From 1127a344dc77ac041182fedb5986a8ef505676ab Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 11 Sep 2018 12:35:53 +0200 Subject: [PATCH] [dxvk] Fix query type enablement in query manager We cannot use query types as flag indices, since query types added in the future may have gretaer enum values than 32. --- src/dxvk/dxvk_context.cpp | 10 ++++------ src/dxvk/dxvk_query_manager.cpp | 26 ++++++++++++++++++-------- src/dxvk/dxvk_query_manager.h | 11 ++++++----- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 3bb0d4d75..e8383f0db 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1797,9 +1797,8 @@ namespace dxvk { m_state.om.renderPassOps); // Begin occlusion queries - m_queries.beginQueries(m_cmd, { - VK_QUERY_TYPE_OCCLUSION, - VK_QUERY_TYPE_PIPELINE_STATISTICS }); + m_queries.beginQueries(m_cmd, VK_QUERY_TYPE_OCCLUSION); + m_queries.beginQueries(m_cmd, VK_QUERY_TYPE_PIPELINE_STATISTICS); } } @@ -1811,9 +1810,8 @@ namespace dxvk { if (m_flags.test(DxvkContextFlag::GpRenderPassBound)) { m_flags.clr(DxvkContextFlag::GpRenderPassBound); - m_queries.endQueries(m_cmd, { - VK_QUERY_TYPE_OCCLUSION, - VK_QUERY_TYPE_PIPELINE_STATISTICS }); + m_queries.endQueries(m_cmd, VK_QUERY_TYPE_OCCLUSION); + m_queries.endQueries(m_cmd, VK_QUERY_TYPE_PIPELINE_STATISTICS); this->renderPassUnbindFramebuffer(); } diff --git a/src/dxvk/dxvk_query_manager.cpp b/src/dxvk/dxvk_query_manager.cpp index aab3d4717..a1a28d1cf 100644 --- a/src/dxvk/dxvk_query_manager.cpp +++ b/src/dxvk/dxvk_query_manager.cpp @@ -44,7 +44,7 @@ namespace dxvk { const DxvkQueryRevision& query) { m_activeQueries.push_back(query); - if (m_activeTypes.test(query.query->type())) { + if (m_activeTypes & getDxvkQueryTypeBit(query.query->type())) { DxvkQueryHandle handle = this->allocQuery(cmd, query); cmd->cmdBeginQuery( @@ -69,7 +69,7 @@ namespace dxvk { } if (iter != m_activeQueries.end()) { - if (m_activeTypes.test(iter->query->type())) { + if (m_activeTypes & getDxvkQueryTypeBit(iter->query->type())) { DxvkQueryHandle handle = iter->query->getHandle(); cmd->cmdEndQuery( @@ -84,11 +84,11 @@ namespace dxvk { void DxvkQueryManager::beginQueries( const Rc& cmd, - DxvkQueryTypeFlags types) { - m_activeTypes.set(types); + VkQueryType type) { + m_activeTypes |= getDxvkQueryTypeBit(type); for (const DxvkQueryRevision& query : m_activeQueries) { - if (types.test(query.query->type())) { + if (type == query.query->type()) { DxvkQueryHandle handle = this->allocQuery(cmd, query); cmd->cmdBeginQuery( @@ -102,11 +102,11 @@ namespace dxvk { void DxvkQueryManager::endQueries( const Rc& cmd, - DxvkQueryTypeFlags types) { - m_activeTypes.clr(types); + VkQueryType type) { + m_activeTypes &= ~getDxvkQueryTypeBit(type); for (const DxvkQueryRevision& query : m_activeQueries) { - if (types.test(query.query->type())) { + if (type == query.query->type()) { DxvkQueryHandle handle = query.query->getHandle(); cmd->cmdEndQuery( @@ -152,4 +152,14 @@ namespace dxvk { } } + + uint32_t DxvkQueryManager::getDxvkQueryTypeBit(VkQueryType type) { + switch (type) { + case VK_QUERY_TYPE_OCCLUSION: return 0x01; + case VK_QUERY_TYPE_PIPELINE_STATISTICS: return 0x02; + case VK_QUERY_TYPE_TIMESTAMP: return 0x04; + default: return 0; + } + } + } \ No newline at end of file diff --git a/src/dxvk/dxvk_query_manager.h b/src/dxvk/dxvk_query_manager.h index cccf05efa..5d8216f19 100644 --- a/src/dxvk/dxvk_query_manager.h +++ b/src/dxvk/dxvk_query_manager.h @@ -8,8 +8,6 @@ namespace dxvk { - using DxvkQueryTypeFlags = Flags; - /** * \brief Query manager * @@ -71,7 +69,7 @@ namespace dxvk { */ void beginQueries( const Rc& cmd, - DxvkQueryTypeFlags types); + VkQueryType type); /** * \brief Ends active queries @@ -82,7 +80,7 @@ namespace dxvk { */ void endQueries( const Rc& cmd, - DxvkQueryTypeFlags types); + VkQueryType type); /** * \brief Tracks query pools @@ -98,7 +96,7 @@ namespace dxvk { const Rc m_vkd; - DxvkQueryTypeFlags m_activeTypes; + uint32_t m_activeTypes = 0; Rc m_occlusion; Rc m_pipeStats; @@ -113,6 +111,9 @@ namespace dxvk { Rc& getQueryPool( VkQueryType type); + static uint32_t getDxvkQueryTypeBit( + VkQueryType type); + }; } \ No newline at end of file