summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-30 16:57:39 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-30 16:57:39 +0000
commit4a3803e1de2669fb546bff0396f083766fad402e (patch)
tree599d610ef4dffe28aa9cfaded09f3e8eb3e0e52c /Graphics/GraphicsEngineD3D12
parentUpdated install instructions for license.txt (diff)
downloadDiligentCore-4a3803e1de2669fb546bff0396f083766fad402e.tar.gz
DiligentCore-4a3803e1de2669fb546bff0396f083766fad402e.zip
Added methods to get command queue from the device context (API Version 240038)
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h11
-rw-r--r--Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h22
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp6
5 files changed, 34 insertions, 9 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
index b9561b3b..1383d439 100644
--- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
@@ -29,7 +29,6 @@
#include <unordered_map>
#include "DeviceContextD3D12.h"
-#include "DeviceContextBase.h"
#include "DeviceContextNextGenBase.h"
#include "BufferD3D12Impl.h"
#include "TextureD3D12Impl.h"
@@ -39,21 +38,25 @@
namespace Diligent
{
+class RenderDeviceD3D12Impl;
+
struct DeviceContextD3D12ImplTraits
{
using BufferType = BufferD3D12Impl;
using TextureType = TextureD3D12Impl;
using PipelineStateType = PipelineStateD3D12Impl;
+ using DeviceType = RenderDeviceD3D12Impl;
+ using ICommandQueueType = ICommandQueueD3D12;
};
/// Implementation of the Diligent::IDeviceContext interface
-class DeviceContextD3D12Impl final : public DeviceContextNextGenBase< DeviceContextBase<IDeviceContextD3D12, DeviceContextD3D12ImplTraits> >
+class DeviceContextD3D12Impl final : public DeviceContextNextGenBase<IDeviceContextD3D12, DeviceContextD3D12ImplTraits>
{
public:
- using TDeviceContextBase = DeviceContextNextGenBase< DeviceContextBase<IDeviceContextD3D12, DeviceContextD3D12ImplTraits> >;
+ using TDeviceContextBase = DeviceContextNextGenBase<IDeviceContextD3D12, DeviceContextD3D12ImplTraits>;
DeviceContextD3D12Impl(IReferenceCounters* pRefCounters,
- class RenderDeviceD3D12Impl* pDevice,
+ RenderDeviceD3D12Impl* pDevice,
bool bIsDeferred,
const EngineD3D12CreateInfo& EngineCI,
Uint32 ContextId,
diff --git a/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h b/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h
index 9769b20f..54d6abe2 100644
--- a/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h
+++ b/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h
@@ -27,6 +27,7 @@
/// Definition of the Diligent::IDeviceContextD3D12 interface
#include "../../GraphicsEngine/interface/DeviceContext.h"
+#include "CommandQueueD3D12.h"
namespace Diligent
{
@@ -70,6 +71,27 @@ public:
/// calling IDeviceContext::InvalidateState() and then manually restore all required states via
/// appropriate Diligent API calls.
virtual ID3D12GraphicsCommandList* GetD3D12CommandList() = 0;
+
+ /// Locks the internal mutex and returns a pointer to the command queue that is associated with this device context.
+
+ /// \return - a pointer to ICommandQueueD3D12 interface of the command queue associated with the context.
+ ///
+ /// \remarks Only immediate device contexts have associated command queues.
+ ///
+ /// The engine locks the internal mutex to prevent simultaneous access to the command queue.
+ /// An application must release the lock by calling IDeviceContextD3D12::UnlockCommandQueue()
+ /// when it is done working with the queue or the engine will not be able to submit any command
+ /// list to the queue. Nested calls to LockCommandQueue() are not allowed.
+ /// The queue pointer never changes while the context is alive, so an application may cache and
+ /// use the pointer if it does not need to prevent potential simultaneous access to the queue from
+ /// other threads.
+ ///
+ /// The engine manages the lifetimes of command queues and all other device objects,
+ /// so an application must not call AddRef/Release methods on the returned interface.
+ virtual ICommandQueueD3D12* LockCommandQueue() = 0;
+
+ /// Unlocks the command queue that was previously locked by IDeviceContextD3D12::LockCommandQueue().
+ virtual void UnlockCommandQueue() = 0;
};
}
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 645bc2b4..5cedaf86 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -749,7 +749,7 @@ namespace Diligent
for(size_t i=0; i < _countof(m_DynamicGPUDescriptorAllocator); ++i)
m_DynamicGPUDescriptorAllocator[i].ReleaseAllocations(m_SubmittedBuffersCmdQueueMask);
- EndFrame(*m_pDevice.RawPtr<RenderDeviceD3D12Impl>());
+ EndFrame();
}
void DeviceContextD3D12Impl::SetVertexBuffers( Uint32 StartSlot,
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index adb16b36..c517f634 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -187,7 +187,7 @@ void RenderDeviceD3D12Impl::CloseAndExecuteTransientCommandContext(Uint32 Comman
ID3D12GraphicsCommandList* pCmdList = Ctx->Close(pAllocator);
Uint64 FenceValue = 0;
// Execute command list directly through the queue to avoid interference with command list numbers in the queue
- LockCommandQueue(CommandQueueIndex,
+ LockCmdQueueAndRun(CommandQueueIndex,
[&](ICommandQueueD3D12* pCmdQueue)
{
FenceValue = pCmdQueue->Submit(pCmdList);
diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp
index d9790df6..92e1c626 100644
--- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp
@@ -49,7 +49,7 @@ SwapChainD3D12Impl::SwapChainD3D12Impl(IReferenceCounters* pRefCounters,
},
m_pBackBufferRTV{STD_ALLOCATOR_RAW_MEM(RefCntAutoPtr<ITextureView>, GetRawAllocator(), "Allocator for vector<RefCntAutoPtr<ITextureView>>")}
{
- pRenderDeviceD3D12->LockCommandQueue(0,
+ pRenderDeviceD3D12->LockCmdQueueAndRun(0,
[this](ICommandQueueD3D12 *pCmdQueue)
{
CreateDXGISwapChain(pCmdQueue->GetD3D12CommandQueue());
@@ -187,8 +187,8 @@ void SwapChainD3D12Impl::UpdateSwapChain(bool CreateNew)
if(CreateNew)
{
m_pSwapChain.Release();
- m_pRenderDevice.RawPtr<RenderDeviceD3D12Impl>()->LockCommandQueue(0,
- [this](ICommandQueueD3D12 *pCmdQueue)
+ m_pRenderDevice.RawPtr<RenderDeviceD3D12Impl>()->LockCmdQueueAndRun(0,
+ [this](ICommandQueueD3D12* pCmdQueue)
{
CreateDXGISwapChain(pCmdQueue->GetD3D12CommandQueue());
}