summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-09-08 21:56:26 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-09-08 21:56:26 +0000
commit52d1b5ab7fee4f2c4e63eaf5774d48111becba12 (patch)
tree9eac4952a2eb4765352270cc7993fbefec83c6ce /Graphics/GraphicsEngineD3D11
parentUpdated constructor of RefCountedObject to forward arguments to its base class (diff)
downloadDiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.tar.gz
DiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.zip
Added IDeviceContext::Wait() method (updated API version to 240026)
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rwxr-xr-xGraphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h2
-rw-r--r--Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h2
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp10
-rw-r--r--Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp20
4 files changed, 33 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h
index bc5c87a6..ef7124be 100755
--- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h
+++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h
@@ -156,6 +156,8 @@ public:
virtual void SignalFence(IFence* pFence, Uint64 Value)override final;
+ virtual void Wait(IFence* pFence, Uint64 Value)override final;
+
virtual ID3D11DeviceContext* GetD3D11DeviceContext()override final { return m_pd3d11DeviceContext; }
void CommitRenderTargets();
diff --git a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h
index 9de594cf..bdfc5262 100644
--- a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h
+++ b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h
@@ -58,6 +58,8 @@ public:
m_PendingQueries.emplace_back(std::move(pCtx), std::move(pQuery), Value);
}
+ void Wait(Uint64 Value);
+
private:
struct PendingFenceData
{
diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
index dc6c3281..1ccdc2e2 100755
--- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
@@ -1764,7 +1764,15 @@ namespace Diligent
m_pd3d11DeviceContext->End(pd3d11Query);
auto* pFenceD3D11Impl = ValidatedCast<FenceD3D11Impl>(pFence);
pFenceD3D11Impl->AddPendingQuery(m_pd3d11DeviceContext, std::move(pd3d11Query), Value);
- };
+ }
+
+ void DeviceContextD3D11Impl::Wait(IFence* pFence, Uint64 Value)
+ {
+ VERIFY(!m_bIsDeferred, "Fence can only be waited from immediate context");
+ Flush();
+ auto* pFenceD3D11Impl = ValidatedCast<FenceD3D11Impl>(pFence);
+ pFenceD3D11Impl->Wait(Value);
+ }
void DeviceContextD3D11Impl::ClearStateCache()
{
diff --git a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp
index 73d32f51..e3bd2f4e 100644
--- a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp
@@ -64,6 +64,26 @@ Uint64 FenceD3D11Impl :: GetCompletedValue()
return m_LastCompletedFenceValue;
}
+void FenceD3D11Impl :: Wait(Uint64 Value)
+{
+ while (!m_PendingQueries.empty())
+ {
+ auto& QueryData = m_PendingQueries.front();
+ if (QueryData.Value > Value)
+ break;
+
+ BOOL Data;
+ while (QueryData.pd3d11Ctx->GetData(QueryData.pd3d11Query, &Data, sizeof(Data), 0) != S_OK)
+ std::this_thread::yield();
+
+ VERIFY_EXPR(Data == TRUE);
+ if (QueryData.Value > m_LastCompletedFenceValue)
+ m_LastCompletedFenceValue = QueryData.Value;
+
+ m_PendingQueries.pop_front();
+ }
+}
+
void FenceD3D11Impl :: Reset(Uint64 Value)
{
DEV_CHECK_ERR(Value >= m_LastCompletedFenceValue, "Resetting fence '", m_Desc.Name, "' to the value (", Value, ") that is smaller than the last completed value (", m_LastCompletedFenceValue, ")");