From ea9e8127985c7417a0b7dfe816c1d2eb52b66a93 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 10 Sep 2018 23:07:51 +0200 Subject: [PATCH] [dxvk] Introduce new 'Created' state for queries New initial state for queries. D3D11 returns an error when trying to retrieve data from a query in this state, rather than S_FALSE or S_OK. --- src/d3d11/d3d11_query.cpp | 12 +++++++++--- src/dxvk/dxvk_query.h | 11 ++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/d3d11/d3d11_query.cpp b/src/d3d11/d3d11_query.cpp index 4f8a6ca9a..c51cf5284 100644 --- a/src/d3d11/d3d11_query.cpp +++ b/src/d3d11/d3d11_query.cpp @@ -201,9 +201,15 @@ namespace dxvk { } else { DxvkQueryData queryData = {}; - if (m_query != nullptr - && m_query->getData(queryData) != DxvkQueryStatus::Available) - return S_FALSE; + if (m_query != nullptr) { + DxvkQueryStatus status = m_query->getData(queryData); + + if (status == DxvkQueryStatus::Created) + return DXGI_ERROR_INVALID_CALL; + + if (status != DxvkQueryStatus::Available) + return S_FALSE; + } if (pData == nullptr) return S_OK; diff --git a/src/dxvk/dxvk_query.h b/src/dxvk/dxvk_query.h index bf4fc410e..4f735b7f8 100644 --- a/src/dxvk/dxvk_query.h +++ b/src/dxvk/dxvk_query.h @@ -13,10 +13,11 @@ namespace dxvk { * the current status of the query. */ enum class DxvkQueryStatus : uint32_t { - Reset = 0, ///< Query is reset - Active = 1, ///< Query is being recorded - Pending = 2, ///< Query has been recorded - Available = 3, ///< Query results can be retrieved + Created = 0, ///< Query was just created + Reset = 1, ///< Query is reset + Active = 2, ///< Query is being recorded + Pending = 3, ///< Query has been recorded + Available = 4, ///< Query results can be retrieved }; /** @@ -190,7 +191,7 @@ namespace dxvk { std::mutex m_mutex; - DxvkQueryStatus m_status = DxvkQueryStatus::Reset; + DxvkQueryStatus m_status = DxvkQueryStatus::Created; DxvkQueryData m_data = {}; DxvkQueryHandle m_handle;