st_pbo/compute: fix 1D coord dimension by pre-trimming vectors
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 17 Aug 2022 15:50:22 +0000 (11:50 -0400)
committerMarge Bot <emma+marge@anholt.net>
Mon, 22 Aug 2022 02:00:55 +0000 (02:00 +0000)
cc: mesa-stable

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18118>

src/mesa/state_tracker/st_pbo_compute.c

index 61e79f8..b21d10b 100644 (file)
@@ -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;