diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-08-09 02:13:00 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-08-09 02:13:00 +0000 |
| commit | c2a16b234fbd087e3f076895f9ce6873ef7b3e29 (patch) | |
| tree | 984f37a256e0a2d713ddc8175106151bfa6156ad /Graphics | |
| parent | D3D12 backend: fixed load op for depth-stencil attachments (diff) | |
| download | DiligentCore-c2a16b234fbd087e3f076895f9ce6873ef7b3e29.tar.gz DiligentCore-c2a16b234fbd087e3f076895f9ce6873ef7b3e29.zip | |
Vk backend: improved handling of RESOURCE_STATE_RESOLVE_DEST attachment state
Diffstat (limited to 'Graphics')
| -rw-r--r-- | Graphics/GraphicsEngine/include/RenderPassBase.hpp | 17 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp | 4 |
2 files changed, 19 insertions, 2 deletions
diff --git a/Graphics/GraphicsEngine/include/RenderPassBase.hpp b/Graphics/GraphicsEngine/include/RenderPassBase.hpp index 96b479e6..c2a6b5c1 100644 --- a/Graphics/GraphicsEngine/include/RenderPassBase.hpp +++ b/Graphics/GraphicsEngine/include/RenderPassBase.hpp @@ -42,6 +42,21 @@ namespace Diligent void ValidateRenderPassDesc(const RenderPassDesc& Desc); +template <typename RenderDeviceImplType> +void _CorrectAttachmentState(RESOURCE_STATE& State) {} + +template <> +inline void _CorrectAttachmentState<class RenderDeviceVkImpl>(RESOURCE_STATE& State) +{ + if (State == RESOURCE_STATE_RESOLVE_DEST) + { + // In Vulkan resolve attachments must be in VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL state. + // It is important to correct the state because outside of render pass RESOURCE_STATE_RESOLVE_DEST maps + // to VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL. + State = RESOURCE_STATE_RENDER_TARGET; + } +} + /// Template class implementing base functionality for the render pass object. /// \tparam BaseInterface - base interface that this class will inheret @@ -76,6 +91,7 @@ public: for (Uint32 i = 0; i < Desc.AttachmentCount; ++i) { pAttachments[i] = Desc.pAttachments[i]; + _CorrectAttachmentState<RenderDeviceImplType>(pAttachments[i].FinalState); } } @@ -150,6 +166,7 @@ public: for (Uint32 rslv_attachment = 0; rslv_attachment < SrcSubpass.RenderTargetAttachmentCount; ++rslv_attachment, ++pCurrAttachmentRef) { *pCurrAttachmentRef = SrcSubpass.pResolveAttachments[rslv_attachment]; + _CorrectAttachmentState<RenderDeviceImplType>(pCurrAttachmentRef->State); UpdateAttachmentStateAndFirstUseSubpass(*pCurrAttachmentRef); } } diff --git a/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp index 8858fb50..c010e460 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp @@ -58,8 +58,8 @@ RenderPassVkImpl::RenderPassVkImpl(IReferenceCounters* pRefCounters, vkAttachment.storeOp = AttachmentStoreOpToVkAttachmentStoreOp(Attachment.StoreOp); vkAttachment.stencilLoadOp = AttachmentLoadOpToVkAttachmentLoadOp(Attachment.StencilLoadOp); vkAttachment.stencilStoreOp = AttachmentStoreOpToVkAttachmentStoreOp(Attachment.StencilStoreOp); - vkAttachment.initialLayout = ResourceStateToVkImageLayout(Attachment.InitialState); - vkAttachment.finalLayout = ResourceStateToVkImageLayout(Attachment.FinalState); + vkAttachment.initialLayout = ResourceStateToVkImageLayout(Attachment.InitialState, /*IsInsideRenderPass = */ false); + vkAttachment.finalLayout = ResourceStateToVkImageLayout(Attachment.FinalState, /*IsInsideRenderPass = */ true); } RenderPassCI.attachmentCount = Desc.AttachmentCount; RenderPassCI.pAttachments = vkAttachments.data(); |
