[dxvk] Added support for pipeline-related stat counters

This commit is contained in:
Philip Rebohle 2018-04-03 15:52:39 +02:00
parent 561fa7440b
commit 9ef4168867
9 changed files with 38 additions and 13 deletions

View File

@ -63,9 +63,9 @@ namespace dxvk {
* Retrieves some info about per-command list
* statistics, such as the number of draw calls
* or the number of pipelines compiled.
* \returns Read-only reference to stat counters
* \returns Reference to stat counters
*/
const DxvkStatCounters& statCounters() const {
DxvkStatCounters& statCounters() {
return m_statCounters;
}

View File

@ -40,8 +40,8 @@ namespace dxvk {
VkPipeline DxvkComputePipeline::getPipelineHandle(
const DxvkComputePipelineStateInfo& state) {
const DxvkComputePipelineStateInfo& state,
DxvkStatCounters& stats) {
for (const PipelineStruct& pair : m_pipelines) {
if (pair.stateVector == state)
return pair.pipeline;
@ -52,6 +52,8 @@ namespace dxvk {
if (m_basePipeline == VK_NULL_HANDLE)
m_basePipeline = pipeline;
stats.addCtr(DxvkStatCounter::PipeCountCompute, 1);
return pipeline;
}

View File

@ -5,6 +5,7 @@
#include "dxvk_pipelayout.h"
#include "dxvk_resource.h"
#include "dxvk_shader.h"
#include "dxvk_stats.h"
namespace dxvk {
@ -58,7 +59,8 @@ namespace dxvk {
* \returns Pipeline handle
*/
VkPipeline getPipelineHandle(
const DxvkComputePipelineStateInfo& state);
const DxvkComputePipelineStateInfo& state,
DxvkStatCounters& stats);
private:

View File

@ -1403,7 +1403,7 @@ namespace dxvk {
m_flags.clr(DxvkContextFlag::CpDirtyPipelineState);
m_cpActivePipeline = m_state.cp.pipeline != nullptr
? m_state.cp.pipeline->getPipelineHandle(m_state.cp.state)
? m_state.cp.pipeline->getPipelineHandle(m_state.cp.state, m_cmd->statCounters())
: VK_NULL_HANDLE;
if (m_cpActivePipeline != VK_NULL_HANDLE) {
@ -1448,7 +1448,7 @@ namespace dxvk {
m_state.gp.state.ilBindings[i].stride = 0;
m_gpActivePipeline = m_state.gp.pipeline != nullptr
? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state)
? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state, m_cmd->statCounters())
: VK_NULL_HANDLE;
if (m_gpActivePipeline != VK_NULL_HANDLE) {

View File

@ -184,11 +184,10 @@ namespace dxvk {
DxvkStatCounters result;
result.setCtr(DxvkStatCounter::MemoryAllocated, mem.memoryAllocated);
result.setCtr(DxvkStatCounter::MemoryUsed, mem.memoryUsed);
result.setCtr(DxvkStatCounter::PipeCacheSize, m_pipelineCache->getCacheSize());
{ std::lock_guard<sync::Spinlock> lock(m_statLock);
result.merge(m_statCounters);
}
std::lock_guard<sync::Spinlock> lock(m_statLock);
result.merge(m_statCounters);
return result;
}

View File

@ -73,7 +73,8 @@ namespace dxvk {
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state) {
const DxvkGraphicsPipelineStateInfo& state,
DxvkStatCounters& stats) {
for (const PipelineStruct& pair : m_pipelines) {
if (pair.stateVector == state)
@ -88,6 +89,8 @@ namespace dxvk {
if (m_basePipeline == VK_NULL_HANDLE)
m_basePipeline = pipeline;
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
return pipeline;
}

View File

@ -8,6 +8,7 @@
#include "dxvk_pipelayout.h"
#include "dxvk_resource.h"
#include "dxvk_shader.h"
#include "dxvk_stats.h"
namespace dxvk {
@ -117,10 +118,12 @@ namespace dxvk {
* Retrieves a pipeline handle for the given pipeline
* state. If necessary, a new pipeline will be created.
* \param [in] state Pipeline state vector
* \param [in,out] stats Stat counter
* \returns Pipeline handle
*/
VkPipeline getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state);
const DxvkGraphicsPipelineStateInfo& state,
DxvkStatCounters& stats);
private:

View File

@ -47,6 +47,16 @@ namespace dxvk {
}
size_t DxvkPipelineCache::getCacheSize() const {
size_t cacheSize = 0;
m_vkd->vkGetPipelineCacheData(
m_vkd->device(), m_handle, &cacheSize, nullptr);
return cacheSize;
}
void DxvkPipelineCache::runThread() {
uint32_t prevUpdateCounter = 0;
uint32_t currUpdateCounter = 0;

View File

@ -42,6 +42,12 @@ namespace dxvk {
*/
void update();
/**
* \brief Queries pipeline cache size
* \returns Cache size, in bytes
*/
size_t getCacheSize() const;
private:
Rc<vk::DeviceFn> m_vkd;