diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index df6f89c98..58be4d323 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -89,6 +89,10 @@ namespace dxvk { return E_INVALIDARG; } + // Ensure that all query commands actually get + // executed before trying to access the query + SynchronizeCsThread(); + // Get query status directly from the query object HRESULT hr = static_cast(pAsync)->GetData(pData, GetDataFlags); diff --git a/src/d3d11/d3d11_query.cpp b/src/d3d11/d3d11_query.cpp index c3dd8dae1..2837f1316 100644 --- a/src/d3d11/d3d11_query.cpp +++ b/src/d3d11/d3d11_query.cpp @@ -8,9 +8,11 @@ namespace dxvk { const D3D11_QUERY_DESC& desc) : m_device(device), m_desc(desc), m_d3d10(this, device->GetD3D10Interface()) { + Rc dxvkDevice = m_device->GetDXVKDevice(); + switch (m_desc.Query) { case D3D11_QUERY_EVENT: - m_event = new DxvkEvent(); + m_event = dxvkDevice->createGpuEvent(); break; case D3D11_QUERY_OCCLUSION: @@ -171,9 +173,6 @@ namespace dxvk { if (m_query != nullptr) return m_query->reset(); - if (m_event != nullptr) - return m_event->reset(); - return 0; } @@ -205,8 +204,7 @@ namespace dxvk { void D3D11Query::Signal(DxvkContext* ctx, uint32_t revision) { switch (m_desc.Query) { case D3D11_QUERY_EVENT: { - DxvkEventRevision rev = { m_event, revision }; - ctx->signalEvent(rev); + ctx->signalGpuEvent(m_event); } break; case D3D11_QUERY_TIMESTAMP: { @@ -224,7 +222,16 @@ namespace dxvk { void* pData, UINT GetDataFlags) { if (m_desc.Query == D3D11_QUERY_EVENT) { - const bool signaled = m_event->getStatus() == DxvkEventStatus::Signaled; + DxvkGpuEventStatus status = m_event->test(); + + if (status == DxvkGpuEventStatus::Invalid) + return DXGI_ERROR_INVALID_CALL; + + bool signaled = status == DxvkGpuEventStatus::Signaled; + + // FIXME remove once query refactor is done + if (m_event->isInUse()) + signaled = false; if (pData != nullptr) *static_cast(pData) = signaled; diff --git a/src/d3d11/d3d11_query.h b/src/d3d11/d3d11_query.h index 27ddefc87..873a3b4b4 100644 --- a/src/d3d11/d3d11_query.h +++ b/src/d3d11/d3d11_query.h @@ -1,6 +1,6 @@ #pragma once -#include "../dxvk/dxvk_event.h" +#include "../dxvk/dxvk_gpu_event.h" #include "../dxvk/dxvk_query.h" #include "../d3d10/d3d10_query.h" @@ -54,8 +54,8 @@ namespace dxvk { D3D11Device* const m_device; D3D11_QUERY_DESC m_desc; - Rc m_query = nullptr; - Rc m_event = nullptr; + Rc m_query = nullptr; + Rc m_event = nullptr; uint32_t m_revision = 0;