From 2fa5afd639d0431b6f38da09a3f33a23220004dd Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 17 Aug 2022 11:50:22 -0400 Subject: [PATCH] st_pbo/compute: fix 1D coord dimension by pre-trimming vectors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cc: mesa-stable Acked-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_pbo_compute.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_pbo_compute.c b/src/mesa/state_tracker/st_pbo_compute.c index 61e79f8c0b1..b21d10ba6a0 100644 --- a/src/mesa/state_tracker/st_pbo_compute.c +++ b/src/mesa/state_tracker/st_pbo_compute.c @@ -633,8 +633,13 @@ create_conversion_shader(struct st_context *st, enum pipe_texture_target target, nir_channel(&b, start, 1), nir_channel(&b, global_id, 2)); } - nir_ssa_def *max = nir_iadd(&b, nir_pad_vector_imm_int(&b, sd.offset, 0, 3), sd.range); - nir_push_if(&b, nir_ball(&b, nir_ilt(&b, coord, nir_trim_vector(&b, max, coord_components)))); + coord = nir_trim_vector(&b, coord, coord_components); + nir_ssa_def *offset = coord_components > 2 ? + nir_pad_vector_imm_int(&b, sd.offset, 0, 3) : + nir_trim_vector(&b, sd.offset, coord_components); + nir_ssa_def *range = nir_trim_vector(&b, sd.range, coord_components); + nir_ssa_def *max = nir_iadd(&b, offset, range); + nir_push_if(&b, nir_ball(&b, nir_ilt(&b, coord, max))); nir_tex_instr *txf = nir_tex_instr_create(b.shader, 3); txf->is_array = glsl_sampler_type_is_array(sampler->type); txf->op = nir_texop_txf;