summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2016-11-30 12:42:54 +0100
committerIago Toral Quiroga <[email protected]>2016-12-13 10:31:38 +0100
commitbac303c286de2a07912333a775bf4af18cd04e7a (patch)
tree2ad36890dff16e864d85652f30ddd8fb655ab19c /src/compiler/nir
parentfd249c803e3ae2acb83f5e3b7152728e73228b7b (diff)
nir/lower_tex: generalize get_texture_size()
This was written specifically for RECT samplers. Make it more generic so we can call this from the gradient lowerings too. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_lower_tex.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 39f7af7c582..08cb6681ace 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);
nir_builder_instr_insert(b, &txs->instr);
return nir_i2f(b, &txs->dest.ssa);