radv: fix copying 2D to 3D images
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 25 May 2023 08:44:11 +0000 (10:44 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 26 May 2023 08:41:31 +0000 (08:41 +0000)
CTS is testing 2D to 3D image copies but the checks are incomplete and
we used to only copy the first slice.

This should fix
dEQP-GLES31.functional.copy_image.non_compressed.*.texture2d_array_to_texture3d
with ANGLE.

Cc: mesa-stable
Suggested-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23231>

src/amd/vulkan/meta/radv_meta_copy.c

index d70a7fa..1f90698 100644 (file)
@@ -497,19 +497,17 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
          .height = img_extent_el.height,
       };
 
-      if (src_image->vk.image_type == VK_IMAGE_TYPE_3D)
+      unsigned num_slices = region->srcSubresource.layerCount;
+
+      if (src_image->vk.image_type == VK_IMAGE_TYPE_3D) {
          b_src.layer = src_offset_el.z;
+         num_slices = img_extent_el.depth;
+      }
 
       if (dst_image->vk.image_type == VK_IMAGE_TYPE_3D)
          b_dst.layer = dst_offset_el.z;
 
-      /* Loop through each 3D or array slice */
-      unsigned num_slices_3d = img_extent_el.depth;
-      unsigned num_slices_array = region->dstSubresource.layerCount;
-      unsigned slice_3d = 0;
-      unsigned slice_array = 0;
-      while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
-
+      for (unsigned slice = 0; slice < num_slices; slice++) {
          /* Finish creating blit rect */
          rect.dst_x = dst_offset_el.x;
          rect.dst_y = dst_offset_el.y;
@@ -529,10 +527,6 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
 
          b_src.layer++;
          b_dst.layer++;
-         if (dst_image->vk.image_type == VK_IMAGE_TYPE_3D)
-            slice_3d++;
-         else
-            slice_array++;
       }
    }