From eb14281b3c361b3b76848a3379a97dfa2cff0678 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 6 May 2026 11:01:45 +0200 Subject: [PATCH] pan/bi: TEX_GRADIENT may need helper invocations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we use the texture coordinates mode for TEX_GRADIENT we need valid texture coordinates on disabled lanes to compute correct lods across all pixels on a triangle, otherwise pixels along triangle edges will read garbage when computing coordinate deltas and produce bogus results. We previously tried to solve this by setting the force_delta_enable bit, but that doesn't always work... and worse, this bit isn't supported on V9, which means we sometimes end up generating illegal instructions. Fixes Piglit: shaders/zero-tex-coord texturequerylod Fixes: 4e58029dc01 ("pan/va: fix base-level for nir_texop_lod") Reviewed-by: Alejandro PiƱeiro Reviewed-by: Erik Faye-Lund Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Lorenzo Rossi --- src/panfrost/compiler/bifrost/bi_helper_invocations.c | 4 ++++ src/panfrost/compiler/pan_nir_lower_tex.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/panfrost/compiler/bifrost/bi_helper_invocations.c b/src/panfrost/compiler/bifrost/bi_helper_invocations.c index 5e59521a47e..e7b32aecffe 100644 --- a/src/panfrost/compiler/bifrost/bi_helper_invocations.c +++ b/src/panfrost/compiler/bifrost/bi_helper_invocations.c @@ -79,6 +79,10 @@ bi_instr_uses_helpers(bi_instr *I) case BI_OPCODE_TEX_SINGLE: return (I->va_lod_mode == BI_VA_LOD_MODE_COMPUTED_LOD) || (I->va_lod_mode == BI_VA_LOD_MODE_COMPUTED_BIAS); + case BI_OPCODE_TEX_GRADIENT: + /* If we don't use derivatives to compute the lod we need disabled lanes + * to have valid texture coordinates. */ + return !I->derivative_enable; case BI_OPCODE_WMASK: /* Helpers are needed to implement voting in fragment shaders. */ return true; diff --git a/src/panfrost/compiler/pan_nir_lower_tex.c b/src/panfrost/compiler/pan_nir_lower_tex.c index d6bb5ea8617..47935ce2760 100644 --- a/src/panfrost/compiler/pan_nir_lower_tex.c +++ b/src/panfrost/compiler/pan_nir_lower_tex.c @@ -979,7 +979,7 @@ va_lower_lod(nir_builder *b, nir_tex_instr *tex, uint64_t gpu_id) struct pan_va_tex_flags flags = { .wide_indices = tex_h->num_components > 1, .derivative_enable = false, - .force_delta_enable = true, + .force_delta_enable = false, }; tex_h = nir_pad_vector_imm_int(b, tex_h, 0, 2);