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 <alyssa.rosenzweig@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41535>
This commit is contained in:
Kenneth Graunke 2026-05-08 14:40:23 -07:00 committed by Marge Bot
parent f2c5410caf
commit faede3c3c1

View file

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