Samuel Iglesias Gonsálvez <sigles...@igalia.com> writes: > Signed-off-by: Samuel Iglesias Gonsálvez <sigles...@igalia.com> > --- > src/compiler/nir/nir_lower_tex.c | 68 > ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > > diff --git a/src/compiler/nir/nir_lower_tex.c > b/src/compiler/nir/nir_lower_tex.c > index 65681decb1c..d3380710405 100644 > --- a/src/compiler/nir/nir_lower_tex.c > +++ b/src/compiler/nir/nir_lower_tex.c > @@ -717,6 +717,52 @@ linearize_srgb_result(nir_builder *b, nir_tex_instr *tex) > result->parent_instr); > } > > +static void > +set_default_lod(nir_builder *b, nir_tex_instr *tex) > +{ > + b->cursor = nir_before_instr(&tex->instr); > + > + /* We are going to emit the same texture but adding a default LOD. > + */ > + int num_srcs = tex->num_srcs + 1; > + nir_tex_instr *new = nir_tex_instr_create(b->shader, num_srcs); > + > + new->op = tex->op; > + new->sampler_dim = tex->sampler_dim; > + new->texture_index = tex->texture_index; > + new->dest_type = tex->dest_type; > + new->is_array = tex->is_array; > + new->is_shadow = tex->is_shadow; > + new->is_new_style_shadow = tex->is_new_style_shadow; > + new->sampler_index = tex->sampler_index; > + new->texture = nir_deref_var_clone(tex->texture, new); > + new->sampler = nir_deref_var_clone(tex->sampler, new); > + new->coord_components = tex->coord_components;
Couldn't we just make a new srcs array of num_srcs+1, memcpy the old srcs/types over, add our new use of the immediate 0 lod to it by manipulating the immediate's uses list, and free the old list? It seems less fragile to me than needing to update this path if we add a new texture flag.
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev