From 992690e483a6319cbc3eadd48c71afa1f17a1b5d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 25 Mar 2022 18:56:38 -0500 Subject: [PATCH] radv: Only use PLANE_0 in meta when actually needed Part-of: --- src/amd/vulkan/radv_meta_copy.c | 28 ++++++++++++++++++---------- src/amd/vulkan/radv_meta_etc_decode.c | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c index 08e09c2..fda0cb3 100644 --- a/src/amd/vulkan/radv_meta_copy.c +++ b/src/amd/vulkan/radv_meta_copy.c @@ -460,16 +460,24 @@ copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image, } } - VkImageAspectFlags src_aspects[3] = {VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, - VK_IMAGE_ASPECT_PLANE_2_BIT}; - VkImageAspectFlags dst_aspects[3] = {VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, - VK_IMAGE_ASPECT_PLANE_2_BIT}; - unsigned aspect_count = - region->srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT ? src_image->plane_count : 1; - if (region->srcSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) - src_aspects[0] = region->srcSubresource.aspectMask; - if (region->dstSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) - dst_aspects[0] = region->dstSubresource.aspectMask; + VkImageAspectFlags src_aspects[3] = { region->srcSubresource.aspectMask }; + VkImageAspectFlags dst_aspects[3] = { region->dstSubresource.aspectMask }; + unsigned aspect_count = 1; + + if (region->srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT && + src_image->plane_count > 1) { + static const VkImageAspectFlags all_planes[3] = { + VK_IMAGE_ASPECT_PLANE_0_BIT, + VK_IMAGE_ASPECT_PLANE_1_BIT, + VK_IMAGE_ASPECT_PLANE_2_BIT + }; + + aspect_count = src_image->plane_count; + for (unsigned i = 0; i < aspect_count; i++) { + src_aspects[i] = all_planes[i]; + dst_aspects[i] = all_planes[i]; + } + } for (unsigned a = 0; a < aspect_count; ++a) { /* Create blit surfaces */ diff --git a/src/amd/vulkan/radv_meta_etc_decode.c b/src/amd/vulkan/radv_meta_etc_decode.c index f8d8013..c9e6ccc 100644 --- a/src/amd/vulkan/radv_meta_etc_decode.c +++ b/src/amd/vulkan/radv_meta_etc_decode.c @@ -746,7 +746,7 @@ radv_meta_decode_etc(struct radv_cmd_buffer *cmd_buffer, struct radv_image *imag .format = load_format, .subresourceRange = { - .aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT, + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = subresource->mipLevel, .levelCount = 1, .baseArrayLayer = 0, -- 2.7.4