diff options
author | Aurélien Brooke <aurelien@bahiasoft.fr> | 2024-02-21 18:07:27 +0100 |
---|---|---|
committer | Aurélien Brooke <aurelien@bahiasoft.fr> | 2024-02-23 17:32:43 +0100 |
commit | 9904686cf3e3fb59fa7839b2d16a6c78bb35bfa1 (patch) | |
tree | 3e211b289f22404abec0c94accc42ee5770ad1fe | |
parent | 46366a14a41ec6db5ab4ab72c473a4a4e187d484 (diff) |
RHI: fix Vulkan layout for PreserveDepthStencilContents depth textures
Vulkan fails when we attach a depth texture to a render target with
QRhiTextureRenderTarget::PreserveDepthStencilContents (we want to reuse
the depth data from a depth pre-pass.)
vkCreateRenderPass(): pCreateInfo->pAttachments[3] format is
VK_FORMAT_D32_SFLOAT and loadOp is VK_ATTACHMENT_LOAD_OP_LOAD, but
initialLayout is VK_IMAGE_LAYOUT_UNDEFINED.
The Vulkan spec states: If format includes a color or depth component
and loadOp is VK_ATTACHMENT_LOAD_OP_LOAD, then initialLayout must not be
VK_IMAGE_LAYOUT_UNDEFINED (https://www.khronos.org/registry/vulkan/
specs/1.3-extensions/html/vkspec.html#VUID-VkAttachmentDescription-
format-06699)
To fix this, just do the same as color attachments: specify a
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL instead of
VK_IMAGE_LAYOUT_UNDEFINED when the depth-stencil is preserved.
[ChangeLog][RHI] QRhiTextureRenderTarget::PreserveDepthStencilContents
now works properly on Vulkan
Pick-to: 6.7
Change-Id: I0577bc8021b3598ddfdcea4af98aaef46e8a4519
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 111fefe7a9..4d7b361f80 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1494,7 +1494,7 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, attDesc.storeOp = storeOp; attDesc.stencilLoadOp = loadOp; attDesc.stencilStoreOp = storeOp; - attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.initialLayout = preserveDs ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; rpD->attDescs.append(attDesc); } |