From d132ec924d462a4f1a4cb2ba317d4d29c60931aa Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 30 Jun 2022 04:17:12 -0700 Subject: [PATCH] dzn: Support native image copies when formats are compatible CopyTextureRegion() works fine if the formats belong to the same group (matching the same _TYPELESS type), so let's avoid creating a temporary resource in that case. Reviewed-by: Jesse Natalie Part-of: --- src/microsoft/vulkan/dzn_cmd_buffer.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/microsoft/vulkan/dzn_cmd_buffer.c b/src/microsoft/vulkan/dzn_cmd_buffer.c index a1bc1fc427f..123d643105a 100644 --- a/src/microsoft/vulkan/dzn_cmd_buffer.c +++ b/src/microsoft/vulkan/dzn_cmd_buffer.c @@ -3013,9 +3013,24 @@ dzn_CmdCopyImage2(VkCommandBuffer commandBuffer, assert(src->vk.samples == dst->vk.samples); - bool requires_temp_res = src->vk.format != dst->vk.format && - src->vk.tiling != VK_IMAGE_TILING_LINEAR && - dst->vk.tiling != VK_IMAGE_TILING_LINEAR; + bool requires_temp_res = false; + + for (uint32_t i = 0; i < info->regionCount; i++) { + const VkImageCopy2 *region = &info->pRegions[i]; + + dzn_foreach_aspect(aspect, region->srcSubresource.aspectMask) { + assert(aspect & region->dstSubresource.aspectMask); + + if (!dzn_image_formats_are_compatible(device, src->vk.format, dst->vk.format, + VK_IMAGE_USAGE_TRANSFER_SRC_BIT, aspect) && + src->vk.tiling != VK_IMAGE_TILING_LINEAR && + dst->vk.tiling != VK_IMAGE_TILING_LINEAR) { + requires_temp_res = true; + break; + } + } + } + bool use_blit = false; if (src->vk.samples > 1) { use_blit = requires_temp_res;