Module: Mesa
Branch: main
Commit: 796cba9bda2adb4a90b9e8dc83a2f0b3756056b4
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=796cba9bda2adb4a90b9e8dc83a2f0b3756056b4

Author: Chia-I Wu <olva...@gmail.com>
Date:   Tue Oct 31 16:46:44 2023 -0700

radv: fix vkCmdCopyImage2 for emulated etc2/astc

When the image copy is between size-compatible formats with different
block sizes, we need to fix up the extent.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25984>

---

 src/amd/vulkan/meta/radv_meta_copy.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/meta/radv_meta_copy.c 
b/src/amd/vulkan/meta/radv_meta_copy.c
index 33eb5e99d26..ad4c330bbce 100644
--- a/src/amd/vulkan/meta/radv_meta_copy.c
+++ b/src/amd/vulkan/meta/radv_meta_copy.c
@@ -606,14 +606,21 @@ radv_CmdCopyImage2(VkCommandBuffer commandBuffer, const 
VkCopyImageInfo2 *pCopyI
 
       const enum util_format_layout format_layout = 
vk_format_description(dst_image->vk.format)->layout;
       for (unsigned r = 0; r < pCopyImageInfo->regionCount; r++) {
+         VkExtent3D dst_extent = pCopyImageInfo->pRegions[r].extent;
+         if (src_image->vk.format != dst_image->vk.format) {
+            dst_extent.width = dst_extent.width / 
vk_format_get_blockwidth(src_image->vk.format) *
+                               vk_format_get_blockwidth(dst_image->vk.format);
+            dst_extent.height = dst_extent.height / 
vk_format_get_blockheight(src_image->vk.format) *
+                                
vk_format_get_blockheight(dst_image->vk.format);
+         }
          if (format_layout == UTIL_FORMAT_LAYOUT_ASTC) {
             radv_meta_decode_astc(cmd_buffer, dst_image, 
pCopyImageInfo->dstImageLayout,
                                   &pCopyImageInfo->pRegions[r].dstSubresource, 
pCopyImageInfo->pRegions[r].dstOffset,
-                                  pCopyImageInfo->pRegions[r].extent);
+                                  dst_extent);
          } else {
             radv_meta_decode_etc(cmd_buffer, dst_image, 
pCopyImageInfo->dstImageLayout,
                                  &pCopyImageInfo->pRegions[r].dstSubresource, 
pCopyImageInfo->pRegions[r].dstOffset,
-                                 pCopyImageInfo->pRegions[r].extent);
+                                 dst_extent);
          }
       }
    }

Reply via email to