diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-08-02 01:18:48 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-08-02 19:21:45 +0000 |
| commit | 812fc38d1b0957ed96d93e023b7322d65c5d3f5d (patch) | |
| tree | 12e83148649718ae8dce97ff6ef027cdcb51551e /Graphics/GraphicsEngine | |
| parent | Fixed build error (diff) | |
| download | DiligentCore-812fc38d1b0957ed96d93e023b7322d65c5d3f5d.tar.gz DiligentCore-812fc38d1b0957ed96d93e023b7322d65c5d3f5d.zip | |
Updated EndRenderPass to optionally update resource states
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/DeviceContextBase.hpp | 20 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/DeviceContext.h | 9 |
2 files changed, 26 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index 9a9e5e89..68f9ec4e 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -130,7 +130,7 @@ public: virtual void DILIGENT_CALL_TYPE NextSubpass() override = 0; - virtual void DILIGENT_CALL_TYPE EndRenderPass() override = 0; + virtual void DILIGENT_CALL_TYPE EndRenderPass(bool UpdateResourceStates) override = 0; /// Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters. virtual void DILIGENT_CALL_TYPE UpdateBuffer(IBuffer* pBuffer, @@ -902,9 +902,25 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::NextSubpass( } template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::EndRenderPass() +inline void DeviceContextBase<BaseInterface, ImplementationTraits>::EndRenderPass(bool UpdateResourceStates) { VERIFY(m_pActiveRenderPass != nullptr, "There is no active render pass"); + VERIFY(m_pBoundFramebuffer != nullptr, "There is no active framebuffer"); + if (UpdateResourceStates) + { + const auto& RPDesc = m_pActiveRenderPass->GetDesc(); + const auto& FBDesc = m_pBoundFramebuffer->GetDesc(); + VERIFY(FBDesc.AttachmentCount >= RPDesc.AttachmentCount, + "Framebuffer attachment count (", FBDesc.AttachmentCount, ") is smaller than the render pass attachment count (", RPDesc.AttachmentCount, ")"); + for (Uint32 i = 0; i < RPDesc.AttachmentCount; ++i) + { + if (auto* pView = FBDesc.ppAttachments[i]) + { + auto* pTex = ValidatedCast<TextureImplType>(pView->GetTexture()); + pTex->SetState(RPDesc.pAttachments[i].FinalState); + } + } + } m_pActiveRenderPass.Release(); m_pBoundFramebuffer.Release(); m_SubpassIndex = 0; diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 5b52cec0..3445a8d6 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -905,7 +905,14 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject) /// Ends current render pass. - VIRTUAL void METHOD(EndRenderPass)(THIS) PURE; + + /// \param [in] UpdateResourceStates - Indicates whether to update resource states so that they match + /// the final states specified by the render pass attachments. + /// Note that resources are always transitioned to the final states. + /// The flag only indicates if the internal state variables should be + /// updated to match the actual final states. + VIRTUAL void METHOD(EndRenderPass)(THIS_ + bool UpdateResourceStates) PURE; /// Executes a draw command. |
