[Mesa-dev] [PATCH 1/6] nir/lower_tex: generalize get_texture_size()
Kenneth Graunke
kenneth at whitecape.org
Tue Dec 6 04:38:53 UTC 2016
On Thursday, December 1, 2016 8:53:16 AM PST Iago Toral Quiroga wrote:
> This was written specifically for RECT samplers. Make it more generic so
> we can call this from the gradient lowerings too.
> ---
> src/compiler/nir/nir_lower_tex.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
> index 0efd443..ccca59b 100644
> --- a/src/compiler/nir/nir_lower_tex.c
> +++ b/src/compiler/nir/nir_lower_tex.c
> @@ -154,22 +154,27 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex)
> {
> b->cursor = nir_before_instr(&tex->instr);
>
> - /* RECT textures should not be array: */
> - assert(!tex->is_array);
> -
> nir_tex_instr *txs;
>
> txs = nir_tex_instr_create(b->shader, 1);
> txs->op = nir_texop_txs;
> - txs->sampler_dim = GLSL_SAMPLER_DIM_RECT;
> + txs->sampler_dim = tex->sampler_dim;
> + txs->is_array = tex->is_array;
> + txs->is_shadow = tex->is_shadow;
> + txs->is_new_style_shadow = tex->is_new_style_shadow;
> txs->texture_index = tex->texture_index;
> + txs->texture = (nir_deref_var *)
> + nir_copy_deref(txs, &tex->texture->deref);
> + txs->sampler_index = tex->sampler_index;
> + txs->sampler = (nir_deref_var *)
> + nir_copy_deref(txs, &tex->sampler->deref);
> txs->dest_type = nir_type_int;
>
> /* only single src, the lod: */
> txs->src[0].src = nir_src_for_ssa(nir_imm_int(b, 0));
> txs->src[0].src_type = nir_tex_src_lod;
>
> - nir_ssa_dest_init(&txs->instr, &txs->dest, 2, 32, NULL);
> + nir_ssa_dest_init(&txs->instr, &txs->dest, tex->coord_components, 32, NULL);
Hrm. Won't this make it start returning 3 for array textures? It looks
like you want 3 for 3D, 1 for 1D, and 2 for everything else...
I guess you swizzle away the unnecessary components, but another option
would be to just pass in the number of components you wanted, rather
than emitting moves to scrap them.
-------------- 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/20161205/657dac99/attachment-0001.sig>
More information about the mesa-dev
mailing list