summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-13 04:29:31 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-13 04:29:31 +0000
commit5cfb2763ae0bd7a7eff679fa19565690be1abeb7 (patch)
tree0991b5944802b7040eb2ec16a70443a260d872ba /Graphics/GraphicsEngineD3D11
parentVk query manager: improved query reuse order (diff)
downloadDiligentCore-5cfb2763ae0bd7a7eff679fa19565690be1abeb7.tar.gz
DiligentCore-5cfb2763ae0bd7a7eff679fa19565690be1abeb7.zip
Added DurationQueryHelper class; fixed issue with disjoint query in D3D11 backend
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h1
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp26
-rw-r--r--Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp1
4 files changed, 19 insertions, 11 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h b/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h
index 5de5cc2a..c9d259ab 100644
--- a/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h
+++ b/Graphics/GraphicsEngineD3D11/include/DisjointQueryPool.h
@@ -42,6 +42,7 @@ public:
{
DisjointQueryPool& Pool;
CComPtr<ID3D11Query> pd3d11Query;
+ bool IsEnded = false;
DisjointQueryWrapper(DisjointQueryPool& _Pool,
CComPtr<ID3D11Query>&& _pd3d11Query) :
diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
index 8009c9b0..d963c7b1 100755
--- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
@@ -1152,6 +1152,7 @@ void DeviceContextD3D11Impl::FinishFrame()
if (m_ActiveDisjointQuery)
{
m_pd3d11DeviceContext->End(m_ActiveDisjointQuery->pd3d11Query);
+ m_ActiveDisjointQuery->IsEnded = true;
m_ActiveDisjointQuery.reset();
}
}
@@ -1838,6 +1839,7 @@ void DeviceContextD3D11Impl::EndQuery(IQuery* pQuery)
m_ActiveDisjointQuery = m_DisjointQueryPool.GetDisjointQuery(m_pDevice->GetD3D11Device());
// Disjoint timestamp queries should only be invoked once per frame or less.
m_pd3d11DeviceContext->Begin(m_ActiveDisjointQuery->pd3d11Query);
+ m_ActiveDisjointQuery->IsEnded = false;
}
pQueryD3D11Impl->SetDisjointQuery(m_ActiveDisjointQuery);
}
diff --git a/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp
index a6335b13..751810de 100644
--- a/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/QueryD3D11Impl.cpp
@@ -119,20 +119,24 @@ bool QueryD3D11Impl::GetData(void* pData, Uint32 DataSize, bool AutoInvalidate)
VERIFY_EXPR(m_DisjointQuery);
- UINT64 Counter = 0;
- DataReady = pd3d11Ctx->GetData(m_pd3d11Query, &Counter, sizeof(Counter), 0) == S_OK;
-
- if (DataReady && pData != nullptr)
+ DataReady = m_DisjointQuery->IsEnded;
+ if (DataReady)
{
- D3D11_QUERY_DATA_TIMESTAMP_DISJOINT DisjointQueryData;
- DataReady = pd3d11Ctx->GetData(m_DisjointQuery->pd3d11Query, &DisjointQueryData, sizeof(DisjointQueryData), 0) == S_OK;
+ UINT64 Counter = 0;
+ DataReady = pd3d11Ctx->GetData(m_pd3d11Query, &Counter, sizeof(Counter), 0) == S_OK;
- if (DataReady)
+ if (DataReady && pData != nullptr)
{
- auto& QueryData = *reinterpret_cast<QueryDataTimestamp*>(pData);
- QueryData.Counter = Counter;
- // The timestamp returned by ID3D11DeviceContext::GetData for a timestamp query is only reliable if Disjoint is FALSE.
- QueryData.Frequency = DisjointQueryData.Disjoint ? 0 : DisjointQueryData.Frequency;
+ D3D11_QUERY_DATA_TIMESTAMP_DISJOINT DisjointQueryData;
+ DataReady = pd3d11Ctx->GetData(m_DisjointQuery->pd3d11Query, &DisjointQueryData, sizeof(DisjointQueryData), 0) == S_OK;
+
+ if (DataReady)
+ {
+ auto& QueryData = *reinterpret_cast<QueryDataTimestamp*>(pData);
+ QueryData.Counter = Counter;
+ // The timestamp returned by ID3D11DeviceContext::GetData for a timestamp query is only reliable if Disjoint is FALSE.
+ QueryData.Frequency = DisjointQueryData.Disjoint ? 0 : DisjointQueryData.Frequency;
+ }
}
}
}
diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp
index 94497ca0..537064e5 100644
--- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp
@@ -133,6 +133,7 @@ void SwapChainD3D11Impl::Present(Uint32 SyncInterval)
if (m_SwapChainDesc.IsPrimary)
{
+ pImmediateCtxD3D11->FinishFrame();
// Clear the state caches to release all outstanding objects
// that are only kept alive by references in the cache
// It is better to do this before calling Present() as D3D11