Module: Mesa
Branch: main
Commit: 5a952807487255cb8e3be6bc2eb66041f7f7785b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5a952807487255cb8e3be6bc2eb66041f7f7785b

Author: Christian Gmeiner <[email protected]>
Date:   Tue Jul 11 15:46:55 2023 +0200

etnaviv: nir: lower nir_texop_txs

Non of the GPU models know at this time have hardware support to
retrieve the dimensions of a level of a texture. Do almost the
same as the binary blob and store the needed values as uniforms.

Passes dEQP-GLES3.functional.shaders.texture_functions.texturesize.*

Signed-off-by: Christian Gmeiner <[email protected]>
Acked-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24217>

---

 .../drivers/etnaviv/etnaviv_nir_lower_texture.c    | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c
index 4348e9e32c9..3e15fa317c9 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c
@@ -5,6 +5,27 @@
 
 #include "etnaviv_nir.h"
 
+static bool
+lower_txs(nir_builder *b, nir_instr *instr, UNUSED void *data)
+{
+   if (instr->type != nir_instr_type_tex)
+      return false;
+
+   nir_tex_instr *tex = nir_instr_as_tex(instr);
+
+   if (tex->op != nir_texop_txs)
+      return false;
+
+   b->cursor = nir_instr_remove(instr);
+
+   nir_ssa_def *idx = nir_imm_int(b, tex->texture_index);
+   nir_ssa_def *sizes = nir_load_texture_size_etna(b, 32, idx);
+
+   nir_ssa_def_rewrite_uses(&tex->dest.ssa, sizes);
+
+   return true;
+}
+
 bool
 etna_nir_lower_texture(nir_shader *s, struct etna_shader_key *key)
 {
@@ -12,6 +33,7 @@ etna_nir_lower_texture(nir_shader *s, struct etna_shader_key 
*key)
 
    nir_lower_tex_options lower_tex_options = {
       .lower_txp = ~0u,
+      .lower_txs_lod = true,
       .lower_invalid_implicit_lod = true,
    };
 
@@ -22,5 +44,8 @@ etna_nir_lower_texture(nir_shader *s, struct etna_shader_key 
*key)
                                                   key->tex_compare_func,
                                                   key->tex_swizzle);
 
+   NIR_PASS(progress, s, nir_shader_instructions_pass, lower_txs,
+         nir_metadata_block_index | nir_metadata_dominance, NULL);
+
    return progress;
 }

Reply via email to