Mesa (main): radv: fix specifying the stencil layout for separate depth/stencil layouts
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 16 08:54:46 UTC 2021
Module: Mesa
Branch: main
Commit: 0b637919a8a30041c64a201f62aba032254a0e0d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b637919a8a30041c64a201f62aba032254a0e0d
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Wed Jul 14 17:04:18 2021 +0200
radv: fix specifying the stencil layout for separate depth/stencil layouts
The Vulkan spec has been updated few months ago again and pNext is
always honored if present.
Found this with vkd3d-proton which implemented separate depth/stencil
layouts recently.
Cc: 21.2 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11903>
---
src/amd/vulkan/radv_meta_decompress.c | 1 +
src/amd/vulkan/radv_meta_fast_clear.c | 1 +
src/amd/vulkan/radv_meta_resolve.c | 1 +
src/amd/vulkan/radv_pass.c | 30 +++++++++++++++++-------------
4 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index 8407d18f6f1..6f0b644531d 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -42,6 +42,7 @@ create_pass(struct radv_device *device, uint32_t samples, VkRenderPass *pass)
VkAttachmentDescription2 attachment;
attachment.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
+ attachment.pNext = NULL;
attachment.flags = 0;
attachment.format = VK_FORMAT_D32_SFLOAT_S8_UINT;
attachment.samples = samples;
diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c
index 64b2910458b..ccd66226f22 100644
--- a/src/amd/vulkan/radv_meta_fast_clear.c
+++ b/src/amd/vulkan/radv_meta_fast_clear.c
@@ -153,6 +153,7 @@ create_pass(struct radv_device *device)
VkAttachmentDescription2 attachment;
attachment.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
+ attachment.pNext = NULL;
attachment.format = VK_FORMAT_UNDEFINED;
attachment.samples = 1;
attachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 9a3bdac7057..e955ddced91 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -57,6 +57,7 @@ create_pass(struct radv_device *device, VkFormat vk_format, VkRenderPass *pass)
for (i = 0; i < 2; i++) {
attachments[i].sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
+ attachments[i].pNext = NULL;
attachments[i].format = vk_format;
attachments[i].samples = 1;
attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index 30c1b3fa658..d5121d62953 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -344,14 +344,20 @@ stencil_ref_layout(const VkAttachmentReference2 *att_ref)
return stencil_ref->stencilLayout;
}
-/* From the Vulkan Specification 1.2.166 - VkAttachmentDescription2:
+/* From the Vulkan Specification 1.2.184:
*
- * "If format is a depth/stencil format, and initialLayout only specifies the
- * initial layout of the depth aspect of the attachment, the initial layout of
- * the stencil aspect is specified by the stencilInitialLayout member of a
- * VkAttachmentDescriptionStencilLayout structure included in the pNext chain.
- * Otherwise, initialLayout describes the initial layout for all relevant
- * image aspects."
+ * "If the pNext chain includes a VkAttachmentDescriptionStencilLayout structure, then the
+ * stencilInitialLayout and stencilFinalLayout members specify the initial and final layouts of the
+ * stencil aspect of a depth/stencil format, and initialLayout and finalLayout only apply to the
+ * depth aspect. For depth-only formats, the VkAttachmentDescriptionStencilLayout structure is
+ * ignored. For stencil-only formats, the initial and final layouts of the stencil aspect are taken
+ * from the VkAttachmentDescriptionStencilLayout structure if present, or initialLayout and
+ * finalLayout if not present."
+ *
+ * "If format is a depth/stencil format, and either initialLayout or finalLayout does not specify a
+ * layout for the stencil aspect, then the application must specify the initial and final layouts
+ * of the stencil aspect by including a VkAttachmentDescriptionStencilLayout structure in the pNext
+ * chain."
*/
static VkImageLayout
stencil_desc_layout(const VkAttachmentDescription2KHR *att_desc, bool final)
@@ -360,14 +366,12 @@ stencil_desc_layout(const VkAttachmentDescription2KHR *att_desc, bool final)
if (!util_format_has_stencil(desc))
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;
+ return final ? att_desc->finalLayout : att_desc->initialLayout;
}
VkResult
More information about the mesa-commit
mailing list