diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-10-30 16:57:39 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-10-30 16:57:39 +0000 |
| commit | 4a3803e1de2669fb546bff0396f083766fad402e (patch) | |
| tree | 599d610ef4dffe28aa9cfaded09f3e8eb3e0e52c /Graphics/GraphicsEngineNextGenBase | |
| parent | Updated install instructions for license.txt (diff) | |
| download | DiligentCore-4a3803e1de2669fb546bff0396f083766fad402e.tar.gz DiligentCore-4a3803e1de2669fb546bff0396f083766fad402e.zip | |
Added methods to get command queue from the device context (API Version 240038)
Diffstat (limited to 'Graphics/GraphicsEngineNextGenBase')
| -rw-r--r-- | Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.h | 34 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h | 19 |
2 files changed, 46 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.h b/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.h index 14f105d4..f92c0d93 100644 --- a/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.h +++ b/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.h @@ -27,16 +27,21 @@ #include "BasicTypes.h" #include "ReferenceCounters.h" #include "RefCntAutoPtr.h" +#include "DeviceContextBase.h" namespace Diligent { /// Base implementation of the device context for next-generation backends. -template<class TBase> -class DeviceContextNextGenBase : public TBase +template<typename BaseInterface, typename ImplementationTraits> +class DeviceContextNextGenBase : public DeviceContextBase<BaseInterface, ImplementationTraits> { public: + using TBase = DeviceContextBase<BaseInterface, ImplementationTraits>; + using DeviceImplType = typename ImplementationTraits::DeviceType; + using ICommandQueueType = typename ImplementationTraits::ICommandQueueType; + DeviceContextNextGenBase(IReferenceCounters* pRefCounters, IRenderDevice* pRenderDevice, Uint32 ContextId, @@ -58,11 +63,30 @@ public: { } + virtual ICommandQueueType* LockCommandQueue()override final + { + if (m_bIsDeferred) + { + LOG_WARNING_MESSAGE("Deferred contexts have no associated command queues"); + return nullptr; + } + return m_pDevice.RawPtr<DeviceImplType>()->LockCommandQueue(m_CommandQueueId); + } + + virtual void UnlockCommandQueue() + { + if (m_bIsDeferred) + { + LOG_WARNING_MESSAGE("Deferred contexts have no associated command queues"); + return; + } + m_pDevice.RawPtr<DeviceImplType>()->UnlockCommandQueue(m_CommandQueueId); + } + protected: // Should be called at the end of FinishFrame() - template<typename RenderDeviceImplType> - void EndFrame(RenderDeviceImplType& RenderDeviceImpl) + void EndFrame() { if (this->m_bIsDeferred) { @@ -71,7 +95,7 @@ protected: } else { - RenderDeviceImpl.FlushStaleResources(m_CommandQueueId); + m_pDevice.RawPtr<DeviceImplType>()->FlushStaleResources(m_CommandQueueId); } Atomics::AtomicIncrement(m_ContextFrameNumber); } diff --git a/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h b/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h index 135dd941..41ceadfb 100644 --- a/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h +++ b/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h @@ -230,7 +230,7 @@ public: return m_CommandQueues[QueueIndex].ReleaseQueue; } - const CommandQueueType& GetCommandQueue(Uint32 QueueIndex) + const CommandQueueType& GetCommandQueue(Uint32 QueueIndex)const { VERIFY_EXPR(QueueIndex < m_CmdQueueCount); return *m_CommandQueues[QueueIndex].CmdQueue; @@ -252,7 +252,7 @@ public: } template<typename TAction> - void LockCommandQueue(Uint32 QueueIndex, TAction Action) + void LockCmdQueueAndRun(Uint32 QueueIndex, TAction Action) { VERIFY_EXPR(QueueIndex < m_CmdQueueCount); auto& Queue = m_CommandQueues[QueueIndex]; @@ -260,6 +260,21 @@ public: Action(Queue.CmdQueue); } + CommandQueueType* LockCommandQueue(Uint32 QueueIndex) + { + VERIFY_EXPR(QueueIndex < m_CmdQueueCount); + auto& Queue = m_CommandQueues[QueueIndex]; + Queue.Mtx.lock(); + return Queue.CmdQueue; + } + + void UnlockCommandQueue(Uint32 QueueIndex) + { + VERIFY_EXPR(QueueIndex < m_CmdQueueCount); + auto& Queue = m_CommandQueues[QueueIndex]; + Queue.Mtx.unlock(); + } + protected: void DestroyCommandQueues() { |
