[Mesa-dev] [PATCH v2 1/4] nir: set default lod to texture opcodes that needed it but don't provide it
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Wed Oct 11 08:12:16 UTC 2017
On Tuesday, October 10, 2017 11:53:27 AM CEST Eric Anholt wrote:
> Samuel Iglesias Gonsálvez <siglesias at igalia.com> writes:
> > Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at 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
This is an interesting approach. I have done the following:
b->cursor = nir_before_instr(&tex->instr);
nir_tex_src *srcs = ralloc_array(tex, nir_tex_src, tex->num_srcs + 1);
memcpy(srcs, tex->src, sizeof(nir_tex_src) * tex->num_srcs);
srcs[tex->num_srcs + 1].src = nir_src_for_ssa(nir_imm_int(b, 0));
srcs[tex->num_srcs + 1].src_type = nir_tex_src_lod;
tex->num_srcs++;
ralloc_free(tex->src);
tex->src = srcs;
However, it crashes when validating ssa def. I also tried calling
nir_ssa_def_rewrite_uses() but I am not sure how to do it for this case,
probably I am missing something.
How can I manipulate the immediate's uses list for this case? Can you provide
an example?
Sam
> , and free the old list? It seems
> less fragile to me than needing to update this path if we add a new
> texture flag.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171011/2347b9db/attachment.sig>
More information about the mesa-dev
mailing list