radeonsi: fix si_compute_copy_image if DCC decompression happens before a copy
authorMarek Olšák <marek.olsak@amd.com>
Tue, 6 Apr 2021 16:28:46 +0000 (12:28 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 6 Apr 2021 19:19:56 +0000 (19:19 +0000)
The buffer clear after DCC decompression overwrote user SGPRs that we set
here, leading to invalid image coordinates. Set them after we bind images.

This will actually be fixed by "radeonsi: don't decompress DCC for float
formats in si_compute_copy_image" as well.

Fixes: ad71ef9326f "radeonsi: don't use a constant buffer for the copy_image compute shader"
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4583

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10061>

src/gallium/drivers/radeonsi/si_compute_blit.c

index aac8702..57f64af 100644 (file)
@@ -475,12 +475,6 @@ void si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u
 
    void *saved_cs = sctx->cs_shader_state.program;
 
-   if (!is_dcc_decompress) {
-      sctx->cs_user_data[0] = src_box->x | (dstx << 16);
-      sctx->cs_user_data[1] = src_box->y | (dsty << 16);
-      sctx->cs_user_data[2] = src_box->z | (dstz << 16);
-   }
-
    struct pipe_image_view image[2] = {0};
    image[0].resource = src;
    image[0].shader_access = image[0].access = PIPE_IMAGE_ACCESS_READ;
@@ -511,6 +505,12 @@ void si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u
 
    ctx->set_shader_images(ctx, PIPE_SHADER_COMPUTE, 0, 2, 0, image);
 
+   if (!is_dcc_decompress) {
+      sctx->cs_user_data[0] = src_box->x | (dstx << 16);
+      sctx->cs_user_data[1] = src_box->y | (dsty << 16);
+      sctx->cs_user_data[2] = src_box->z | (dstz << 16);
+   }
+
    struct pipe_grid_info info = {0};
 
    if (is_dcc_decompress) {