radv: fix msaa feedback loop without tc-compat cmask
authorChia-I Wu <olvaffe@gmail.com>
Tue, 30 May 2023 22:43:16 +0000 (15:43 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 31 May 2023 14:57:57 +0000 (14:57 +0000)
When in an msaa feedback loop and when the image does not have tc-compat
cmask, we have to decompress and expand fmask.  This can happen on gfx9
when sample count > 2 or when RADV_DEBUG=notccompatcmask is specified.

Fixes: a38de4c011d ("radv: disable tc_compatible_cmask on GFX9 in some cases")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23331>

src/amd/vulkan/radv_image.c

index 93965ea..cc6ae6e 100644 (file)
@@ -2500,15 +2500,23 @@ radv_layout_fmask_compression(const struct radv_device *device, const struct rad
    if (layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL && (queue_mask & (1u << RADV_QUEUE_COMPUTE)))
       return RADV_FMASK_COMPRESSION_NONE;
 
-   if (layout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL ||
-       layout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) {
-      return radv_image_is_tc_compat_cmask(image) ? RADV_FMASK_COMPRESSION_FULL :
-         RADV_FMASK_COMPRESSION_PARTIAL;
-   }
+   /* Compress images if TC-compat CMASK is enabled. */
+   if (radv_image_is_tc_compat_cmask(image))
+      return RADV_FMASK_COMPRESSION_FULL;
 
-   /* Only compress concurrent images if TC-compat CMASK is enabled (no FMASK decompression). */
-   return (queue_mask == (1u << RADV_QUEUE_GENERAL) || radv_image_is_tc_compat_cmask(image)) ?
-      RADV_FMASK_COMPRESSION_FULL : RADV_FMASK_COMPRESSION_NONE;
+   switch (layout) {
+   case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
+   case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
+      /* Don't compress images but no need to expand FMASK. */
+      return RADV_FMASK_COMPRESSION_PARTIAL;
+   case VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT:
+      /* Don't compress images that are in feedback loops. */
+      return RADV_FMASK_COMPRESSION_NONE;
+   default:
+      /* Don't compress images that are concurrent. */
+      return queue_mask == (1u << RADV_QUEUE_GENERAL) ?
+         RADV_FMASK_COMPRESSION_FULL : RADV_FMASK_COMPRESSION_NONE;
+   }
 }
 
 unsigned