Mesa (staging/21.3): radv: 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: 83c298a3c4e86f893b33736c27220954d37809ac
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83c298a3c4e86f893b33736c27220954d37809ac
Author: Hyunjun Ko <zzoon at igalia.com>
Date: Fri Sep 17 02:10:22 2021 +0000
radv: Fix to honor the spec to get stencil layout.
Fixes: 3ef89b245e3e ("radv: fix separate depth/stencil layout in render pass")
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 2a0253b9b5d21c7571555abe3a1d851468a18740)
---
.pick_status.json | 2 +-
src/amd/vulkan/radv_pass.c | 31 +++++++++++++++++++++++++------
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 78389eb7e27..08cc2e00d1e 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -130,7 +130,7 @@
"description": "radv: Fix to honor the spec to get stencil layout.",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "3ef89b245e3e1ac4e67fea9c1b13ebeda75769d0"
},
diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index 26063f57dd7..ff7c42237ca 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -333,15 +333,23 @@ vk_image_layout_depth_only(VkImageLayout layout)
static VkImageLayout
stencil_ref_layout(const VkAttachmentReference2 *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.184:
@@ -371,6 +379,17 @@ stencil_desc_layout(const VkAttachmentDescription2KHR *att_desc, bool final)
if (stencil_desc)
return final ? stencil_desc->stencilFinalLayout : stencil_desc->stencilInitialLayout;
+
+ /* 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(final ? att_desc->finalLayout :
+ att_desc->initialLayout));
+
return final ? att_desc->finalLayout : att_desc->initialLayout;
}
More information about the mesa-commit
mailing list