st/pbo_compute: fix z coords for compute pbos

without manually taking the value from the global_id vec, this will
end up being offset.y again, which breaks z-indexing

Fixes: e7b9561959 ("gallium: implement compute pbo download")

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16728>
This commit is contained in:
Mike Blumenkrantz 2022-05-26 14:19:15 -04:00 committed by Dylan Baker
parent d05f81668b
commit 38b59a9e15
2 changed files with 13 additions and 4 deletions

View file

@ -643,7 +643,7 @@
"description": "st/pbo_compute: fix z coords for compute pbos",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 3,
"main_sha": null,
"because_sha": "e7b95619596167025d26f07efb04dc5bfd5e9aee"
},

View file

@ -620,10 +620,19 @@ create_conversion_shader(struct st_context *st, enum pipe_texture_target target,
nir_ssa_def *iid = nir_load_local_invocation_id(&b);
nir_ssa_def *tile = nir_imul(&b, wid, bsize);
nir_ssa_def *global_id = nir_iadd(&b, tile, iid);
nir_ssa_def *start = nir_iadd(&b, global_id, sd.offset);
nir_ssa_def *start = nir_iadd(&b, nir_trim_vector(&b, global_id, 2), sd.offset);
nir_ssa_def *coord = nir_channels(&b, start, (1<<coord_components)-1);
nir_ssa_def *max = nir_iadd(&b, sd.offset, sd.range);
nir_ssa_def *coord;
if (coord_components < 3)
coord = start;
else {
/* pad offset vec with global_id to get correct z offset */
assert(coord_components == 3);
coord = nir_vec3(&b, nir_channel(&b, start, 0),
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))));
nir_tex_instr *txf = nir_tex_instr_create(b.shader, 3);
txf->is_array = glsl_sampler_type_is_array(sampler->type);