From 3591e2b4cdcf173bbbf73302a43e6065b0729ba7 Mon Sep 17 00:00:00 2001 From: Nick Hamilton Date: Wed, 15 Apr 2026 15:11:28 +0100 Subject: [PATCH] pco: fix clamping the array index when shaderImageGatherExtended is enabled The array index value is a signed integer but the compiler was using the unsigned version of the clamp helper function meaning the value was not been clamped to 0 when its value was < 0. Fix the following deqp test cases when shaderImageGatherExtended is enabled dEQP-VK.glsl.texture_gather.basic.2d_array.* dEQP-VK.glsl.texture_gather.offset.*.2d_array.* dEQP-VK.glsl.texture_gather.offset_dynamic.*.2d_array.* dEQP-VK.glsl.texture_gather.offsets.*.2d_array.* Fixes: 854563f0f82 ("pco: fully switch over to common smp emission code") Signed-off-by: Nick Hamilton Reviewed-by: Frank Binns (cherry picked from commit b80a5f9b7db3894f7f232b0eedd35462475075ae) Part-of: --- .pick_status.json | 2 +- src/imagination/pco/pco_nir_tex.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8a9cf14bc38..537f1ab3e8e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -844,7 +844,7 @@ "description": "pco: fix clamping the array index when shaderImageGatherExtended is enabled", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "854563f0f82ff6d6a0570eee3ee4e24611b6196a", "notes": null diff --git a/src/imagination/pco/pco_nir_tex.c b/src/imagination/pco/pco_nir_tex.c index 77d7a48a990..647d0032a05 100644 --- a/src/imagination/pco/pco_nir_tex.c +++ b/src/imagination/pco/pco_nir_tex.c @@ -641,7 +641,7 @@ static nir_def *lower_tex(nir_builder *b, nir_instr *instr, void *cb_data) assert(array_index); nir_def *array_max = usclib_tex_state_array_max(b, tex_state); - array_index = nir_uclamp(b, array_index, nir_imm_int(b, 0), array_max); + array_index = nir_iclamp(b, array_index, nir_imm_int(b, 0), array_max); if (is_cube_array) array_index = nir_imul_imm(b, array_index, 6); @@ -1244,7 +1244,7 @@ static nir_def *lower_image(nir_builder *b, nir_instr *instr, void *cb_data) if (is_array) { assert(array_index); nir_def *array_max = usclib_tex_state_array_max(b, tex_state); - array_index = nir_uclamp(b, array_index, nir_imm_int(b, 0), array_max); + array_index = nir_iclamp(b, array_index, nir_imm_int(b, 0), array_max); nir_def *tex_meta = nir_load_tex_meta_pco(b, PCO_IMAGE_META_COUNT, @@ -1415,7 +1415,7 @@ static nir_def *lower_image(nir_builder *b, nir_instr *instr, void *cb_data) assert(array_index); nir_def *array_max = usclib_tex_state_array_max(b, tex_state); - array_index = nir_uclamp(b, array_index, nir_imm_int(b, 0), array_max); + array_index = nir_iclamp(b, array_index, nir_imm_int(b, 0), array_max); nir_def *tex_meta = nir_load_tex_meta_pco(b, PCO_IMAGE_META_COUNT,