pan/bi: Fix simple txl test
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fixes: 731dfc6066d ("pan/bi: Allow vertex txl with lod=0 as compact")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index aaf3d7b..2de2e7f 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -995,32 +995,24 @@
unreachable("stub");
}
-/* Normal textures ops are tex for frag shaders and txl for vertex shaders with
- * lod a constant 0. Anything else needs a full texture op. */
+/* Simple textures ops correspond to NIR tex or txl with LOD = 0. Anything else
+ * needs a complete texture op. */
static bool
bi_is_normal_tex(gl_shader_stage stage, nir_tex_instr *instr)
{
- if (stage == MESA_SHADER_FRAGMENT)
- return instr->op == nir_texop_tex;
+ if (instr->op == nir_texop_tex)
+ return true;
if (instr->op != nir_texop_txl)
return false;
- for (unsigned i = 0; i < instr->num_srcs; ++i) {
- if (instr->src[i].src_type != nir_tex_src_lod)
- continue;
+ int lod_idx = nir_tex_instr_src_index(instr, nir_tex_src_lod);
+ if (lod_idx < 0)
+ return true;
- nir_src src = instr->src[i].src;
-
- if (!nir_src_is_const(src))
- continue;
-
- if (nir_src_as_uint(src) != 0)
- continue;
- }
-
- return true;
+ nir_src lod = instr->src[lod_idx].src;
+ return nir_src_is_const(lod) && nir_src_as_uint(lod) == 0;
}
static void