Mesa (staging/22.1): st/pbo_compute: fix z coords for compute pbos
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 21:17:33 UTC 2022
Module: Mesa
Branch: staging/22.1
Commit: e2fffe018be1b030e28fc1b468a4509448e02d2e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e2fffe018be1b030e28fc1b468a4509448e02d2e
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu May 26 14:19:15 2022 -0400
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: e7b95619596 ("gallium: implement compute pbo download")
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16728>
---
src/mesa/state_tracker/st_pbo_compute.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/mesa/state_tracker/st_pbo_compute.c b/src/mesa/state_tracker/st_pbo_compute.c
index 14f100bd27a..cdb4a45d52d 100644
--- a/src/mesa/state_tracker/st_pbo_compute.c
+++ b/src/mesa/state_tracker/st_pbo_compute.c
@@ -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 *coord = nir_channels(&b, start, (1<<coord_components)-1);
- nir_ssa_def *max = nir_iadd(&b, sd.offset, sd.range);
+ nir_ssa_def *start = nir_iadd(&b, nir_trim_vector(&b, global_id, 2), sd.offset);
+
+ 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);
More information about the mesa-commit
mailing list