mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[dxvk] Add basic support for indexed queries
This commit is contained in:
parent
76d917df20
commit
3435702719
@ -4,8 +4,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkQuery::DxvkQuery(
|
DxvkQuery::DxvkQuery(
|
||||||
VkQueryType type,
|
VkQueryType type,
|
||||||
VkQueryControlFlags flags)
|
VkQueryControlFlags flags,
|
||||||
: m_type(type), m_flags(flags) {
|
uint32_t index)
|
||||||
|
: m_type (type),
|
||||||
|
m_flags (flags),
|
||||||
|
m_index (index) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,6 +18,11 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DxvkQuery::isIndexed() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t DxvkQuery::reset() {
|
uint32_t DxvkQuery::reset() {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ namespace dxvk {
|
|||||||
VkQueryPool queryPool = VK_NULL_HANDLE;
|
VkQueryPool queryPool = VK_NULL_HANDLE;
|
||||||
uint32_t queryId = 0;
|
uint32_t queryId = 0;
|
||||||
VkQueryControlFlags flags = 0;
|
VkQueryControlFlags flags = 0;
|
||||||
|
uint32_t index = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +97,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkQuery(
|
DxvkQuery(
|
||||||
VkQueryType type,
|
VkQueryType type,
|
||||||
VkQueryControlFlags flags);
|
VkQueryControlFlags flags,
|
||||||
|
uint32_t index = ~0u);
|
||||||
~DxvkQuery();
|
~DxvkQuery();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,6 +120,24 @@ namespace dxvk {
|
|||||||
return m_flags;
|
return m_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Query type index
|
||||||
|
*
|
||||||
|
* The query type index. Will be undefined if the
|
||||||
|
* query type is not indexed. Not to be confused
|
||||||
|
* with the query index within the query pool.
|
||||||
|
* \returns Query type index
|
||||||
|
*/
|
||||||
|
uint32_t index() const {
|
||||||
|
return m_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checks whether the query type is indexed
|
||||||
|
* \returns \c true if the query type is indexed
|
||||||
|
*/
|
||||||
|
bool isIndexed() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Resets the query object
|
* \brief Resets the query object
|
||||||
*
|
*
|
||||||
@ -188,6 +208,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
const VkQueryType m_type;
|
const VkQueryType m_type;
|
||||||
const VkQueryControlFlags m_flags;
|
const VkQueryControlFlags m_flags;
|
||||||
|
const uint32_t m_index;
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
|
||||||
|
@ -44,14 +44,8 @@ namespace dxvk {
|
|||||||
const DxvkQueryRevision& query) {
|
const DxvkQueryRevision& query) {
|
||||||
m_activeQueries.push_back(query);
|
m_activeQueries.push_back(query);
|
||||||
|
|
||||||
if (m_activeTypes & getDxvkQueryTypeBit(query.query->type())) {
|
if (m_activeTypes & getDxvkQueryTypeBit(query.query->type()))
|
||||||
DxvkQueryHandle handle = this->allocQuery(cmd, query);
|
this->beginVulkanQuery(cmd, query);
|
||||||
|
|
||||||
cmd->cmdBeginQuery(
|
|
||||||
handle.queryPool,
|
|
||||||
handle.queryId,
|
|
||||||
handle.flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,13 +63,8 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iter != m_activeQueries.end()) {
|
if (iter != m_activeQueries.end()) {
|
||||||
if (m_activeTypes & getDxvkQueryTypeBit(iter->query->type())) {
|
if (m_activeTypes & getDxvkQueryTypeBit(iter->query->type()))
|
||||||
DxvkQueryHandle handle = iter->query->getHandle();
|
this->endVulkanQuery(cmd, query);
|
||||||
|
|
||||||
cmd->cmdEndQuery(
|
|
||||||
handle.queryPool,
|
|
||||||
handle.queryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_activeQueries.erase(iter);
|
m_activeQueries.erase(iter);
|
||||||
}
|
}
|
||||||
@ -88,14 +77,8 @@ namespace dxvk {
|
|||||||
m_activeTypes |= getDxvkQueryTypeBit(type);
|
m_activeTypes |= getDxvkQueryTypeBit(type);
|
||||||
|
|
||||||
for (const DxvkQueryRevision& query : m_activeQueries) {
|
for (const DxvkQueryRevision& query : m_activeQueries) {
|
||||||
if (type == query.query->type()) {
|
if (type == query.query->type())
|
||||||
DxvkQueryHandle handle = this->allocQuery(cmd, query);
|
this->beginVulkanQuery(cmd, query);
|
||||||
|
|
||||||
cmd->cmdBeginQuery(
|
|
||||||
handle.queryPool,
|
|
||||||
handle.queryId,
|
|
||||||
handle.flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,13 +89,8 @@ namespace dxvk {
|
|||||||
m_activeTypes &= ~getDxvkQueryTypeBit(type);
|
m_activeTypes &= ~getDxvkQueryTypeBit(type);
|
||||||
|
|
||||||
for (const DxvkQueryRevision& query : m_activeQueries) {
|
for (const DxvkQueryRevision& query : m_activeQueries) {
|
||||||
if (type == query.query->type()) {
|
if (type == query.query->type())
|
||||||
DxvkQueryHandle handle = query.query->getHandle();
|
this->endVulkanQuery(cmd, query);
|
||||||
|
|
||||||
cmd->cmdEndQuery(
|
|
||||||
handle.queryPool,
|
|
||||||
handle.queryId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +114,44 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkQueryManager::beginVulkanQuery(
|
||||||
|
const Rc<DxvkCommandList>& cmd,
|
||||||
|
const DxvkQueryRevision& query) {
|
||||||
|
DxvkQueryHandle handle = this->allocQuery(cmd, query);
|
||||||
|
|
||||||
|
if (query.query->isIndexed()) {
|
||||||
|
cmd->cmdBeginQueryIndexed(
|
||||||
|
handle.queryPool,
|
||||||
|
handle.queryId,
|
||||||
|
handle.flags,
|
||||||
|
handle.index);
|
||||||
|
} else {
|
||||||
|
cmd->cmdBeginQuery(
|
||||||
|
handle.queryPool,
|
||||||
|
handle.queryId,
|
||||||
|
handle.flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkQueryManager::endVulkanQuery(
|
||||||
|
const Rc<DxvkCommandList>& cmd,
|
||||||
|
const DxvkQueryRevision& query) {
|
||||||
|
DxvkQueryHandle handle = query.query->getHandle();
|
||||||
|
|
||||||
|
if (query.query->isIndexed()) {
|
||||||
|
cmd->cmdEndQueryIndexed(
|
||||||
|
handle.queryPool,
|
||||||
|
handle.queryId,
|
||||||
|
handle.index);
|
||||||
|
} else {
|
||||||
|
cmd->cmdEndQuery(
|
||||||
|
handle.queryPool,
|
||||||
|
handle.queryId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkQueryPool>& DxvkQueryManager::getQueryPool(VkQueryType type) {
|
Rc<DxvkQueryPool>& DxvkQueryManager::getQueryPool(VkQueryType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VK_QUERY_TYPE_OCCLUSION:
|
case VK_QUERY_TYPE_OCCLUSION:
|
||||||
|
@ -108,6 +108,14 @@ namespace dxvk {
|
|||||||
const Rc<DxvkCommandList>& cmd,
|
const Rc<DxvkCommandList>& cmd,
|
||||||
const Rc<DxvkQueryPool>& pool);
|
const Rc<DxvkQueryPool>& pool);
|
||||||
|
|
||||||
|
void beginVulkanQuery(
|
||||||
|
const Rc<DxvkCommandList>& cmd,
|
||||||
|
const DxvkQueryRevision& query);
|
||||||
|
|
||||||
|
void endVulkanQuery(
|
||||||
|
const Rc<DxvkCommandList>& cmd,
|
||||||
|
const DxvkQueryRevision& query);
|
||||||
|
|
||||||
Rc<DxvkQueryPool>& getQueryPool(
|
Rc<DxvkQueryPool>& getQueryPool(
|
||||||
VkQueryType type);
|
VkQueryType type);
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ namespace dxvk {
|
|||||||
result.queryPool = m_queryPool;
|
result.queryPool = m_queryPool;
|
||||||
result.queryId = queryIndex;
|
result.queryId = queryIndex;
|
||||||
result.flags = query.query->flags();
|
result.flags = query.query->flags();
|
||||||
|
result.index = query.query->index();
|
||||||
|
|
||||||
query.query->associateQuery(query.revision, result);
|
query.query->associateQuery(query.revision, result);
|
||||||
m_queries.at(queryIndex) = query;
|
m_queries.at(queryIndex) = query;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user