From 76e33d528bb82ead1ec869001833b233166fd4b4 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 10 Dec 2020 14:28:11 +0100 Subject: [PATCH] radv: clean up radv_layout_is_htile_compressed() Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_image.c | 50 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 4203f4262eb..2d46b1d86b1 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -1749,35 +1749,29 @@ bool radv_layout_is_htile_compressed(const struct radv_image *image, bool in_render_loop, unsigned queue_mask) { - if (radv_image_is_tc_compat_htile(image)) { - if (layout == VK_IMAGE_LAYOUT_GENERAL && - !in_render_loop && - !(image->usage & VK_IMAGE_USAGE_STORAGE_BIT)) { - /* It should be safe to enable TC-compat HTILE with - * VK_IMAGE_LAYOUT_GENERAL if we are not in a render - * loop and if the image doesn't have the storage bit - * set. This improves performance for apps that use - * GENERAL for the main depth pass because this allows - * compression and this reduces the number of - * decompressions from/to GENERAL. - */ - return true; - } - - if ((layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL || - layout == VK_IMAGE_LAYOUT_GENERAL) && - (queue_mask & (1u << RADV_QUEUE_COMPUTE))) - return false; - - return layout != VK_IMAGE_LAYOUT_GENERAL; + switch (layout) { + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR: + case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR: + return radv_image_has_htile(image); + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + return radv_image_has_htile(image) && queue_mask == (1u << RADV_QUEUE_GENERAL); + case VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR: + case VK_IMAGE_LAYOUT_GENERAL: + /* It should be safe to enable TC-compat HTILE with + * VK_IMAGE_LAYOUT_GENERAL if we are not in a render loop and + * if the image doesn't have the storage bit set. This + * improves performance for apps that use GENERAL for the main + * depth pass because this allows compression and this reduces + * the number of decompressions from/to GENERAL. + */ + return radv_image_is_tc_compat_htile(image) && + queue_mask == (1u << RADV_QUEUE_GENERAL) && + !(image->usage & VK_IMAGE_USAGE_STORAGE_BIT) && + !in_render_loop; + default: + return radv_image_is_tc_compat_htile(image); } - - return radv_image_has_htile(image) && - (layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL || - layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR || - layout == VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR || - (layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL && - queue_mask == (1u << RADV_QUEUE_GENERAL))); } bool radv_layout_can_fast_clear(const struct radv_device *device,