diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-09-08 21:56:26 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-09-08 21:56:26 +0000 |
| commit | 52d1b5ab7fee4f2c4e63eaf5774d48111becba12 (patch) | |
| tree | 9eac4952a2eb4765352270cc7993fbefec83c6ce /Graphics/GraphicsEngineD3D12 | |
| parent | Updated constructor of RefCountedObject to forward arguments to its base class (diff) | |
| download | DiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.tar.gz DiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.zip | |
Added IDeviceContext::Wait() method (updated API version to 240026)
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
7 files changed, 38 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h index 4089663c..e1d29f2e 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandQueueD3D12Impl.h @@ -56,7 +56,9 @@ public: virtual Uint64 GetCompletedFenceValue()override final; - void SignalFence(ID3D12Fence* pFence, Uint64 Value)override final; + virtual void SignalFence(ID3D12Fence* pFence, Uint64 Value)override final; + + virtual void Wait(ID3D12Fence* pFence, Uint64 Value)override final; private: // A value that will be signaled by the command queue next diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index 7674ed54..a0cea3d2 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -154,6 +154,8 @@ public: virtual void SignalFence(IFence* pFence, Uint64 Value)override final; + virtual void Wait(IFence* pFence, Uint64 Value)override final; + virtual void TransitionTextureState(ITexture *pTexture, D3D12_RESOURCE_STATES State)override final; virtual void TransitionBufferState(IBuffer *pBuffer, D3D12_RESOURCE_STATES State)override final; diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h index 0551f7d0..9a70e68d 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h @@ -85,6 +85,8 @@ public: PooledCommandContext AllocateCommandContext(const Char* ID = ""); void CloseAndExecuteTransientCommandContext(Uint32 CommandQueueIndex, PooledCommandContext&& Ctx); Uint64 CloseAndExecuteCommandContext(Uint32 QueueIndex, PooledCommandContext&& Ctx, bool DiscardStaleObjects, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence> > >* pSignalFences); + + void WaitForFence(Uint32 QueueIndex, IFence* pFence, Uint64 Value); // Disposes an unused command context void DisposeCommandContext(PooledCommandContext&& Ctx); @@ -101,7 +103,7 @@ public: } const GenerateMipsHelper& GetMipsGenerator()const {return m_MipsGenerator;} - + private: virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat )override final; void FreeCommandContext(PooledCommandContext&& Ctx); diff --git a/Graphics/GraphicsEngineD3D12/interface/CommandQueueD3D12.h b/Graphics/GraphicsEngineD3D12/interface/CommandQueueD3D12.h index 81ff9b45..5ad649fa 100644 --- a/Graphics/GraphicsEngineD3D12/interface/CommandQueueD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/CommandQueueD3D12.h @@ -56,6 +56,9 @@ public: /// Signals the given fence virtual void SignalFence(ID3D12Fence* pFence, Uint64 Value) = 0; + + /// Waits until the specified fence reaches or exceeds the specified value. + virtual void Wait(ID3D12Fence* pFence, Uint64 Value) = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp index ed41e02a..df423816 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp @@ -99,4 +99,10 @@ void CommandQueueD3D12Impl::SignalFence(ID3D12Fence* pFence, Uint64 Value) m_pd3d12CmdQueue->Signal(pFence, Value); } +void CommandQueueD3D12Impl::Wait(ID3D12Fence* pFence, Uint64 Value) +{ + std::lock_guard<std::mutex> Lock(m_QueueMtx); + m_pd3d12CmdQueue->Wait(pFence, Value); +} + } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 01aa8307..7daa6437 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -1562,7 +1562,15 @@ namespace Diligent { VERIFY(!m_bIsDeferred, "Fence can only be signaled from immediate context"); m_PendingFences.emplace_back(Value, pFence); - }; + } + + void DeviceContextD3D12Impl::Wait(IFence* pFence, Uint64 Value) + { + VERIFY(!m_bIsDeferred, "Fence can only be waited from immediate context"); + Flush(); + m_pDevice.RawPtr<RenderDeviceD3D12Impl>()->WaitForFence(m_CommandQueueId, pFence, Value); + } + void DeviceContextD3D12Impl::TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) { diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index a7d2f6c6..e7ee520e 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -197,6 +197,18 @@ Uint64 RenderDeviceD3D12Impl::CloseAndExecuteCommandContext(Uint32 QueueIndex, P return FenceValue; } +void RenderDeviceD3D12Impl::WaitForFence(Uint32 QueueIndex, IFence* pFence, Uint64 Value) +{ + VERIFY_EXPR(QueueIndex < m_CmdQueueCount); + VERIFY_EXPR(pFence != nullptr); + + auto* pFenceD3D12Impl = ValidatedCast<FenceD3D12Impl>(pFence); + auto* pd3d12Fence = pFenceD3D12Impl->GetD3D12Fence(); + m_CommandQueues[QueueIndex].CmdQueue->Wait(pd3d12Fence, Value); + + PurgeReleaseQueue(QueueIndex); +} + void RenderDeviceD3D12Impl::IdleGPU() { |
