1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-02 22:29:16 +01:00

[dxvk] Refactor pipeline stat counters

The stat counter struct no longer has to be passed to
the pipeline compiler function.

The new implementation uses atomic counters of the pipeline manager
rather than per-command list counters, which removes the need to
pass the counter structure to the compiler function.
This commit is contained in:
Philip Rebohle 2018-09-21 22:28:06 +02:00
parent 5410680401
commit 83447975ac
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
8 changed files with 41 additions and 16 deletions

View File

@ -45,8 +45,7 @@ namespace dxvk {
VkPipeline DxvkComputePipeline::getPipelineHandle( VkPipeline DxvkComputePipeline::getPipelineHandle(
const DxvkComputePipelineStateInfo& state, const DxvkComputePipelineStateInfo& state) {
DxvkStatCounters& stats) {
VkPipeline pipeline = VK_NULL_HANDLE; VkPipeline pipeline = VK_NULL_HANDLE;
{ std::lock_guard<sync::Spinlock> lock(m_mutex); { std::lock_guard<sync::Spinlock> lock(m_mutex);
@ -70,11 +69,11 @@ namespace dxvk {
// Add new pipeline to the set // Add new pipeline to the set
m_pipelines.push_back({ state, newPipeline }); m_pipelines.push_back({ state, newPipeline });
m_pipeMgr->m_numComputePipelines += 1;
if (m_basePipeline == VK_NULL_HANDLE) if (m_basePipeline == VK_NULL_HANDLE)
m_basePipeline = newPipeline; m_basePipeline = newPipeline;
stats.addCtr(DxvkStatCounter::PipeCountCompute, 1);
return newPipeline; return newPipeline;
} }
} }

View File

@ -61,8 +61,7 @@ namespace dxvk {
* \returns Pipeline handle * \returns Pipeline handle
*/ */
VkPipeline getPipelineHandle( VkPipeline getPipelineHandle(
const DxvkComputePipelineStateInfo& state, const DxvkComputePipelineStateInfo& state);
DxvkStatCounters& stats);
private: private:

View File

@ -2013,7 +2013,7 @@ namespace dxvk {
m_flags.clr(DxvkContextFlag::CpDirtyPipelineState); m_flags.clr(DxvkContextFlag::CpDirtyPipelineState);
m_cpActivePipeline = m_state.cp.pipeline != nullptr m_cpActivePipeline = m_state.cp.pipeline != nullptr
? m_state.cp.pipeline->getPipelineHandle(m_state.cp.state, m_cmd->statCounters()) ? m_state.cp.pipeline->getPipelineHandle(m_state.cp.state)
: VK_NULL_HANDLE; : VK_NULL_HANDLE;
if (m_cpActivePipeline != VK_NULL_HANDLE) { if (m_cpActivePipeline != VK_NULL_HANDLE) {
@ -2071,7 +2071,7 @@ namespace dxvk {
m_gpActivePipeline = m_state.gp.pipeline != nullptr && m_state.om.framebuffer != nullptr m_gpActivePipeline = m_state.gp.pipeline != nullptr && m_state.om.framebuffer != nullptr
? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state, ? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state,
m_state.om.framebuffer->getRenderPass(), m_cmd->statCounters()) m_state.om.framebuffer->getRenderPass())
: VK_NULL_HANDLE; : VK_NULL_HANDLE;
if (m_gpActivePipeline != VK_NULL_HANDLE) { if (m_gpActivePipeline != VK_NULL_HANDLE) {

View File

@ -198,10 +198,13 @@ namespace dxvk {
DxvkStatCounters DxvkDevice::getStatCounters() { DxvkStatCounters DxvkDevice::getStatCounters() {
DxvkMemoryStats mem = m_memory->getMemoryStats(); DxvkMemoryStats mem = m_memory->getMemoryStats();
DxvkPipelineCount pipe = m_pipelineManager->getPipelineCount();
DxvkStatCounters result; DxvkStatCounters result;
result.setCtr(DxvkStatCounter::MemoryAllocated, mem.memoryAllocated); result.setCtr(DxvkStatCounter::MemoryAllocated, mem.memoryAllocated);
result.setCtr(DxvkStatCounter::MemoryUsed, mem.memoryUsed); result.setCtr(DxvkStatCounter::MemoryUsed, mem.memoryUsed);
result.setCtr(DxvkStatCounter::PipeCountGraphics, pipe.numGraphicsPipelines);
result.setCtr(DxvkStatCounter::PipeCountCompute, pipe.numComputePipelines);
std::lock_guard<sync::Spinlock> lock(m_statLock); std::lock_guard<sync::Spinlock> lock(m_statLock);
result.merge(m_statCounters); result.merge(m_statCounters);

View File

@ -82,8 +82,7 @@ namespace dxvk {
VkPipeline DxvkGraphicsPipeline::getPipelineHandle( VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state, const DxvkGraphicsPipelineStateInfo& state,
const DxvkRenderPass& renderPass, const DxvkRenderPass& renderPass) {
DxvkStatCounters& stats) {
VkRenderPass renderPassHandle = renderPass.getDefaultHandle(); VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
{ std::lock_guard<sync::Spinlock> lock(m_mutex); { std::lock_guard<sync::Spinlock> lock(m_mutex);
@ -120,8 +119,7 @@ namespace dxvk {
// Add new pipeline to the set // Add new pipeline to the set
m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle); m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle);
m_pipeMgr->m_numGraphicsPipelines += 1;
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
} }
// Use the new pipeline as the base pipeline for derivative pipelines // Use the new pipeline as the base pipeline for derivative pipelines

View File

@ -175,13 +175,11 @@ namespace dxvk {
* state. If necessary, a new pipeline will be created. * state. If necessary, a new pipeline will be created.
* \param [in] state Pipeline state vector * \param [in] state Pipeline state vector
* \param [in] renderPass The render pass * \param [in] renderPass The render pass
* \param [in,out] stats Stat counter
* \returns Pipeline handle * \returns Pipeline handle
*/ */
VkPipeline getPipelineHandle( VkPipeline getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state, const DxvkGraphicsPipelineStateInfo& state,
const DxvkRenderPass& renderPass, const DxvkRenderPass& renderPass);
DxvkStatCounters& stats);
private: private:

View File

@ -101,4 +101,12 @@ namespace dxvk {
return pipeline; return pipeline;
} }
DxvkPipelineCount DxvkPipelineManager::getPipelineCount() const {
DxvkPipelineCount result;
result.numComputePipelines = m_numComputePipelines.load();
result.numGraphicsPipelines = m_numGraphicsPipelines.load();
return result;
}
} }

View File

@ -8,6 +8,17 @@
namespace dxvk { namespace dxvk {
/**
* \brief Pipeline count
*
* Stores number of graphics and
* compute pipelines, individually.
*/
struct DxvkPipelineCount {
uint32_t numGraphicsPipelines;
uint32_t numComputePipelines;
};
/** /**
* \brief Compute pipeline key * \brief Compute pipeline key
* *
@ -95,11 +106,20 @@ namespace dxvk {
const Rc<DxvkShader>& gs, const Rc<DxvkShader>& gs,
const Rc<DxvkShader>& fs); const Rc<DxvkShader>& fs);
/**
* \brief Retrieves total pipeline count
* \returns Number of compute/graphics pipelines
*/
DxvkPipelineCount getPipelineCount() const;
private: private:
const DxvkDevice* m_device; const DxvkDevice* m_device;
Rc<DxvkPipelineCache> m_cache; Rc<DxvkPipelineCache> m_cache;
std::atomic<uint32_t> m_numComputePipelines = { 0 };
std::atomic<uint32_t> m_numGraphicsPipelines = { 0 };
std::mutex m_mutex; std::mutex m_mutex;
std::unordered_map< std::unordered_map<