From d96c22be052635c031d67b6f2ca34230d4d28d2f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 2 Nov 2019 13:29:53 +0100 Subject: [PATCH] [d3d11] Do not synchronize with CS thread in GetData Instead, use a counter to determine whether there are any pending operation for the query on the CS thread. --- src/d3d11/d3d11_context_imm.cpp | 4 ---- src/d3d11/d3d11_query.cpp | 9 +++++++++ src/d3d11/d3d11_query.h | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index afd6a7c7..f24bae1f 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -77,10 +77,6 @@ namespace dxvk { // DataSize is 0, but we should ignore that pointer pData = DataSize ? pData : nullptr; - // Ensure that all query commands actually get - // executed before trying to access the query - SynchronizeCsThread(); - // Get query status directly from the query object auto query = static_cast(pAsync); HRESULT hr = query->GetData(pData, GetDataFlags); diff --git a/src/d3d11/d3d11_query.cpp b/src/d3d11/d3d11_query.cpp index b434a1c7..1d47b47a 100644 --- a/src/d3d11/d3d11_query.cpp +++ b/src/d3d11/d3d11_query.cpp @@ -214,6 +214,8 @@ namespace dxvk { if (unlikely(m_predicate != nullptr)) ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]); + + m_resetCtr -= 1; } @@ -230,6 +232,7 @@ namespace dxvk { return false; m_state = D3D11_VK_QUERY_ENDED; + m_resetCtr += 1; return true; } @@ -237,6 +240,12 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE D3D11Query::GetData( void* pData, UINT GetDataFlags) { + if (m_state != D3D11_VK_QUERY_ENDED) + return DXGI_ERROR_INVALID_CALL; + + if (m_resetCtr != 0u) + return S_FALSE; + if (m_desc.Query == D3D11_QUERY_EVENT) { DxvkGpuEventStatus status = m_event[0]->test(); diff --git a/src/d3d11/d3d11_query.h b/src/d3d11/d3d11_query.h index c70cd837..ea1e7f1e 100644 --- a/src/d3d11/d3d11_query.h +++ b/src/d3d11/d3d11_query.h @@ -114,6 +114,8 @@ namespace dxvk { uint32_t m_stallMask = 0; bool m_stallFlag = false; + std::atomic m_resetCtr = { 0u }; + UINT64 GetTimestampQueryFrequency() const; Rc CreatePredicateBuffer();