summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-09-08 23:09:11 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-09-08 23:09:11 +0000
commit01108131af397a32dbcb94f77b8a4c1f564bd474 (patch)
treeede70d818675f9ceae36d5a2c21c6f19d6a97e36 /Graphics/GraphicsEngineD3D12
parentFixed Metal build error (diff)
downloadDiligentCore-01108131af397a32dbcb94f77b8a4c1f564bd474.tar.gz
DiligentCore-01108131af397a32dbcb94f77b8a4c1f564bd474.zip
D3D12 backend: fixed issue with fences not being signaled if there is no command list when flushing the context
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp7
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp19
3 files changed, 20 insertions, 8 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
index 9a70e68d..b447fdc5 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 SignalFences(Uint32 QueueIndex, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence> > >& SignalFences);
void WaitForFence(Uint32 QueueIndex, IFence* pFence, Uint64 Value);
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 7daa6437..1a654109 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -594,6 +594,13 @@ namespace Diligent
pDeviceD3D12Impl->DisposeCommandContext(std::move(m_CurrCmdCtx));
}
+ // If there is no command list to submit, but there are pending fences, we need to signal them now
+ if (!m_PendingFences.empty())
+ {
+ pDeviceD3D12Impl->SignalFences(m_CommandQueueId, m_PendingFences);
+ m_PendingFences.clear();
+ }
+
if(RequestNewCmdCtx)
RequestCommandContext(pDeviceD3D12Impl);
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 0b04c709..8ad14c16 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -179,14 +179,7 @@ Uint64 RenderDeviceD3D12Impl::CloseAndExecuteCommandContext(Uint32 QueueIndex, P
auto SubmittedCmdBuffInfo = TRenderDeviceBase::SubmitCommandBuffer(QueueIndex, pCmdList, true);
FenceValue = SubmittedCmdBuffInfo.FenceValue;
if (pSignalFences != nullptr)
- {
- for (auto& val_fence : *pSignalFences)
- {
- auto* pFenceD3D12Impl = val_fence.second.RawPtr<FenceD3D12Impl>();
- auto* pd3d12Fence = pFenceD3D12Impl->GetD3D12Fence();
- m_CommandQueues[QueueIndex].CmdQueue->SignalFence(pd3d12Fence, val_fence.first);
- }
- }
+ SignalFences(QueueIndex, *pSignalFences);
}
m_CmdListManager.ReleaseAllocator(std::move(pAllocator), QueueIndex, FenceValue);
@@ -197,6 +190,16 @@ Uint64 RenderDeviceD3D12Impl::CloseAndExecuteCommandContext(Uint32 QueueIndex, P
return FenceValue;
}
+void RenderDeviceD3D12Impl::SignalFences(Uint32 QueueIndex, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence> > >& SignalFences)
+{
+ for (auto& val_fence : SignalFences)
+ {
+ auto* pFenceD3D12Impl = val_fence.second.RawPtr<FenceD3D12Impl>();
+ auto* pd3d12Fence = pFenceD3D12Impl->GetD3D12Fence();
+ m_CommandQueues[QueueIndex].CmdQueue->SignalFence(pd3d12Fence, val_fence.first);
+ }
+}
+
void RenderDeviceD3D12Impl::WaitForFence(Uint32 QueueIndex, IFence* pFence, Uint64 Value)
{
VERIFY_EXPR(QueueIndex < m_CmdQueueCount);