mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 10:24:12 +01:00
[dxvk] Added support for pipeline-related stat counters
This commit is contained in:
parent
561fa7440b
commit
9ef4168867
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
std::lock_guard<sync::Spinlock> lock(m_statLock);
|
||||
result.merge(m_statCounters);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user