pan/bi: TEX_GRADIENT may need helper invocations

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: 4e58029dc0 ("pan/va: fix base-level for nir_texop_lod")
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
This commit is contained in:
Iago Toral Quiroga 2026-05-06 11:01:45 +02:00 committed by Erik Faye-Lund
parent 4dbdd4c0ee
commit eb14281b3c
2 changed files with 5 additions and 1 deletions

View file

@ -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;

View file

@ -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);