From 4412f3bad7a95020cb9f447add2a0a8a5e5c985f Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 1 May 2026 13:42:07 -0400 Subject: [PATCH] panfrost: Take texture/sampler_index into account in lower_res_indices We currently rely on nir_lower_tex_options::lower_index_to_offset but there's really no reason for this. Our pan_nir_res_handle() helper can already take both an immediate and a dynamic index. Reviewed-by: Ryan Mckeever Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- .../drivers/panfrost/pan_nir_lower_res_indices.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_nir_lower_res_indices.c b/src/gallium/drivers/panfrost/pan_nir_lower_res_indices.c index 8d250068f69..66242d7f0e7 100644 --- a/src/gallium/drivers/panfrost/pan_nir_lower_res_indices.c +++ b/src/gallium/drivers/panfrost/pan_nir_lower_res_indices.c @@ -15,10 +15,11 @@ lower_tex(nir_builder *b, nir_tex_instr *tex) b->cursor = nir_before_instr(&tex->instr); nir_def *tex_offset = nir_steal_tex_src(tex, nir_tex_src_texture_offset); - nir_def *sampler_offset = nir_steal_tex_src(tex, nir_tex_src_sampler_offset); + nir_def *samp_offset = nir_steal_tex_src(tex, nir_tex_src_sampler_offset); if (tex_offset != NULL) { - tex_offset = pan_nir_res_handle(b, PAN_TABLE_TEXTURE, 0, tex_offset); + tex_offset = pan_nir_res_handle(b, PAN_TABLE_TEXTURE, + tex->texture_index, tex_offset); nir_tex_instr_add_src(tex, nir_tex_src_texture_offset, tex_offset); } else { tex->texture_index = @@ -30,10 +31,10 @@ lower_tex(nir_builder *b, nir_tex_instr *tex) */ if (!nir_tex_instr_need_sampler(tex)) { tex->sampler_index = pan_res_handle(PAN_TABLE_SAMPLER, 0); - } else if (sampler_offset != NULL) { - sampler_offset = - pan_nir_res_handle(b, PAN_TABLE_SAMPLER, 0, sampler_offset); - nir_tex_instr_add_src(tex, nir_tex_src_sampler_offset, sampler_offset); + } else if (samp_offset != NULL) { + samp_offset = pan_nir_res_handle(b, PAN_TABLE_SAMPLER, + tex->sampler_index, samp_offset); + nir_tex_instr_add_src(tex, nir_tex_src_sampler_offset, samp_offset); } else { tex->sampler_index = pan_res_handle(PAN_TABLE_SAMPLER, tex->sampler_index);