mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 10:24:12 +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:
parent
5410680401
commit
83447975ac
@ -45,8 +45,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
VkPipeline DxvkComputePipeline::getPipelineHandle(
|
||||
const DxvkComputePipelineStateInfo& state,
|
||||
DxvkStatCounters& stats) {
|
||||
const DxvkComputePipelineStateInfo& state) {
|
||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
||||
|
||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||
@ -70,11 +69,11 @@ namespace dxvk {
|
||||
|
||||
// Add new pipeline to the set
|
||||
m_pipelines.push_back({ state, newPipeline });
|
||||
m_pipeMgr->m_numComputePipelines += 1;
|
||||
|
||||
if (m_basePipeline == VK_NULL_HANDLE)
|
||||
m_basePipeline = newPipeline;
|
||||
|
||||
stats.addCtr(DxvkStatCounter::PipeCountCompute, 1);
|
||||
return newPipeline;
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,7 @@ namespace dxvk {
|
||||
* \returns Pipeline handle
|
||||
*/
|
||||
VkPipeline getPipelineHandle(
|
||||
const DxvkComputePipelineStateInfo& state,
|
||||
DxvkStatCounters& stats);
|
||||
const DxvkComputePipelineStateInfo& state);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -2013,7 +2013,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_cmd->statCounters())
|
||||
? m_state.cp.pipeline->getPipelineHandle(m_state.cp.state)
|
||||
: 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_state.gp.pipeline->getPipelineHandle(m_state.gp.state,
|
||||
m_state.om.framebuffer->getRenderPass(), m_cmd->statCounters())
|
||||
m_state.om.framebuffer->getRenderPass())
|
||||
: VK_NULL_HANDLE;
|
||||
|
||||
if (m_gpActivePipeline != VK_NULL_HANDLE) {
|
||||
|
@ -198,10 +198,13 @@ namespace dxvk {
|
||||
|
||||
DxvkStatCounters DxvkDevice::getStatCounters() {
|
||||
DxvkMemoryStats mem = m_memory->getMemoryStats();
|
||||
DxvkPipelineCount pipe = m_pipelineManager->getPipelineCount();
|
||||
|
||||
DxvkStatCounters result;
|
||||
result.setCtr(DxvkStatCounter::MemoryAllocated, mem.memoryAllocated);
|
||||
result.setCtr(DxvkStatCounter::MemoryUsed, mem.memoryUsed);
|
||||
result.setCtr(DxvkStatCounter::MemoryAllocated, mem.memoryAllocated);
|
||||
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);
|
||||
result.merge(m_statCounters);
|
||||
|
@ -82,8 +82,7 @@ namespace dxvk {
|
||||
|
||||
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass,
|
||||
DxvkStatCounters& stats) {
|
||||
const DxvkRenderPass& renderPass) {
|
||||
VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
|
||||
|
||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||
@ -120,8 +119,7 @@ namespace dxvk {
|
||||
|
||||
// Add new pipeline to the set
|
||||
m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle);
|
||||
|
||||
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
|
||||
m_pipeMgr->m_numGraphicsPipelines += 1;
|
||||
}
|
||||
|
||||
// Use the new pipeline as the base pipeline for derivative pipelines
|
||||
|
@ -175,13 +175,11 @@ namespace dxvk {
|
||||
* state. If necessary, a new pipeline will be created.
|
||||
* \param [in] state Pipeline state vector
|
||||
* \param [in] renderPass The render pass
|
||||
* \param [in,out] stats Stat counter
|
||||
* \returns Pipeline handle
|
||||
*/
|
||||
VkPipeline getPipelineHandle(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass,
|
||||
DxvkStatCounters& stats);
|
||||
const DxvkRenderPass& renderPass);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -100,5 +100,13 @@ namespace dxvk {
|
||||
m_graphicsPipelines.insert(std::make_pair(key, pipeline));
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
||||
DxvkPipelineCount DxvkPipelineManager::getPipelineCount() const {
|
||||
DxvkPipelineCount result;
|
||||
result.numComputePipelines = m_numComputePipelines.load();
|
||||
result.numGraphicsPipelines = m_numGraphicsPipelines.load();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,17 @@
|
||||
#include "dxvk_graphics.h"
|
||||
|
||||
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
|
||||
@ -95,10 +106,19 @@ namespace dxvk {
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs);
|
||||
|
||||
/**
|
||||
* \brief Retrieves total pipeline count
|
||||
* \returns Number of compute/graphics pipelines
|
||||
*/
|
||||
DxvkPipelineCount getPipelineCount() const;
|
||||
|
||||
private:
|
||||
|
||||
const DxvkDevice* m_device;
|
||||
Rc<DxvkPipelineCache> m_cache;
|
||||
|
||||
std::atomic<uint32_t> m_numComputePipelines = { 0 };
|
||||
std::atomic<uint32_t> m_numGraphicsPipelines = { 0 };
|
||||
|
||||
std::mutex m_mutex;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user