From faede3c3c14db2510b6428cbea57832c3972d0a3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 8 May 2026 14:40:23 -0700 Subject: [PATCH] intel/nir: Only add an explicit LOD 0 when lod/bias don't already exist When lowering tg4 sparse testing to a non-gather opcode, we were adding an explicit LOD 0 parameter. But we might already have a LOD or bias. Fixes tests like: dEQP-VK.glsl.texture_gather.basic.2d.rgba8.base_level.sparse_level_1_amd_lod dEQP-VK.glsl.texture_gather.basic.2d.rgba8.base_level.sparse_level_1_amd_bias Reviewed-by: Alyssa Rosenzweig Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/intel_nir_lower_sparse.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/intel/compiler/intel_nir_lower_sparse.c b/src/intel/compiler/intel_nir_lower_sparse.c index ead2f5403c7..efae36b8aa5 100644 --- a/src/intel/compiler/intel_nir_lower_sparse.c +++ b/src/intel/compiler/intel_nir_lower_sparse.c @@ -152,13 +152,14 @@ split_tex_residency(nir_builder *b, nir_tex_instr *tex, bool jay) * out unwanted color components, using fewer registers. */ if (tex->op == nir_texop_tg4) { - if (!sparse_tex->is_gather_implicit_lod) { + if (sparse_tex->is_gather_implicit_lod) { + assert(nir_tex_instr_src_index(sparse_tex, nir_tex_src_lod) == -1); + } else if (nir_tex_instr_src_index(sparse_tex, nir_tex_src_lod) == -1 && + nir_tex_instr_src_index(sparse_tex, nir_tex_src_bias) == -1) { /* Add explicit LOD 0 */ nir_builder bb = nir_builder_at(nir_after_instr(&tex->instr)); nir_tex_instr_add_src(sparse_tex, nir_tex_src_lod, - nir_imm_int(&bb, 0)); - } else { - assert(nir_tex_instr_src_index(sparse_tex, nir_tex_src_lod) == -1); + nir_imm_int(&bb, 0)); } if (jay)