mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-13 19:29:14 +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(
|
||||
VkQueryType type,
|
||||
VkQueryControlFlags flags)
|
||||
: m_type(type), m_flags(flags) {
|
||||
VkQueryControlFlags 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() {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
|
@ -81,6 +81,7 @@ namespace dxvk {
|
||||
VkQueryPool queryPool = VK_NULL_HANDLE;
|
||||
uint32_t queryId = 0;
|
||||
VkQueryControlFlags flags = 0;
|
||||
uint32_t index = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -91,12 +92,13 @@ namespace dxvk {
|
||||
* submissions, we need to
|
||||
*/
|
||||
class DxvkQuery : public RcObject {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DxvkQuery(
|
||||
VkQueryType type,
|
||||
VkQueryControlFlags flags);
|
||||
VkQueryControlFlags flags,
|
||||
uint32_t index = ~0u);
|
||||
~DxvkQuery();
|
||||
|
||||
/**
|
||||
@ -117,6 +119,24 @@ namespace dxvk {
|
||||
VkQueryControlFlags flags() const {
|
||||
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
|
||||
@ -188,6 +208,7 @@ namespace dxvk {
|
||||
|
||||
const VkQueryType m_type;
|
||||
const VkQueryControlFlags m_flags;
|
||||
const uint32_t m_index;
|
||||
|
||||
std::mutex m_mutex;
|
||||
|
||||
|
@ -44,14 +44,8 @@ namespace dxvk {
|
||||
const DxvkQueryRevision& query) {
|
||||
m_activeQueries.push_back(query);
|
||||
|
||||
if (m_activeTypes & getDxvkQueryTypeBit(query.query->type())) {
|
||||
DxvkQueryHandle handle = this->allocQuery(cmd, query);
|
||||
|
||||
cmd->cmdBeginQuery(
|
||||
handle.queryPool,
|
||||
handle.queryId,
|
||||
handle.flags);
|
||||
}
|
||||
if (m_activeTypes & getDxvkQueryTypeBit(query.query->type()))
|
||||
this->beginVulkanQuery(cmd, query);
|
||||
}
|
||||
|
||||
|
||||
@ -69,13 +63,8 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
if (iter != m_activeQueries.end()) {
|
||||
if (m_activeTypes & getDxvkQueryTypeBit(iter->query->type())) {
|
||||
DxvkQueryHandle handle = iter->query->getHandle();
|
||||
|
||||
cmd->cmdEndQuery(
|
||||
handle.queryPool,
|
||||
handle.queryId);
|
||||
}
|
||||
if (m_activeTypes & getDxvkQueryTypeBit(iter->query->type()))
|
||||
this->endVulkanQuery(cmd, query);
|
||||
|
||||
m_activeQueries.erase(iter);
|
||||
}
|
||||
@ -88,14 +77,8 @@ namespace dxvk {
|
||||
m_activeTypes |= getDxvkQueryTypeBit(type);
|
||||
|
||||
for (const DxvkQueryRevision& query : m_activeQueries) {
|
||||
if (type == query.query->type()) {
|
||||
DxvkQueryHandle handle = this->allocQuery(cmd, query);
|
||||
|
||||
cmd->cmdBeginQuery(
|
||||
handle.queryPool,
|
||||
handle.queryId,
|
||||
handle.flags);
|
||||
}
|
||||
if (type == query.query->type())
|
||||
this->beginVulkanQuery(cmd, query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,13 +89,8 @@ namespace dxvk {
|
||||
m_activeTypes &= ~getDxvkQueryTypeBit(type);
|
||||
|
||||
for (const DxvkQueryRevision& query : m_activeQueries) {
|
||||
if (type == query.query->type()) {
|
||||
DxvkQueryHandle handle = query.query->getHandle();
|
||||
|
||||
cmd->cmdEndQuery(
|
||||
handle.queryPool,
|
||||
handle.queryId);
|
||||
}
|
||||
if (type == query.query->type())
|
||||
this->endVulkanQuery(cmd, query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
switch (type) {
|
||||
case VK_QUERY_TYPE_OCCLUSION:
|
||||
|
@ -108,6 +108,14 @@ namespace dxvk {
|
||||
const Rc<DxvkCommandList>& cmd,
|
||||
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(
|
||||
VkQueryType type);
|
||||
|
||||
|
@ -54,6 +54,7 @@ namespace dxvk {
|
||||
result.queryPool = m_queryPool;
|
||||
result.queryId = queryIndex;
|
||||
result.flags = query.query->flags();
|
||||
result.index = query.query->index();
|
||||
|
||||
query.query->associateQuery(query.revision, result);
|
||||
m_queries.at(queryIndex) = query;
|
||||
|
Loading…
x
Reference in New Issue
Block a user