From e08590880055ef1dc3e5bda68079598a8d1567e3 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 20 Aug 2020 13:23:53 -0700 Subject: D3D12 backend: added version support to GraphicsContext --- .../GraphicsEngineD3D12/include/CommandContext.hpp | 19 +++++++++++++++++-- Graphics/GraphicsEngineD3D12/src/CommandContext.cpp | 12 ++++++++++++ .../src/DeviceContextD3D12Impl.cpp | 6 +++--- 3 files changed, 32 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') 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& 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(*this); } +inline GraphicsContext4& CommandContext::AsGraphicsContext4() +{ + VERIFY(m_DbgMaxInterfaceVer >= 4, "Maximum supported interface version is ", m_DbgMaxInterfaceVer); + return static_cast(*this); +} + inline ComputeContext& CommandContext::AsComputeContext() { return static_cast(*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(m_pCommandList)) + m_DbgMaxInterfaceVer = 5; + else if (CComQIPtr(m_pCommandList)) + m_DbgMaxInterfaceVer = 4; + else if (CComQIPtr(m_pCommandList)) + m_DbgMaxInterfaceVer = 3; + else if (CComQIPtr(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(); } -- cgit v1.2.3