radeonsi: improve the subsampled copy_image calculation
authorMarek Olšák <marek.olsak@amd.com>
Mon, 25 Apr 2022 10:44:25 +0000 (06:44 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 3 May 2022 15:11:08 +0000 (11:11 -0400)
This fixes a few cases for AMD_TEST=copyimage, but it's still pretty broken.

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

src/gallium/drivers/radeonsi/si_compute_blit.c

index f9cf809..83dd961 100644 (file)
@@ -557,7 +557,20 @@ void si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u
    }
 
    if (util_format_is_subsampled_422(src_format)) {
+      assert(src_format == dst_format);
+
+      src_access |= SI_IMAGE_ACCESS_BLOCK_FORMAT_AS_UINT;
+      dst_access |= SI_IMAGE_ACCESS_BLOCK_FORMAT_AS_UINT;
+
+      dstx = util_format_get_nblocksx(src_format, dstx);
+
+      new_box = *src_box;
+      new_box.x = util_format_get_nblocksx(src_format, src_box->x);
+      new_box.width = util_format_get_nblocksx(src_format, src_box->width);
+      src_box = &new_box;
+
       src_format = dst_format = PIPE_FORMAT_R32_UINT;
+
       /* Interpreting 422 subsampled format (16 bpp) as 32 bpp
        * should force us to divide src_box->x, dstx and width by 2.
        * But given that ac_surface allocates this format as 32 bpp