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;