From 4c7a584a22a7a7a17494b26f616a34012c253ddd Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 29 Aug 2019 09:06:51 -0700 Subject: Added IDeviceContextD3D12::GetD3D12CommandList method --- .../GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h | 2 ++ Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h | 12 ++++++++++++ Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 6 ++++++ 3 files changed, 20 insertions(+) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index d22784dd..7674ed54 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -158,6 +158,8 @@ public: virtual void TransitionBufferState(IBuffer *pBuffer, D3D12_RESOURCE_STATES State)override final; + virtual ID3D12GraphicsCommandList* GetD3D12CommandList()override final; + ///// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute) //static constexpr int NumShaderTypes = 6; diff --git a/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h b/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h index 38e2d1a8..293815d9 100644 --- a/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h @@ -51,6 +51,18 @@ public: /// \param [in] pBuffer - Buffer to transition /// \param [in] State - D3D12 resource state this buffer to transition to virtual void TransitionBufferState(IBuffer* pBuffer, D3D12_RESOURCE_STATES State) = 0; + + /// Returns a pointer to Direct3D12 graphics command list that is currently being recorded + + /// \return - a pointer to the current command list + /// + /// \remarks Any command on the device context may potentially submit the command list for + /// execution into the command queue and make it invalid. An application should + /// never cache the pointer and should instead request the command list every time it + /// needs it.\n + /// The engine manages the lifetimes of all command buffers, so an application must + /// not call AddRef/Release methods on the returned interface. + virtual ID3D12GraphicsCommandList* GetD3D12CommandList() = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 3c1a4ca6..01aa8307 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -1629,4 +1629,10 @@ namespace Diligent auto& CmdCtx = GetCmdContext(); CmdCtx.TransitionResource(ValidatedCast(pBuffer), D3D12ResourceStatesToResourceStateFlags(State)); } + + ID3D12GraphicsCommandList* DeviceContextD3D12Impl::GetD3D12CommandList() + { + auto& CmdCtx = GetCmdContext(); + return CmdCtx.GetCommandList(); + } } -- cgit v1.2.3