summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-08-26 22:57:45 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-08-26 22:57:45 +0000
commit9ae620ef8cb2e876af331c3c330d42f68ba2f76e (patch)
tree4778f18d3fd95faea1de4a1873444fb022ae2e6e /Graphics/GraphicsEngineD3D12
parentUpdated readme (diff)
downloadDiligentCore-9ae620ef8cb2e876af331c3c330d42f68ba2f76e.tar.gz
DiligentCore-9ae620ef8cb2e876af331c3c330d42f68ba2f76e.zip
Added draw/dispatch command argument validation
Removed DrawAttribs::IsIndirect
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp54
1 files changed, 18 insertions, 36 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 5f951a66..66477281 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -304,25 +304,17 @@ namespace Diligent
m_bCommittedD3D12VBsUpToDate = !DynamicBufferPresent;
}
- void DeviceContextD3D12Impl::Draw( DrawAttribs& DrawAttribs )
+ void DeviceContextD3D12Impl::Draw( DrawAttribs& drawAttribs )
{
-#ifdef _DEBUG
- if (!m_pPipelineState)
- {
- LOG_ERROR("No pipeline state is bound");
- return;
- }
- if (m_pPipelineState->GetDesc().IsComputePipeline)
- {
- LOG_ERROR("No graphics pipeline state is bound");
+#ifdef DEVELOPMENT
+ if (!DvpVerifyDrawArguments(drawAttribs))
return;
- }
#endif
auto &GraphCtx = RequestCmdContext()->AsGraphicsContext();
- if( DrawAttribs.IsIndexed )
+ if( drawAttribs.IsIndexed )
{
- if( m_CommittedIBFormat != DrawAttribs.IndexType )
+ if( m_CommittedIBFormat != drawAttribs.IndexType )
m_bCommittedD3D12IBUpToDate = false;
if(m_bCommittedD3D12IBUpToDate)
@@ -332,7 +324,7 @@ namespace Diligent
GraphCtx.TransitionResource(pBuffD3D12, D3D12_RESOURCE_STATE_INDEX_BUFFER, true);
}
else
- CommitD3D12IndexBuffer(DrawAttribs.IndexType);
+ CommitD3D12IndexBuffer(drawAttribs.IndexType);
}
if(m_bCommittedD3D12VBsUpToDate)
@@ -355,44 +347,34 @@ namespace Diligent
#endif
- if( DrawAttribs.IsIndirect )
+ auto *pIndirectDrawAttribsD3D12 = ValidatedCast<BufferD3D12Impl>(drawAttribs.pIndirectDrawAttribs);
+ if (pIndirectDrawAttribsD3D12 != nullptr)
{
- VERIFY(DrawAttribs.pIndirectDrawAttribs != nullptr, "Valid pIndirectDrawAttribs must be provided for indirect draw command");
- auto *pBufferD3D12 = ValidatedCast<BufferD3D12Impl>(DrawAttribs.pIndirectDrawAttribs);
-
#ifdef DEVELOPMENT
- if(pBufferD3D12->GetDesc().Usage == USAGE_DYNAMIC)
- pBufferD3D12->DvpVerifyDynamicAllocation(m_ContextId);
+ if (pIndirectDrawAttribsD3D12->GetDesc().Usage == USAGE_DYNAMIC)
+ pIndirectDrawAttribsD3D12->DvpVerifyDynamicAllocation(m_ContextId);
#endif
- GraphCtx.TransitionResource(pBufferD3D12, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT);
+ GraphCtx.TransitionResource(pIndirectDrawAttribsD3D12, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT);
size_t BuffDataStartByteOffset;
- ID3D12Resource *pd3d12ArgsBuff = pBufferD3D12->GetD3D12Buffer(BuffDataStartByteOffset, m_ContextId);
- GraphCtx.ExecuteIndirect(DrawAttribs.IsIndexed ? m_pDrawIndexedIndirectSignature : m_pDrawIndirectSignature, pd3d12ArgsBuff, DrawAttribs.IndirectDrawArgsOffset + BuffDataStartByteOffset);
+ ID3D12Resource *pd3d12ArgsBuff = pIndirectDrawAttribsD3D12->GetD3D12Buffer(BuffDataStartByteOffset, m_ContextId);
+ GraphCtx.ExecuteIndirect(drawAttribs.IsIndexed ? m_pDrawIndexedIndirectSignature : m_pDrawIndirectSignature, pd3d12ArgsBuff, drawAttribs.IndirectDrawArgsOffset + BuffDataStartByteOffset);
}
else
{
- if( DrawAttribs.IsIndexed )
- GraphCtx.DrawIndexed(DrawAttribs.NumIndices, DrawAttribs.NumInstances, DrawAttribs.FirstIndexLocation, DrawAttribs.BaseVertex, DrawAttribs.FirstInstanceLocation);
+ if( drawAttribs.IsIndexed )
+ GraphCtx.DrawIndexed(drawAttribs.NumIndices, drawAttribs.NumInstances, drawAttribs.FirstIndexLocation, drawAttribs.BaseVertex, drawAttribs.FirstInstanceLocation);
else
- GraphCtx.Draw(DrawAttribs.NumVertices, DrawAttribs.NumInstances, DrawAttribs.StartVertexLocation, DrawAttribs.FirstInstanceLocation );
+ GraphCtx.Draw(drawAttribs.NumVertices, drawAttribs.NumInstances, drawAttribs.StartVertexLocation, drawAttribs.FirstInstanceLocation );
}
++m_NumCommandsInCurCtx;
}
void DeviceContextD3D12Impl::DispatchCompute( const DispatchComputeAttribs& DispatchAttrs )
{
-#ifdef _DEBUG
- if (!m_pPipelineState)
- {
- LOG_ERROR("No pipeline state is bound");
- return;
- }
- if (!m_pPipelineState->GetDesc().IsComputePipeline)
- {
- LOG_ERROR("No compute pipeline state is bound");
+#ifdef DEVELOPMENT
+ if (!DvpVerifyDispatchArguments(DispatchAttrs))
return;
- }
#endif
auto& ComputeCtx = RequestCmdContext()->AsComputeContext();