diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-09-09 00:42:51 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-09-09 00:42:51 +0000 |
| commit | d06553e2b4700aa026acd4445a598eadf10dfb35 (patch) | |
| tree | 534c3761a92cfb93d370b75f29f6b720a10c64a8 /Graphics/GraphicsEngineD3D11 | |
| parent | Renamed IDeviceContext::Wait to IDeviceContext::WaitForFence (updated API ver... (diff) | |
| download | DiligentCore-d06553e2b4700aa026acd4445a598eadf10dfb35.tar.gz DiligentCore-d06553e2b4700aa026acd4445a598eadf10dfb35.zip | |
Added IDeviceContext::WaitForIdle() method (updated API version to 240028)
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
| -rwxr-xr-x | Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h | 6 | ||||
| -rwxr-xr-x | Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp | 26 |
2 files changed, 27 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index 940529b4..86ca2fb2 100755 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -103,8 +103,6 @@ public: virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
- virtual void Flush()override final;
-
virtual void UpdateBuffer(IBuffer* pBuffer,
Uint32 Offset,
Uint32 Size,
@@ -158,6 +156,10 @@ public: virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext)override final;
+ virtual void WaitForIdle()override final;
+
+ virtual void Flush()override final;
+
virtual ID3D11DeviceContext* GetD3D11DeviceContext()override final { return m_pd3d11DeviceContext; }
void CommitRenderTargets();
diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 72e26117..e3543bac 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1747,20 +1747,28 @@ namespace Diligent #endif
}
- void DeviceContextD3D11Impl::SignalFence(IFence* pFence, Uint64 Value)
+
+ static CComPtr<ID3D11Query> CreateD3D11QueryEvent(ID3D11Device* pd3d11Device)
{
- VERIFY(!m_bIsDeferred, "Fence can only be signaled from immediate context");
- auto* pd3d11Device = m_pDevice.RawPtr<RenderDeviceD3D11Impl>()->GetD3D11Device();
D3D11_QUERY_DESC QueryDesc = {};
QueryDesc.Query = D3D11_QUERY_EVENT; // Determines whether or not the GPU is finished processing commands.
// When the GPU is finished processing commands ID3D11DeviceContext::GetData will
// return S_OK, and pData will point to a BOOL with a value of TRUE. When using this
// type of query, ID3D11DeviceContext::Begin is disabled.
QueryDesc.MiscFlags = 0;
+
CComPtr<ID3D11Query> pd3d11Query;
auto hr = pd3d11Device->CreateQuery(&QueryDesc, &pd3d11Query);
DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to create D3D11 query");
VERIFY_EXPR(pd3d11Query);
+ return pd3d11Query;
+ }
+
+ void DeviceContextD3D11Impl::SignalFence(IFence* pFence, Uint64 Value)
+ {
+ VERIFY(!m_bIsDeferred, "Fence can only be signaled from immediate context");
+ auto* pd3d11Device = m_pDevice.RawPtr<RenderDeviceD3D11Impl>()->GetD3D11Device();
+ CComPtr<ID3D11Query> pd3d11Query = CreateD3D11QueryEvent(pd3d11Device);
m_pd3d11DeviceContext->End(pd3d11Query);
auto* pFenceD3D11Impl = ValidatedCast<FenceD3D11Impl>(pFence);
pFenceD3D11Impl->AddPendingQuery(m_pd3d11DeviceContext, std::move(pd3d11Query), Value);
@@ -1775,6 +1783,18 @@ namespace Diligent pFenceD3D11Impl->Wait(Value, FlushContext);
}
+ void DeviceContextD3D11Impl::WaitForIdle()
+ {
+ VERIFY(!m_bIsDeferred, "Only immediate contexts can be idled");
+ Flush();
+ auto* pd3d11Device = m_pDevice.RawPtr<RenderDeviceD3D11Impl>()->GetD3D11Device();
+ CComPtr<ID3D11Query> pd3d11Query = CreateD3D11QueryEvent(pd3d11Device);
+ m_pd3d11DeviceContext->End(pd3d11Query);
+ BOOL Data;
+ while (m_pd3d11DeviceContext->GetData(pd3d11Query, &Data, sizeof(Data), 0) != S_OK)
+ std::this_thread::yield();
+ }
+
void DeviceContextD3D11Impl::ClearStateCache()
{
TDeviceContextBase::ClearStateCache();
|
