1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[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.
This commit is contained in:
Philip Rebohle 2018-09-11 12:35:53 +02:00
parent f9add97a07
commit 1127a344dc
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 28 additions and 19 deletions

View File

@ -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();
}

View File

@ -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<DxvkCommandList>& 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<DxvkCommandList>& 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;
}
}
}

View File

@ -8,8 +8,6 @@
namespace dxvk {
using DxvkQueryTypeFlags = Flags<VkQueryType>;
/**
* \brief Query manager
*
@ -71,7 +69,7 @@ namespace dxvk {
*/
void beginQueries(
const Rc<DxvkCommandList>& cmd,
DxvkQueryTypeFlags types);
VkQueryType type);
/**
* \brief Ends active queries
@ -82,7 +80,7 @@ namespace dxvk {
*/
void endQueries(
const Rc<DxvkCommandList>& cmd,
DxvkQueryTypeFlags types);
VkQueryType type);
/**
* \brief Tracks query pools
@ -98,7 +96,7 @@ namespace dxvk {
const Rc<vk::DeviceFn> m_vkd;
DxvkQueryTypeFlags m_activeTypes;
uint32_t m_activeTypes = 0;
Rc<DxvkQueryPool> m_occlusion;
Rc<DxvkQueryPool> m_pipeStats;
@ -113,6 +111,9 @@ namespace dxvk {
Rc<DxvkQueryPool>& getQueryPool(
VkQueryType type);
static uint32_t getDxvkQueryTypeBit(
VkQueryType type);
};
}