Mesa (staging/21.3): anv: Fix to honor the spec to get stencil layout.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 9 22:03:12 UTC 2021


Module: Mesa
Branch: staging/21.3
Commit: ff1b1f6c7d85adf191aca287dd9dfe94870ac9ae
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff1b1f6c7d85adf191aca287dd9dfe94870ac9ae

Author: Hyunjun Ko <zzoon at igalia.com>
Date:   Fri Sep 17 02:07:14 2021 +0000

anv: Fix to honor the spec to get stencil layout.

Fixes: 28207669d0 ("anv: Fix stencil layout in render passes")

Signed-off-by: Hyunjun Ko <zzoon at igalia.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12785>
(cherry picked from commit 00bea38242d97e7ace1954f1bc7d32cbf0ce3ee0)

---

 .pick_status.json           |  2 +-
 src/intel/vulkan/anv_pass.c | 50 +++++++++++++++++++++++++++++++--------------
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e91a28f1ac2..78389eb7e27 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -139,7 +139,7 @@
         "description": "anv: Fix to honor the spec to get stencil layout.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "28207669d03a7e4829169790dde332e90b6e0209"
     },
diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c
index e41b2756b03..0dec9fb2951 100644
--- a/src/intel/vulkan/anv_pass.c
+++ b/src/intel/vulkan/anv_pass.c
@@ -275,15 +275,24 @@ vk_image_layout_depth_only(VkImageLayout layout)
 static VkImageLayout
 stencil_ref_layout(const VkAttachmentReference2KHR *att_ref)
 {
-   if (!vk_image_layout_depth_only(att_ref->layout))
-      return att_ref->layout;
-
    const VkAttachmentReferenceStencilLayoutKHR *stencil_ref =
       vk_find_struct_const(att_ref->pNext,
                            ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR);
-   if (!stencil_ref)
-      return VK_IMAGE_LAYOUT_UNDEFINED;
-   return stencil_ref->stencilLayout;
+
+   if (stencil_ref)
+      return stencil_ref->stencilLayout;
+
+   /* From VUID-VkAttachmentReference2-attachment-04755:
+    *  "If attachment is not VK_ATTACHMENT_UNUSED, and the format of the
+    *   referenced attachment is a depth/stencil format which includes both
+    *   depth and stencil aspects, and layout is
+    *   VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL or
+    *   VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL, the pNext chain must include
+    *   a VkAttachmentReferenceStencilLayout structure."
+    */
+   assert(!vk_image_layout_depth_only(att_ref->layout));
+
+   return att_ref->layout;
 }
 
 /* From the Vulkan Specification 1.2.166 - VkAttachmentDescription2:
@@ -301,18 +310,29 @@ stencil_desc_layout(const VkAttachmentDescription2KHR *att_desc, bool final)
    if (!vk_format_has_stencil(att_desc->format))
       return VK_IMAGE_LAYOUT_UNDEFINED;
 
-   const VkImageLayout main_layout =
-      final ? att_desc->finalLayout : att_desc->initialLayout;
-   if (!vk_image_layout_depth_only(main_layout))
-      return main_layout;
-
    const VkAttachmentDescriptionStencilLayoutKHR *stencil_desc =
       vk_find_struct_const(att_desc->pNext,
                            ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR);
-   assert(stencil_desc);
-   return final ?
-      stencil_desc->stencilFinalLayout :
-      stencil_desc->stencilInitialLayout;
+
+   if (stencil_desc) {
+      return final ?
+         stencil_desc->stencilFinalLayout :
+         stencil_desc->stencilInitialLayout;
+   }
+
+   const VkImageLayout main_layout =
+      final ? att_desc->finalLayout : att_desc->initialLayout;
+
+   /* From VUID-VkAttachmentDescription2-format-03302/03303:
+    *  "If format is a depth/stencil format which includes both depth and
+    *   stencil aspects, and initial/finalLayout is
+    *   VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL or
+    *   VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL, the pNext chain must include
+    *   a VkAttachmentDescriptionStencilLayout structure."
+    */
+   assert(!vk_image_layout_depth_only(main_layout));
+
+   return main_layout;
 }
 
 VkResult anv_CreateRenderPass2(



More information about the mesa-commit mailing list