summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-12-01 18:42:38 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-12-01 18:42:38 +0000
commit97a72224ba1788ade4890b3f737f150b240610e1 (patch)
treed0dc4e3e2290ccd7368d97e49ba597b8dac19b80 /Graphics/GraphicsEngineD3D12
parentUpdated SetRenderTargets() in Vk backend to only transitin states. CommitRend... (diff)
downloadDiligentCore-97a72224ba1788ade4890b3f737f150b240610e1.tar.gz
DiligentCore-97a72224ba1788ade4890b3f737f150b240610e1.zip
Added explicit state transition mode to ClearRenderTarget() command
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/CommandContext.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/CommandContext.cpp20
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp4
4 files changed, 21 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.h b/Graphics/GraphicsEngineD3D12/include/CommandContext.h
index 9de975df..6b89ba2c 100644
--- a/Graphics/GraphicsEngineD3D12/include/CommandContext.h
+++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.h
@@ -174,7 +174,7 @@ protected:
class GraphicsContext : public CommandContext
{
public:
- void ClearRenderTarget( ITextureViewD3D12 *pRTV, const float *Color );
+ void ClearRenderTarget( ITextureViewD3D12 *pRTV, const float *Color, CLEAR_RENDER_TARGET_STATE_TRANSITION_MODE StateTransitionMode );
void ClearDepthStencil( ITextureViewD3D12 *pDSV, D3D12_CLEAR_FLAGS ClearFlags, float Depth, UINT8 Stencil );
void SetRootSignature( ID3D12RootSignature *pRootSig )
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
index 7eaebfcd..ce36f432 100644
--- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
@@ -91,7 +91,7 @@ public:
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, CLEAR_RENDER_TARGET_STATE_TRANSITION_MODE StateTransitionMode )override final;
virtual void Flush()override final;
diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
index a08fe172..992b6e3b 100644
--- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
@@ -191,11 +191,25 @@ void CommandContext::ClearUAVUint( ITextureViewD3D12* pTexView, const UINT* Colo
}
-void GraphicsContext::ClearRenderTarget( ITextureViewD3D12* pRTV, const float* Color )
+void GraphicsContext::ClearRenderTarget( ITextureViewD3D12* pRTV, const float* Color, CLEAR_RENDER_TARGET_STATE_TRANSITION_MODE StateTransitionMode )
{
auto *pTexture = ValidatedCast<TextureD3D12Impl>( pRTV->GetTexture() );
- if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_RENDER_TARGET))
- TransitionResource(pTexture, RESOURCE_STATE_RENDER_TARGET);
+ if (StateTransitionMode == CLEAR_RENDER_TARGET_TRANSITION_STATE)
+ {
+ if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_RENDER_TARGET))
+ TransitionResource(pTexture, RESOURCE_STATE_RENDER_TARGET);
+ }
+#ifdef DEVELOPMENT
+ else if (StateTransitionMode == CLEAR_RENDER_TARGET_VERIFY_STATE)
+ {
+ if (pTexture->IsInKnownState() && !pTexture->CheckState(RESOURCE_STATE_RENDER_TARGET))
+ {
+ LOG_ERROR_MESSAGE("Render target '", pTexture->GetDesc().Name, "' being cleared is not transitioned to RESOURCE_STATE_RENDER_TARGET state. "
+ "Actual texture state: ", GetResourceStateString(pTexture->GetState()), ". "
+ "Use CLEAR_RENDER_TARGET_TRANSITION_STATE mode or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method.");
+ }
+ }
+#endif
FlushResourceBarriers();
m_pCommandList->ClearRenderTargetView(pRTV->GetCPUDescriptorHandle(), Color, 0, nullptr);
}
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 01bc7e7a..3bd3a096 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -617,7 +617,7 @@ namespace Diligent
++m_State.NumCommands;
}
- void DeviceContextD3D12Impl::ClearRenderTarget( ITextureView* pView, const float* RGBA )
+ void DeviceContextD3D12Impl::ClearRenderTarget( ITextureView* pView, const float* RGBA, CLEAR_RENDER_TARGET_STATE_TRANSITION_MODE StateTransitionMode )
{
ITextureViewD3D12 *pd3d12RTV = nullptr;
if( pView != nullptr )
@@ -647,7 +647,7 @@ namespace Diligent
// The full extent of the resource view is always cleared.
// Viewport and scissor settings are not applied??
- GetCmdContext().AsGraphicsContext().ClearRenderTarget( pd3d12RTV, RGBA );
+ GetCmdContext().AsGraphicsContext().ClearRenderTarget( pd3d12RTV, RGBA, StateTransitionMode );
++m_State.NumCommands;
}