From 1303ae5da64c35a56768edecdf60d57f7a2fe628 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 30 Nov 2018 20:20:46 -0800 Subject: Added explicit state transition flags to SetRenderTargets method --- .../GraphicsEngine/include/DeviceContextBase.h | 5 +- Graphics/GraphicsEngine/interface/DeviceContext.h | 28 ++++++++++- .../include/DeviceContextD3D11Impl.h | 21 ++++++-- .../src/DeviceContextD3D11Impl.cpp | 44 +++++++++++++--- .../src/RenderDeviceFactoryD3D11.cpp | 2 +- .../GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp | 2 +- .../GraphicsEngineD3D12/include/CommandContext.h | 2 +- .../include/DeviceContextD3D12Impl.h | 47 +++++++++++------- .../GraphicsEngineD3D12/src/CommandContext.cpp | 40 +++++++++++++-- .../src/DeviceContextD3D12Impl.cpp | 10 ++-- .../src/RenderDeviceFactoryD3D12.cpp | 2 +- .../GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 2 +- .../include/DeviceContextGLImpl.h | 2 +- .../src/DeviceContextGLImpl.cpp | 2 +- .../src/RenderDeviceFactoryOpenGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 2 +- .../GraphicsEngineOpenGL/src/TexRegionRender.cpp | 2 +- .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 2 +- .../include/DeviceContextVkImpl.h | 21 ++++++-- .../src/DeviceContextVkImpl.cpp | 58 ++++++++++++++++------ .../src/RenderDeviceFactoryVk.cpp | 2 +- .../GraphicsEngineVulkan/src/SwapChainVkImpl.cpp | 4 +- 22 files changed, 224 insertions(+), 78 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 293e438c..0bbdd843 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -107,7 +107,7 @@ public: /// Caches the render target and depth stencil views. Returns true if any view is different /// from the cached value and false otherwise. - inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, Uint32 Dummy = 0 ); + inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil); /// Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters. virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override = 0; @@ -462,7 +462,8 @@ inline void DeviceContextBase -inline bool DeviceContextBase :: SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, Uint32 Dummy ) +inline bool DeviceContextBase :: + SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil ) { bool bBindRenderTargets = false; m_FramebufferWidth = 0; diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 70088d2a..236d5e51 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -269,6 +269,31 @@ enum COMMIT_SHADER_RESOURCES_FLAGS : Uint8 }; DEFINE_FLAG_ENUM_OPERATORS(COMMIT_SHADER_RESOURCES_FLAGS) +/// Additional flags for IDeviceContext::SetRenderTargets() command that define +/// which resources need to be transitioned by the command. +enum SET_RENDER_TARGETS_FLAGS +{ + /// Perform no state transitions + SET_RENDER_TARGETS_FLAG_NONE = 0x00, + + /// Transition color targets to Diligent::RESOURCE_STATE_RENDER_TARGET state (see Diligent::RESOURCE_STATE). + /// Textures in unknown state will not be transitioned. + SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR = 0x01, + + /// Transition depth buffer to Diligent::RESOURCE_STATE_DEPTH_WRITE state (see Diligent::RESOURCE_STATE). + /// If the texture is in unknown state, the flag will have no effect. + SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH = 0x02, + + /// Transition all color targets and depth buffer + SET_RENDER_TARGETS_FLAG_TRANSITION_ALL = (SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR | SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH), + + /// Verify the state of color/depth targets not being transitioned. This flag + /// only has effect in debug and development builds. No validation is performed + /// in release build and the flag is ignored. + SET_RENDER_TARGETS_FLAG_VERIFY_STATES = 0x04 +}; +DEFINE_FLAG_ENUM_OPERATORS(SET_RENDER_TARGETS_FLAGS) + /// Describes the viewport. @@ -516,6 +541,7 @@ public: /// \param [in] pDepthStencil - Pointer to the ITextureView that represents the depth stencil to /// bind to the device. The view type must be /// Diligent::TEXTURE_VIEW_DEPTH_STENCIL. + /// \param [in] Flags - Flags defining required resource transitions. /// \remarks /// The device context will keep strong references to all bound render target /// and depth-stencil views. Thus these views (and consequently referenced textures) @@ -525,7 +551,7 @@ public: /// following call: /// /// pContext->SetRenderTargets(0, nullptr, nullptr); - virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil) = 0; + virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags) = 0; /// Executes a draw command diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index 08bdd7a0..8153a6e3 100755 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -64,7 +64,11 @@ public: virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers(Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer** ppBuffers, Uint32* pOffsets, SET_VERTEX_BUFFERS_FLAGS Flags)override final; + virtual void SetVertexBuffers(Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + SET_VERTEX_BUFFERS_FLAGS Flags)override final; virtual void InvalidateState()override final; @@ -74,7 +78,10 @@ public: virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight)override final; - virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil)override final; + virtual void SetRenderTargets(Uint32 NumRenderTargets, + ITextureView* ppRenderTargets[], + ITextureView* pDepthStencil, + SET_RENDER_TARGETS_FLAGS Flags)override final; virtual void Draw(DrawAttribs& DrawAttribs)override final; @@ -86,15 +93,19 @@ public: virtual void Flush()override final; - virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; + virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; - virtual void CopyBuffer(IBuffer *pSrcBuffer, Uint32 SrcOffset, IBuffer *pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; + virtual void CopyBuffer(IBuffer* pSrcBuffer, Uint32 SrcOffset, IBuffer* pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final; virtual void UnmapBuffer(IBuffer* pBuffer)override final; - virtual void UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData)override final; + virtual void UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData)override final; virtual void CopyTexture(ITexture* pSrcTexture, Uint32 SrcMipLevel, diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index c07912e3..17102bff 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1507,27 +1507,55 @@ namespace Diligent m_pd3d11DeviceContext->OMSetRenderTargets(0, nullptr, nullptr); } - void DeviceContextD3D11Impl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil ) + void DeviceContextD3D11Impl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags ) { - if (TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil )) + if (TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil)) { for (Uint32 RT = 0; RT < NumRenderTargets; ++RT) { if (ppRenderTargets[RT]) { auto* pTex = ValidatedCast(ppRenderTargets[RT]->GetTexture()); - UnbindTextureFromInput( pTex, pTex->GetD3D11Texture() ); - if (pTex->IsInKnownState()) - pTex->SetState(RESOURCE_STATE_RENDER_TARGET); + if (Flags & SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR) + { + UnbindTextureFromInput( pTex, pTex->GetD3D11Texture() ); + if (pTex->IsInKnownState()) + pTex->SetState(RESOURCE_STATE_RENDER_TARGET); + } +#ifdef DEVELOPMENT + else if (Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) + { + if (pTex->IsInKnownState() && !pTex->CheckState(RESOURCE_STATE_RENDER_TARGET)) + { + LOG_ERROR_MESSAGE("Texture '", pTex->GetDesc().Name, "' being set as render target at slot ", RT, " is not transitioned to RESOURCE_STATE_RENDER_TARGET state. " + "Actual texture state: ", GetResourceStateString(pTex->GetState()), ". " + "Use SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); + } + } +#endif } } if (pDepthStencil) { auto* pTex = ValidatedCast(pDepthStencil->GetTexture()); - UnbindTextureFromInput( pTex, pTex->GetD3D11Texture() ); - if (pTex->IsInKnownState()) - pTex->SetState(RESOURCE_STATE_DEPTH_WRITE); + if (Flags & SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH) + { + UnbindTextureFromInput( pTex, pTex->GetD3D11Texture() ); + if (pTex->IsInKnownState()) + pTex->SetState(RESOURCE_STATE_DEPTH_WRITE); + } +#ifdef DEVELOPMENT + else if(Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) + { + if (pTex->IsInKnownState() && !pTex->CheckState(RESOURCE_STATE_DEPTH_WRITE)) + { + LOG_ERROR_MESSAGE("Texture '", pTex->GetDesc().Name, "' being set as depth-stencil buffer is not transitioned to RESOURCE_STATE_DEPTH_WRITE state. " + "Actual texture state: ", GetResourceStateString(pTex->GetState()), ". " + "Use SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); + } + } +#endif } CommitRenderTargets(); diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp index eb8558c2..ca7c9e9e 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp @@ -324,7 +324,7 @@ void EngineFactoryD3D11Impl::CreateSwapChainD3D11( IRenderDevice* pDe pDeviceContextD3D11->SetSwapChain(pSwapChainD3D11); // Bind default render target - pDeviceContextD3D11->SetRenderTargets( 0, nullptr, nullptr ); + pDeviceContextD3D11->SetRenderTargets( 0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); // Set default viewport pDeviceContextD3D11->SetViewports( 1, nullptr, 0, 0 ); diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp index cb25af84..20379c42 100644 --- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp @@ -182,7 +182,7 @@ void SwapChainD3D11Impl::UpdateSwapChain(bool CreateNew) if (bIsDefaultFBBound) { // Set default render target and viewport - pImmediateCtxD3D11->SetRenderTargets(0, nullptr, nullptr); + pImmediateCtxD3D11->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); pImmediateCtxD3D11->SetViewports(1, nullptr, 0, 0); } } diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.h b/Graphics/GraphicsEngineD3D12/include/CommandContext.h index 46dbc9fe..9de975df 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandContext.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.h @@ -185,7 +185,7 @@ public: } } - void SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs, ITextureViewD3D12* pDSV ); + void SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs, ITextureViewD3D12* pDSV, SET_RENDER_TARGETS_FLAGS Flags ); void SetViewports( UINT NumVPs, const D3D12_VIEWPORT* pVPs ) { diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index 142ca7cb..7eaebfcd 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -56,47 +56,58 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; - virtual void SetPipelineState(IPipelineState *pPipelineState)override final; + virtual void SetPipelineState(IPipelineState* pPipelineState)override final; - virtual void TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding)override final; + virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding)override final; - virtual void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, COMMIT_SHADER_RESOURCES_FLAGS Flags)override final; + virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, COMMIT_SHADER_RESOURCES_FLAGS Flags)override final; virtual void SetStencilRef(Uint32 StencilRef)override final; virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, SET_VERTEX_BUFFERS_FLAGS Flags )override final; + virtual void SetVertexBuffers( Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + SET_VERTEX_BUFFERS_FLAGS Flags )override final; virtual void InvalidateState()override final; - virtual void SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset )override final; + virtual void SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset )override final; - virtual void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight )override final; + virtual void SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight )override final; - virtual void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight )override final; + virtual void SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight )override final; - virtual void SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil )override final; + virtual void SetRenderTargets( Uint32 NumRenderTargets, + ITextureView* ppRenderTargets[], + ITextureView* pDepthStencil, + SET_RENDER_TARGETS_FLAGS Flags )override final; - virtual void Draw( DrawAttribs &DrawAttribs )override final; + virtual void Draw( DrawAttribs& DrawAttribs )override final; - virtual void DispatchCompute( const DispatchComputeAttribs &DispatchAttrs )override final; + virtual void DispatchCompute( const DispatchComputeAttribs& DispatchAttrs )override final; - virtual void ClearDepthStencil( ITextureView *pView, CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, float fDepth, Uint8 Stencil)override final; + virtual void ClearDepthStencil( ITextureView* pView, CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, float fDepth, Uint8 Stencil)override final; - virtual void ClearRenderTarget( ITextureView *pView, const float *RGBA )override final; + virtual void ClearRenderTarget( ITextureView* pView, const float* RGBA )override final; virtual void Flush()override final; - virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; + virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; - virtual void CopyBuffer(IBuffer *pSrcBuffer, Uint32 SrcOffset, IBuffer *pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; + virtual void CopyBuffer(IBuffer* pSrcBuffer, Uint32 SrcOffset, IBuffer* pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final; virtual void UnmapBuffer(IBuffer* pBuffer)override final; - virtual void UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData)override final; + virtual void UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData)override final; virtual void CopyTexture(ITexture* pSrcTexture, Uint32 SrcMipLevel, @@ -123,9 +134,9 @@ public: virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final; - virtual void FinishCommandList(class ICommandList **ppCommandList)override final; + virtual void FinishCommandList(class ICommandList** ppCommandList)override final; - virtual void ExecuteCommandList(class ICommandList *pCommandList)override final; + virtual void ExecuteCommandList(class ICommandList* pCommandList)override final; virtual void SignalFence(IFence* pFence, Uint64 Value)override final; @@ -176,7 +187,7 @@ private: void CommitD3D12IndexBuffer(VALUE_TYPE IndexType, bool TransitionBuffer, bool VerifyState); void CommitD3D12VertexBuffers(class GraphicsContext &GraphCtx, bool TransitionBuffers, bool VerifyStates); void TransitionD3D12VertexBuffers(class GraphicsContext &GraphCtx); - void CommitRenderTargets(); + void CommitRenderTargets(SET_RENDER_TARGETS_FLAGS Flags); void CommitViewports(); void CommitScissorRects(class GraphicsContext &GraphCtx, bool ScissorEnable); void Flush(bool RequestNewCmdCtx); diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp index 8d6d5d9c..a08fe172 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp @@ -91,7 +91,7 @@ ID3D12GraphicsCommandList* CommandContext::Close(CComPtr return m_pCommandList; } -void GraphicsContext::SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs, ITextureViewD3D12* pDSV ) +void GraphicsContext::SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs, ITextureViewD3D12* pDSV, SET_RENDER_TARGETS_FLAGS Flags ) { D3D12_CPU_DESCRIPTOR_HANDLE RTVHandles[8]; // Do not waste time initializing array to zero @@ -101,8 +101,23 @@ void GraphicsContext::SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs if( pRTV ) { auto* pTexture = ValidatedCast( pRTV->GetTexture() ); - if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_RENDER_TARGET)) - TransitionResource(pTexture, RESOURCE_STATE_RENDER_TARGET); + if (Flags & SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR) + { + if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_RENDER_TARGET)) + TransitionResource(pTexture, RESOURCE_STATE_RENDER_TARGET); + } +#ifdef DEVELOPMENT + else if (Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) + { + if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_RENDER_TARGET)) + { + LOG_ERROR_MESSAGE("Texture '", pTexture->GetDesc().Name, "' being set as render target at slot ", i, " is not transitioned to RESOURCE_STATE_RENDER_TARGET state. " + "Actual texture state: ", GetResourceStateString(pTexture->GetState()), ". " + "Use SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); + } + } +#endif + RTVHandles[i] = pRTV->GetCPUDescriptorHandle(); VERIFY_EXPR(RTVHandles[i].ptr != 0); } @@ -118,8 +133,23 @@ void GraphicsContext::SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs //} //else { - if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_DEPTH_WRITE)) - TransitionResource(pTexture, RESOURCE_STATE_DEPTH_WRITE); + if (Flags & SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH) + { + if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_DEPTH_WRITE)) + TransitionResource(pTexture, RESOURCE_STATE_DEPTH_WRITE); + } +#ifdef DEVELOPMENT + else if (Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) + { + if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_DEPTH_WRITE)) + { + LOG_ERROR_MESSAGE("Texture '", pTexture->GetDesc().Name, "' being set as depth-stencil buffer is not transitioned to RESOURCE_STATE_DEPTH_WRITE state. " + "Actual texture state: ", GetResourceStateString(pTexture->GetState()), ". " + "Use SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); + } + + } +#endif auto DSVHandle = pDSV->GetCPUDescriptorHandle(); VERIFY_EXPR(DSVHandle.ptr != 0); m_pCommandList->OMSetRenderTargets( NumRTVs, RTVHandles, FALSE, &DSVHandle ); diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index f37691ac..01bc7e7a 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -211,7 +211,7 @@ namespace Diligent { GraphicsCtx.SetStencilRef(m_StencilRef); GraphicsCtx.SetBlendFactor(m_BlendFactors); - CommitRenderTargets(); + CommitRenderTargets(SET_RENDER_TARGETS_FLAG_VERIFY_STATES); CommitViewports(); } @@ -846,7 +846,7 @@ namespace Diligent } - void DeviceContextD3D12Impl::CommitRenderTargets() + void DeviceContextD3D12Impl::CommitRenderTargets(SET_RENDER_TARGETS_FLAGS Flags) { const Uint32 MaxD3D12RTs = D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; Uint32 NumRenderTargets = m_NumBoundRenderTargets; @@ -876,14 +876,14 @@ namespace Diligent ppRTVs[rt] = m_pBoundRenderTargets[rt].RawPtr(); pDSV = m_pBoundDepthStencil.RawPtr(); } - GetCmdContext().AsGraphicsContext().SetRenderTargets(NumRenderTargets, ppRTVs, pDSV); + GetCmdContext().AsGraphicsContext().SetRenderTargets(NumRenderTargets, ppRTVs, pDSV, Flags); } - void DeviceContextD3D12Impl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil ) + void DeviceContextD3D12Impl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags ) { if( TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil ) ) { - CommitRenderTargets(); + CommitRenderTargets(Flags); // Set the viewport to match the render target size SetViewports(1, nullptr, 0, 0); diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp index c79679fc..88681445 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp @@ -381,7 +381,7 @@ void EngineFactoryD3D12Impl::CreateSwapChainD3D12( IRenderDevice* pDe pDeviceContextD3D12->SetSwapChain(pSwapChainD3D12); // Bind default render target - pDeviceContextD3D12->SetRenderTargets( 0, nullptr, nullptr ); + pDeviceContextD3D12->SetRenderTargets( 0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); // Set default viewport pDeviceContextD3D12->SetViewports( 1, nullptr, 0, 0 ); diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 610b560d..18ef3043 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -199,7 +199,7 @@ void SwapChainD3D12Impl::UpdateSwapChain(bool CreateNew) if (bIsDefaultFBBound) { // Set default render target and viewport - pDeviceContext->SetRenderTargets(0, nullptr, nullptr); + pDeviceContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); pDeviceContext->SetViewports(1, nullptr, 0, 0); } } diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h index fe4afb36..abd57cfa 100644 --- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h @@ -66,7 +66,7 @@ public: virtual void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight )override final; - virtual void SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil )override final; + virtual void SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags )override final; virtual void Draw( DrawAttribs &DrawAttribs )override final; diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index 872e9f0f..70041b20 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -329,7 +329,7 @@ namespace Diligent SetViewports(1, nullptr, 0, 0); } - void DeviceContextGLImpl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil ) + void DeviceContextGLImpl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags ) { if( TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil ) ) CommitRenderTargets(); diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp index cc959951..ea53ee57 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp @@ -128,7 +128,7 @@ void EngineFactoryOpenGLImpl::CreateDeviceAndSwapChainGL(const EngineGLAttribs& pDeviceContextOpenGL->SetSwapChain(pSwapChainGL); // Bind default framebuffer and viewport - pDeviceContextOpenGL->SetRenderTargets( 0, nullptr, nullptr ); + pDeviceContextOpenGL->SetRenderTargets( 0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); pDeviceContextOpenGL->SetViewports( 1, nullptr, 0, 0 ); } catch( const std::runtime_error & ) diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index e58bcd89..2d46e3c0 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -105,7 +105,7 @@ void SwapChainGLImpl::Resize( Uint32 NewWidth, Uint32 NewHeight ) if( bIsDefaultFBBound ) { // Update framebuffer size and viewport - pImmediateCtxGL->SetRenderTargets(0, nullptr, nullptr); + pImmediateCtxGL->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); pImmediateCtxGL->SetViewports( 1, nullptr, 0, 0 ); } } diff --git a/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp b/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp index 92ea6703..4670873c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp @@ -162,7 +162,7 @@ namespace Diligent void TexRegionRender::RestoreStates( DeviceContextGLImpl *pCtxGL ) { - pCtxGL->SetRenderTargets( m_NumRenderTargets, m_pOrigRTVs, m_pOrigDSV ); + pCtxGL->SetRenderTargets( m_NumRenderTargets, m_pOrigRTVs, m_pOrigDSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); for( Uint32 rt = 0; rt < _countof( m_pOrigRTVs ); ++rt ) { if( m_pOrigRTVs[rt] ) diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 29ccab1a..2ccd76bf 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -468,7 +468,7 @@ void TextureBaseGL :: CopyData(DeviceContextGLImpl *pDeviceCtxGL, ); ITextureView *pRTVs[] = { &RTV }; - pDeviceCtxGL->SetRenderTargets( _countof( pRTVs ), pRTVs, nullptr ); + pDeviceCtxGL->SetRenderTargets( _countof( pRTVs ), pRTVs, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); // No need to set up the viewport as SetRenderTargets() does that diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 8678f2af..8dd9b730 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -73,7 +73,11 @@ public: virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32* pOffsets, SET_VERTEX_BUFFERS_FLAGS Flags )override final; + virtual void SetVertexBuffers( Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + SET_VERTEX_BUFFERS_FLAGS Flags )override final; virtual void InvalidateState()override final; @@ -83,7 +87,10 @@ public: virtual void SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight )override final; - virtual void SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil )override final; + virtual void SetRenderTargets( Uint32 NumRenderTargets, + ITextureView* ppRenderTargets[], + ITextureView* pDepthStencil, + SET_RENDER_TARGETS_FLAGS Flags )override final; virtual void Draw( DrawAttribs &DrawAttribs )override final; @@ -97,13 +104,17 @@ public: virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; - virtual void CopyBuffer(IBuffer *pSrcBuffer, Uint32 SrcOffset, IBuffer *pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; + virtual void CopyBuffer(IBuffer* pSrcBuffer, Uint32 SrcOffset, IBuffer* pDstBuffer, Uint32 DstOffset, Uint32 Size)override final; virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final; virtual void UnmapBuffer(IBuffer* pBuffer)override final; - virtual void UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData)override final; + virtual void UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData)override final; virtual void CopyTexture(ITexture* pSrcTexture, Uint32 SrcMipLevel, @@ -213,7 +224,7 @@ public: Int64 GetContextFrameNumber()const{return m_ContextFrameNumber;} private: - void CommitRenderPassAndFramebuffer(); + void CommitRenderPassAndFramebuffer(SET_RENDER_TARGETS_FLAGS Flags); void CommitVkVertexBuffers(bool TransitionBuffers, bool VerifyStates); void TransitionVkVertexBuffers(); void CommitViewports(); diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index b594aa35..d758f321 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -242,7 +242,7 @@ namespace Diligent { m_CommandBuffer.SetStencilReference(m_StencilRef); m_CommandBuffer.SetBlendConstants(m_BlendFactors); - CommitRenderPassAndFramebuffer(); + CommitRenderPassAndFramebuffer(SET_RENDER_TARGETS_FLAG_VERIFY_STATES); CommitViewports(); } @@ -540,7 +540,7 @@ namespace Diligent } #endif - CommitRenderPassAndFramebuffer(); + CommitRenderPassAndFramebuffer(SET_RENDER_TARGETS_FLAG_VERIFY_STATES); if (pIndirectDrawAttribsVk != nullptr) { @@ -673,7 +673,7 @@ namespace Diligent { // Render pass may not be currently committed VERIFY_EXPR(m_RenderPass != VK_NULL_HANDLE && m_Framebuffer != VK_NULL_HANDLE); - CommitRenderPassAndFramebuffer(); + CommitRenderPassAndFramebuffer(SET_RENDER_TARGETS_FLAG_VERIFY_STATES); VkClearAttachment ClearAttachment = {}; ClearAttachment.aspectMask = 0; @@ -808,7 +808,7 @@ namespace Diligent { // Render pass may not be currently committed VERIFY_EXPR(m_RenderPass != VK_NULL_HANDLE && m_Framebuffer != VK_NULL_HANDLE); - CommitRenderPassAndFramebuffer(); + CommitRenderPassAndFramebuffer(SET_RENDER_TARGETS_FLAG_VERIFY_STATES); VkClearAttachment ClearAttachment = {}; ClearAttachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1084,7 +1084,7 @@ namespace Diligent } - void DeviceContextVkImpl::CommitRenderPassAndFramebuffer() + void DeviceContextVkImpl::CommitRenderPassAndFramebuffer(SET_RENDER_TARGETS_FLAGS Flags) { const auto& CmdBufferState = m_CommandBuffer.GetState(); if (CmdBufferState.Framebuffer != m_Framebuffer) @@ -1099,14 +1099,28 @@ namespace Diligent { auto* pDSVVk = m_pBoundDepthStencil.RawPtr(); auto* pDepthBufferVk = ValidatedCast(pDSVVk->GetTexture()); - if (pDepthBufferVk->IsInKnownState()) + if (Flags & SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH) { - if (!pDepthBufferVk->CheckState(RESOURCE_STATE_DEPTH_WRITE)) + if (pDepthBufferVk->IsInKnownState()) { - TransitionTextureState(*pDepthBufferVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_DEPTH_WRITE, true); + if (!pDepthBufferVk->CheckState(RESOURCE_STATE_DEPTH_WRITE)) + { + TransitionTextureState(*pDepthBufferVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_DEPTH_WRITE, true); + } + VERIFY_EXPR(pDepthBufferVk->GetLayout() == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); + } + } +#ifdef DEVELOPMENT + else if (Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) + { + if (pDepthBufferVk->IsInKnownState() && !pDepthBufferVk->CheckState(RESOURCE_STATE_DEPTH_WRITE)) + { + LOG_ERROR_MESSAGE("Texture '", pDepthBufferVk->GetDesc().Name, "' being set as depth-stencil buffer is not transitioned to RESOURCE_STATE_DEPTH_WRITE state. " + "Actual texture state: ", GetResourceStateString(pDepthBufferVk->GetState()), ". " + "Use SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); } - VERIFY_EXPR(pDepthBufferVk->GetLayout() == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); } +#endif } for (Uint32 rt=0; rt < m_NumBoundRenderTargets; ++rt) @@ -1115,14 +1129,28 @@ namespace Diligent { auto* pRTVVk = ValidatedCast(pRTV); auto* pRenderTargetVk = ValidatedCast(pRTVVk->GetTexture()); - if (pRenderTargetVk->IsInKnownState()) + if (Flags & SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR) { - if (!pRenderTargetVk->CheckState(RESOURCE_STATE_RENDER_TARGET)) + if (pRenderTargetVk->IsInKnownState()) { - TransitionTextureState(*pRenderTargetVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_RENDER_TARGET, true); + if (!pRenderTargetVk->CheckState(RESOURCE_STATE_RENDER_TARGET)) + { + TransitionTextureState(*pRenderTargetVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_RENDER_TARGET, true); + } + VERIFY_EXPR(pRenderTargetVk->GetLayout() == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); } - VERIFY_EXPR(pRenderTargetVk->GetLayout() == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); } +#ifdef DEVELOPMENT + else if (Flags & SET_RENDER_TARGETS_FLAG_VERIFY_STATES) + { + if (pRenderTargetVk->IsInKnownState() && !pRenderTargetVk->CheckState(RESOURCE_STATE_RENDER_TARGET)) + { + LOG_ERROR_MESSAGE("Texture '", pRenderTargetVk->GetDesc().Name, "' being set as render target at slot ", rt, " is not transitioned to RESOURCE_STATE_RENDER_TARGET state. " + "Actual texture state: ", GetResourceStateString(pRenderTargetVk->GetState()), ". " + "Use SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); + } + } +#endif } } m_CommandBuffer.BeginRenderPass(m_RenderPass, m_Framebuffer, m_FramebufferWidth, m_FramebufferHeight); @@ -1130,7 +1158,7 @@ namespace Diligent } } - void DeviceContextVkImpl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil ) + void DeviceContextVkImpl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags ) { if ( TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil ) ) { @@ -1187,7 +1215,7 @@ namespace Diligent } EnsureVkCmdBuffer(); - CommitRenderPassAndFramebuffer(); + CommitRenderPassAndFramebuffer(Flags); } void DeviceContextVkImpl::ResetRenderTargets() diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp index 7445df91..654e6bb1 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp @@ -315,7 +315,7 @@ void EngineFactoryVkImpl::CreateSwapChainVk( IRenderDevice* pDevice, pDeviceContextVk->SetSwapChain(pSwapChainVk); // Bind default render target - pDeviceContextVk->SetRenderTargets( 0, nullptr, nullptr ); + pDeviceContextVk->SetRenderTargets( 0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); // Set default viewport pDeviceContextVk->SetViewports( 1, nullptr, 0, 0 ); diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index 9a5bed10..5cdb4f4c 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -499,7 +499,7 @@ void SwapChainVkImpl::Present(Uint32 SyncInterval) { // If default framebuffer is bound, we need to call SetRenderTargets() // to bind new back buffer RTV - pImmediateCtxVk->SetRenderTargets(0, nullptr, nullptr); + pImmediateCtxVk->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); } } } @@ -551,7 +551,7 @@ void SwapChainVkImpl::Resize( Uint32 NewWidth, Uint32 NewHeight ) if( bIsDefaultFBBound ) { // Set default render target and viewport - pDeviceContext->SetRenderTargets( 0, nullptr, nullptr ); + pDeviceContext->SetRenderTargets( 0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL ); pDeviceContext->SetViewports( 1, nullptr, 0, 0 ); } } -- cgit v1.2.3