diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index f214e3e5..b0325f4d 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -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; } diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index 63e48119..258b0301 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -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; } diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index ad266601..335589d2 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -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: diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index c4e101e1..eed988f2 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -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) { diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index 57d6b34c..47e3f6ed 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -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 lock(m_statLock); - result.merge(m_statCounters); - } - + std::lock_guard lock(m_statLock); + result.merge(m_statCounters); return result; } diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index da5e6871..c61cc898 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -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; } diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index a6c82b5e..5bfa2bee 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -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: diff --git a/src/dxvk/dxvk_pipecache.cpp b/src/dxvk/dxvk_pipecache.cpp index 2ef3b68c..2dbffc9e 100644 --- a/src/dxvk/dxvk_pipecache.cpp +++ b/src/dxvk/dxvk_pipecache.cpp @@ -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; diff --git a/src/dxvk/dxvk_pipecache.h b/src/dxvk/dxvk_pipecache.h index ab8918fb..e7058199 100644 --- a/src/dxvk/dxvk_pipecache.h +++ b/src/dxvk/dxvk_pipecache.h @@ -42,6 +42,12 @@ namespace dxvk { */ void update(); + /** + * \brief Queries pipeline cache size + * \returns Cache size, in bytes + */ + size_t getCacheSize() const; + private: Rc m_vkd;