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 Change-Id: I0577bc8021b3598ddfdcea4af98aaef46e8a4519 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 9904686cf3e3fb59fa7839b2d16a6c78bb35bfa1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
36d2fb1f9f
commit
5403bfedc8
@ -1445,7 +1445,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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user