mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-02 22:29:16 +01:00
[dxvk] Added query tracker
This commit is contained in:
parent
43200010c1
commit
7ddd2500d1
@ -82,6 +82,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkCommandList::reset() {
|
void DxvkCommandList::reset() {
|
||||||
|
m_queryTracker.reset();
|
||||||
m_stagingAlloc.reset();
|
m_stagingAlloc.reset();
|
||||||
m_descAlloc.reset();
|
m_descAlloc.reset();
|
||||||
m_resources.reset();
|
m_resources.reset();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "dxvk_lifetime.h"
|
#include "dxvk_lifetime.h"
|
||||||
#include "dxvk_limits.h"
|
#include "dxvk_limits.h"
|
||||||
#include "dxvk_pipelayout.h"
|
#include "dxvk_pipelayout.h"
|
||||||
#include "dxvk_query_pool.h"
|
#include "dxvk_query_tracker.h"
|
||||||
#include "dxvk_staging.h"
|
#include "dxvk_staging.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
@ -81,8 +81,19 @@ namespace dxvk {
|
|||||||
* finished executing on the GPU.
|
* finished executing on the GPU.
|
||||||
* \param [in] queries The query range
|
* \param [in] queries The query range
|
||||||
*/
|
*/
|
||||||
void trackQueryRange(const DxvkQueryRange& queries) {
|
void trackQueryRange(DxvkQueryRange&& queries) {
|
||||||
m_queryRanges.push_back(queries);
|
m_queryTracker.trackQueryRange(std::move(queries));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Writes back query results
|
||||||
|
*
|
||||||
|
* Uses the query range to write back query data
|
||||||
|
* after the command list has finished executing
|
||||||
|
* on the GPU.
|
||||||
|
*/
|
||||||
|
void writeQueryData() {
|
||||||
|
m_queryTracker.writeQueryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,6 +106,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
||||||
VkDescriptorSet allocateDescriptorSet(
|
VkDescriptorSet allocateDescriptorSet(
|
||||||
VkDescriptorSetLayout descriptorLayout) {
|
VkDescriptorSetLayout descriptorLayout) {
|
||||||
return m_descAlloc.alloc(descriptorLayout);
|
return m_descAlloc.alloc(descriptorLayout);
|
||||||
@ -473,8 +485,7 @@ namespace dxvk {
|
|||||||
DxvkLifetimeTracker m_resources;
|
DxvkLifetimeTracker m_resources;
|
||||||
DxvkDescriptorAlloc m_descAlloc;
|
DxvkDescriptorAlloc m_descAlloc;
|
||||||
DxvkStagingAlloc m_stagingAlloc;
|
DxvkStagingAlloc m_stagingAlloc;
|
||||||
|
DxvkQueryTracker m_queryTracker;
|
||||||
std::vector<DxvkQueryRange> m_queryRanges;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,6 +58,10 @@ namespace dxvk {
|
|||||||
this->renderPassEnd();
|
this->renderPassEnd();
|
||||||
this->endActiveQueries();
|
this->endActiveQueries();
|
||||||
|
|
||||||
|
this->trackQueryPool(m_queryPools[VK_QUERY_TYPE_OCCLUSION]);
|
||||||
|
this->trackQueryPool(m_queryPools[VK_QUERY_TYPE_PIPELINE_STATISTICS]);
|
||||||
|
this->trackQueryPool(m_queryPools[VK_QUERY_TYPE_TIMESTAMP]);
|
||||||
|
|
||||||
m_cmd->endRecording();
|
m_cmd->endRecording();
|
||||||
return std::exchange(m_cmd, nullptr);
|
return std::exchange(m_cmd, nullptr);
|
||||||
}
|
}
|
||||||
@ -1634,6 +1638,9 @@ namespace dxvk {
|
|||||||
queryHandle = queryPool->allocQuery(query);
|
queryHandle = queryPool->allocQuery(query);
|
||||||
|
|
||||||
if (queryHandle.queryPool == VK_NULL_HANDLE) {
|
if (queryHandle.queryPool == VK_NULL_HANDLE) {
|
||||||
|
if (queryPool != nullptr)
|
||||||
|
this->trackQueryPool(queryPool);
|
||||||
|
|
||||||
m_queryPools[queryType] = m_device->createQueryPool(queryType, MaxNumQueryCountPerPool);
|
m_queryPools[queryType] = m_device->createQueryPool(queryType, MaxNumQueryCountPerPool);
|
||||||
queryPool = m_queryPools[queryType];
|
queryPool = m_queryPools[queryType];
|
||||||
|
|
||||||
@ -1652,6 +1659,16 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkContext::trackQueryPool(const Rc<DxvkQueryPool>& pool) {
|
||||||
|
if (pool != nullptr) {
|
||||||
|
DxvkQueryRange range = pool->getActiveQueryRange();
|
||||||
|
|
||||||
|
if (range.queryCount > 0)
|
||||||
|
m_cmd->trackQueryRange(std::move(range));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::beginActiveQueries() {
|
void DxvkContext::beginActiveQueries() {
|
||||||
for (const DxvkQueryRevision& query : m_activeQueries) {
|
for (const DxvkQueryRevision& query : m_activeQueries) {
|
||||||
DxvkQueryHandle handle = this->allocQuery(query);
|
DxvkQueryHandle handle = this->allocQuery(query);
|
||||||
|
@ -612,6 +612,9 @@ namespace dxvk {
|
|||||||
void resetQueryPool(
|
void resetQueryPool(
|
||||||
const Rc<DxvkQueryPool>& pool);
|
const Rc<DxvkQueryPool>& pool);
|
||||||
|
|
||||||
|
void trackQueryPool(
|
||||||
|
const Rc<DxvkQueryPool>& pool);
|
||||||
|
|
||||||
void beginActiveQueries();
|
void beginActiveQueries();
|
||||||
|
|
||||||
void endActiveQueries();
|
void endActiveQueries();
|
||||||
|
@ -91,4 +91,16 @@ namespace dxvk {
|
|||||||
m_queryRangeLength = 0;
|
m_queryRangeLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DxvkQueryRange DxvkQueryPool::getActiveQueryRange() {
|
||||||
|
DxvkQueryRange result;
|
||||||
|
result.queryPool = this;
|
||||||
|
result.queryIndex = m_queryRangeOffset;
|
||||||
|
result.queryCount = m_queryRangeLength;
|
||||||
|
|
||||||
|
m_queryRangeOffset += m_queryRangeLength;
|
||||||
|
m_queryRangeLength = 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -75,6 +75,16 @@ namespace dxvk {
|
|||||||
void reset(
|
void reset(
|
||||||
const Rc<DxvkCommandList>& cmd);
|
const Rc<DxvkCommandList>& cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retrieves active query range
|
||||||
|
*
|
||||||
|
* This will also move the beginning of the
|
||||||
|
* new active query range to the end of the
|
||||||
|
* current active query range.
|
||||||
|
* \returns Active query range
|
||||||
|
*/
|
||||||
|
DxvkQueryRange getActiveQueryRange();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
|
24
src/dxvk/dxvk_query_tracker.cpp
Normal file
24
src/dxvk/dxvk_query_tracker.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "dxvk_query_tracker.h"
|
||||||
|
|
||||||
|
namespace dxvk {
|
||||||
|
|
||||||
|
DxvkQueryTracker:: DxvkQueryTracker() { }
|
||||||
|
DxvkQueryTracker::~DxvkQueryTracker() { }
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkQueryTracker::trackQueryRange(DxvkQueryRange&& queryRange) {
|
||||||
|
m_queries.push_back(std::move(queryRange));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkQueryTracker::writeQueryData() {
|
||||||
|
for (const DxvkQueryRange& curr : m_queries)
|
||||||
|
curr.queryPool->getData(curr.queryIndex, curr.queryCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkQueryTracker::reset() {
|
||||||
|
m_queries.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
45
src/dxvk/dxvk_query_tracker.h
Normal file
45
src/dxvk/dxvk_query_tracker.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dxvk_query_pool.h"
|
||||||
|
|
||||||
|
namespace dxvk {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Query tracker
|
||||||
|
*/
|
||||||
|
class DxvkQueryTracker {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DxvkQueryTracker();
|
||||||
|
~DxvkQueryTracker();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Adds a query range to track
|
||||||
|
* \param [in] queryRange The query range
|
||||||
|
*/
|
||||||
|
void trackQueryRange(DxvkQueryRange&& queryRange);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Fetches query data
|
||||||
|
*
|
||||||
|
* Retrieves query data from the query pools
|
||||||
|
* and writes it back to the query objects.
|
||||||
|
*/
|
||||||
|
void writeQueryData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Resets query tracker
|
||||||
|
*
|
||||||
|
* Releases all query ranges from the tracker.
|
||||||
|
* Call this after writing back the query data.
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<DxvkQueryRange> m_queries;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -56,6 +56,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (entry.fence != nullptr) {
|
if (entry.fence != nullptr) {
|
||||||
entry.fence->wait(std::numeric_limits<uint64_t>::max());
|
entry.fence->wait(std::numeric_limits<uint64_t>::max());
|
||||||
|
|
||||||
|
entry.cmdList->writeQueryData();
|
||||||
entry.cmdList->reset();
|
entry.cmdList->reset();
|
||||||
m_device->recycleCommandList(entry.cmdList);
|
m_device->recycleCommandList(entry.cmdList);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ dxvk_src = files([
|
|||||||
'dxvk_pipemanager.cpp',
|
'dxvk_pipemanager.cpp',
|
||||||
'dxvk_query.cpp',
|
'dxvk_query.cpp',
|
||||||
'dxvk_query_pool.cpp',
|
'dxvk_query_pool.cpp',
|
||||||
|
'dxvk_query_tracker.cpp',
|
||||||
'dxvk_queue.cpp',
|
'dxvk_queue.cpp',
|
||||||
'dxvk_renderpass.cpp',
|
'dxvk_renderpass.cpp',
|
||||||
'dxvk_resource.cpp',
|
'dxvk_resource.cpp',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user