diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-12-01 04:20:46 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-12-01 04:20:46 +0000 |
| commit | 1303ae5da64c35a56768edecdf60d57f7a2fe628 (patch) | |
| tree | b240850db3f521a636bdd71435a9aafda99a89c5 /Graphics/GraphicsEngineD3D11 | |
| parent | Improved type safety of different flag types (diff) | |
| download | DiligentCore-1303ae5da64c35a56768edecdf60d57f7a2fe628.tar.gz DiligentCore-1303ae5da64c35a56768edecdf60d57f7a2fe628.zip | |
Added explicit state transition flags to SetRenderTargets method
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
4 files changed, 54 insertions, 15 deletions
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<TextureBaseD3D11>(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<TextureBaseD3D11>(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); } } |
