summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-20 20:23:53 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-20 20:23:53 +0000
commite08590880055ef1dc3e5bda68079598a8d1567e3 (patch)
treeefcca84327d474f3ea91ef8818ade5b7610d3f33 /Graphics/GraphicsEngineD3D12
parentGL backend: implemented render passes attachment invalidation with glInvalida... (diff)
downloadDiligentCore-e08590880055ef1dc3e5bda68079598a8d1567e3.tar.gz
DiligentCore-e08590880055ef1dc3e5bda68079598a8d1567e3.zip
D3D12 backend: added version support to GraphicsContext
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/CommandContext.hpp19
-rw-r--r--Graphics/GraphicsEngineD3D12/src/CommandContext.cpp12
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp6
3 files changed, 32 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp b/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
index 6fd7c63f..b2fe9bb1 100644
--- a/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
@@ -80,8 +80,9 @@ public:
ID3D12GraphicsCommandList* Close(CComPtr<ID3D12CommandAllocator>& pAllocator);
void Reset(CommandListManager& CmdListManager);
- class GraphicsContext& AsGraphicsContext();
- class ComputeContext& AsComputeContext();
+ class GraphicsContext& AsGraphicsContext();
+ class GraphicsContext4& AsGraphicsContext4();
+ class ComputeContext& AsComputeContext();
void ClearUAVFloat(D3D12_GPU_DESCRIPTOR_HANDLE GpuHandle,
D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle,
@@ -227,6 +228,10 @@ protected:
String m_ID;
D3D12_PRIMITIVE_TOPOLOGY m_PrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
+
+#ifdef DILIGENT_DEBUG
+ Uint32 m_DbgMaxInterfaceVer = 0;
+#endif
};
@@ -344,7 +349,11 @@ public:
FlushResourceBarriers();
m_pCommandList->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, StartInstanceLocation);
}
+};
+class GraphicsContext4 : public GraphicsContext
+{
+public:
void BeginRenderPass(UINT NumRenderTargets,
const D3D12_RENDER_PASS_RENDER_TARGET_DESC* pRenderTargets,
const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC* pDepthStencil,
@@ -425,6 +434,12 @@ inline GraphicsContext& CommandContext::AsGraphicsContext()
return static_cast<GraphicsContext&>(*this);
}
+inline GraphicsContext4& CommandContext::AsGraphicsContext4()
+{
+ VERIFY(m_DbgMaxInterfaceVer >= 4, "Maximum supported interface version is ", m_DbgMaxInterfaceVer);
+ return static_cast<GraphicsContext4&>(*this);
+}
+
inline ComputeContext& CommandContext::AsComputeContext()
{
return static_cast<ComputeContext&>(*this);
diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
index dded6b29..da26de46 100644
--- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
@@ -47,6 +47,18 @@ CommandContext::CommandContext(CommandListManager& CmdListManager) :
{
m_PendingResourceBarriers.reserve(MaxPendingBarriers);
CmdListManager.CreateNewCommandList(&m_pCommandList, &m_pCurrentAllocator);
+#ifdef DILIGENT_DEBUG
+ if (CComQIPtr<ID3D12GraphicsCommandList5>(m_pCommandList))
+ m_DbgMaxInterfaceVer = 5;
+ else if (CComQIPtr<ID3D12GraphicsCommandList4>(m_pCommandList))
+ m_DbgMaxInterfaceVer = 4;
+ else if (CComQIPtr<ID3D12GraphicsCommandList3>(m_pCommandList))
+ m_DbgMaxInterfaceVer = 3;
+ else if (CComQIPtr<ID3D12GraphicsCommandList2>(m_pCommandList))
+ m_DbgMaxInterfaceVer = 2;
+ else
+ m_DbgMaxInterfaceVer = 1;
+#endif
}
CommandContext::~CommandContext(void)
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 08b64857..355b90b0 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -1221,7 +1221,7 @@ void DeviceContextD3D12Impl::CommitSubpassRenderTargets()
}
auto& CmdCtx = GetCmdContext();
- CmdCtx.AsGraphicsContext().BeginRenderPass(
+ CmdCtx.AsGraphicsContext4().BeginRenderPass(
Subpass.RenderTargetAttachmentCount,
RenderPassRTs,
m_pBoundDepthStencil ? &RenderPassDS : nullptr,
@@ -1246,7 +1246,7 @@ void DeviceContextD3D12Impl::BeginRenderPass(const BeginRenderPassAttribs& Attri
void DeviceContextD3D12Impl::NextSubpass()
{
auto& CmdCtx = GetCmdContext();
- CmdCtx.AsGraphicsContext().EndRenderPass();
+ CmdCtx.AsGraphicsContext4().EndRenderPass();
TDeviceContextBase::NextSubpass();
TransitionSubpassAttachments(m_SubpassIndex);
CommitSubpassRenderTargets();
@@ -1255,7 +1255,7 @@ void DeviceContextD3D12Impl::NextSubpass()
void DeviceContextD3D12Impl::EndRenderPass()
{
auto& CmdCtx = GetCmdContext();
- CmdCtx.AsGraphicsContext().EndRenderPass();
+ CmdCtx.AsGraphicsContext4().EndRenderPass();
TransitionSubpassAttachments(m_SubpassIndex + 1);
TDeviceContextBase::EndRenderPass();
}