Module: Mesa
Branch: main
Commit: 239363f3c61aa87431c1d444e641f1a45404c477
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=239363f3c61aa87431c1d444e641f1a45404c477

Author: Samuel Pitoiset <[email protected]>
Date:   Thu Mar 11 13:58:35 2021 +0100

radv: implement VK_EXT_attachment_feedback_loop_layout

This extension introduces a new layout which allows applications
to both render and sample from the same image inside the same draw
(aka. feedback loops).

Previously, the GENERAL layout was used and this introduced some
rendering artifacts because the hw can't read&write DCC/HTILE for
the same image, and we try to keep it compressed on GFX10+.

This helps fixing corruption with D3D9 and RPCS3 games which
are candidate for feedback loops.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4411
Signed-off-by: Samuel Pitoiset <[email protected]>

Reviewed-by: Timur Kristóf <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17883>

---

 docs/relnotes/new_features.txt |  1 +
 src/amd/vulkan/radv_device.c   |  7 +++++++
 src/amd/vulkan/radv_image.c    | 12 ++++++++++++
 3 files changed, 20 insertions(+)

diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt
index 4948d8fc146..ac6a227d735 100644
--- a/docs/relnotes/new_features.txt
+++ b/docs/relnotes/new_features.txt
@@ -1,3 +1,4 @@
 GL_ARB_shader_clock on llvmpipe
 VK_KHR_shader_clock on lavapipe
 Mesa-DB, the new single file cache type
+VK_EXT_attachment_feedback_loop_layout on RADV
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index bc6ada7cbfd..29b9e2371b0 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -519,6 +519,7 @@ radv_physical_device_get_supported_extensions(const struct 
radv_physical_device
       .KHR_workgroup_memory_explicit_layout = true,
       .KHR_zero_initialize_workgroup_memory = true,
       .EXT_4444_formats = true,
+      .EXT_attachment_feedback_loop_layout = true,
       .EXT_border_color_swizzle = device->rad_info.gfx_level >= GFX10,
       .EXT_buffer_device_address = true,
       .EXT_calibrated_timestamps = RADV_SUPPORT_CALIBRATED_TIMESTAMPS,
@@ -1850,6 +1851,12 @@ radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice 
physicalDevice,
          features->deviceGeneratedCommands = true;
          break;
       }
+      case 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT: 
{
+         VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *features =
+            (VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *)ext;
+         features->attachmentFeedbackLoopLayout = true;
+        break;
+      }
       default:
          break;
       }
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 487d1cf059c..107572019e2 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -2241,6 +2241,11 @@ radv_layout_is_htile_compressed(const struct radv_device 
*device, const struct r
       } else {
          return false;
       }
+   case VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT:
+      /* Do not compress HTILE with feedback loops because we can't read&write 
it without
+       * introducing corruption.
+       */
+      return false;
    case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
       if (radv_image_is_tc_compat_htile(image) ||
           (radv_image_has_htile(image) &&
@@ -2303,6 +2308,13 @@ radv_layout_dcc_compressed(const struct radv_device 
*device, const struct radv_i
        (queue_mask & (1u << RADV_QUEUE_COMPUTE)) && 
!radv_image_use_dcc_image_stores(device, image))
       return false;
 
+   if (layout == VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT) {
+      /* Do not compress DCC with feedback loops because we can't read&write 
it without introducing
+       * corruption.
+       */
+      return false;
+   }
+
    return device->physical_device->rad_info.gfx_level >= GFX10 || layout != 
VK_IMAGE_LAYOUT_GENERAL;
 }
 

Reply via email to