[dxvk] Reintroduce stat counters

This commit is contained in:
Philip Rebohle 2018-04-03 11:03:57 +02:00
parent 4b44d3ce39
commit a5077952ea
3 changed files with 130 additions and 0 deletions

27
src/dxvk/dxvk_stats.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "dxvk_stats.h"
namespace dxvk {
DxvkStatCounters::DxvkStatCounters() {
this->reset();
}
DxvkStatCounters::~DxvkStatCounters() {
}
void DxvkStatCounters::merge(const DxvkStatCounters& other) {
for (size_t i = 0; i < m_counters.size(); i++) {
m_counters[i] += other.m_counters[i];
}
}
void DxvkStatCounters::reset() {
for (size_t i = 0; i < m_counters.size(); i++)
m_counters[i] = 0;
}
}

102
src/dxvk/dxvk_stats.h Normal file
View File

@ -0,0 +1,102 @@
#pragma once
#include "dxvk_include.h"
namespace dxvk {
/**
* \brief Named stat counters
*
* Enumerates available stat counters. Used
* thogether with \ref DxvkStatCounters.
*/
enum class DxvkStatCounter : uint32_t {
CmdDrawCalls, ///< Number of draw calls
CmdDispatchCalls, ///< Number of compute calls
CmdRenderPassCount, ///< Number of render passes
MemoryAllocationCount, ///< Number of memory allocations
MemoryAllocated, ///< Amount of memory allocated
MemoryUsed, ///< Amount of memory used
PipeCountGraphics, ///< Number of graphics pipelines
PipeCountCompute, ///< Number of compute pipelines
PipeCacheSize, ///< Pipeline cache size
QueueSubmitCount, ///< Number of command buffer submissions
QueuePresentCount, ///< Number of present calls / frames
NumCounters, ///< Number of counters available
};
/**
* \brief Stat counters
*
* Collects various statistics that may be
* useful to identify performance bottlenecks.
*/
class DxvkStatCounters {
public:
DxvkStatCounters();
~DxvkStatCounters();
/**
* \brief Retrieves a counter value
*
* \param [in] ctr The counter
* \returns Counter value
*/
uint32_t getCtr(DxvkStatCounter ctr) const {
return m_counters[uint32_t(ctr)];
}
/**
* \brief Sets a counter value
*
* \param [in] ctr The counter
* \param [in] val Counter value
*/
void setCtr(DxvkStatCounter ctr, uint32_t val) {
m_counters[uint32_t(ctr)] = val;
}
/**
* \brief Increments a counter value
*
* \param [in] ctr Counter to increment
* \param [in] val Number to add to counter value
*/
void addCtr(DxvkStatCounter ctr, uint32_t val) {
m_counters[uint32_t(ctr)] += val;
}
/**
* \brief Resets a counter
* \param [in] ctr The counter
*/
void clrCtr(DxvkStatCounter ctr) {
m_counters[uint32_t(ctr)] = 0;
}
/**
* \brief Merges counters
*
* Adds counter values from another set
* of counters to this set of counters.
* \param [in] other Counters to add
*/
void merge(const DxvkStatCounters& other);
/**
* \brief Resets counters
*
* Sets all counters to zero.
*/
void reset();
private:
std::array<uint32_t, uint32_t(DxvkStatCounter::NumCounters)> m_counters;
};
}

View File

@ -40,6 +40,7 @@ dxvk_src = files([
'dxvk_sampler.cpp',
'dxvk_shader.cpp',
'dxvk_staging.cpp',
'dxvk_stats.cpp',
'dxvk_surface.cpp',
'dxvk_swapchain.cpp',
'dxvk_sync.cpp',