[Mesa-dev] [PATCH v2 1/4] nir: set default lod to texture opcodes that needed it but don't provide it
Eric Anholt
eric at anholt.net
Tue Oct 10 18:53:27 UTC 2017
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, 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: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171010/1d69d308/attachment-0001.sig>
More information about the mesa-dev
mailing list