From 4b0fc025f39ea8a9393ca712ff3dd61791e5d924 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 2 Apr 2021 18:11:28 +0200 Subject: [PATCH] radv: try to keep HTILE compressed with DEPTH_STENCIL_READ_ONLY_OPTIMAL From the Vulkan spec: "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL specifies a layout for both the depth and stencil aspects of a depth/stencil format image allowing read only access as a depth/stencil attachment or in shaders as a sampled image, combined image/sampler, or input attachment. It is equivalent to VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL and VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL." So, it should be safe to keep HTILE compressed if the depth/stencil image isn't going to be sampled. We could probably extend this to separate depth/stencil layout but that seems a bit more complicated. This gives a huge boost to the deferredmultisampling Vulkan demo. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_image.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 5077a3fb552..4b30ae85d7d 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -2086,6 +2086,19 @@ bool radv_layout_is_htile_compressed(const struct radv_device *device, } else { return false; } + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + if (radv_image_is_tc_compat_htile(image) || + (radv_image_has_htile(image) && + !(image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)))) { + /* Keep HTILE compressed if the image is only going to + * be used as a depth/stencil read-only attachment. + */ + return true; + } else { + return false; + } + break; default: return radv_image_is_tc_compat_htile(image); }