From eaa41eb76c7e404a18960b6ea6fb8c744804c648 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 23 Jul 2019 13:15:06 +0200 Subject: [PATCH] [dxvk] Don't use reference counting for pipeline objects Again not necessary since these objects are persistent. Eliminates refcount overhead of pipeline lookups entirely. --- src/dxvk/dxvk_compute.h | 2 +- src/dxvk/dxvk_context_state.h | 4 ++-- src/dxvk/dxvk_graphics.h | 2 +- src/dxvk/dxvk_pipemanager.cpp | 26 ++++++++++++++------------ src/dxvk/dxvk_pipemanager.h | 8 ++++---- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 933698c1..ea6c6baa 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -42,7 +42,7 @@ namespace dxvk { * pipelines do not need to be recompiled against any sort * of pipeline state. */ - class DxvkComputePipeline : public RcObject { + class DxvkComputePipeline { public: diff --git a/src/dxvk/dxvk_context_state.h b/src/dxvk/dxvk_context_state.h index c27050af..8b772fc2 100644 --- a/src/dxvk/dxvk_context_state.h +++ b/src/dxvk/dxvk_context_state.h @@ -117,14 +117,14 @@ namespace dxvk { DxvkGraphicsPipelineShaders shaders; DxvkGraphicsPipelineStateInfo state; DxvkGraphicsPipelineFlags flags; - Rc pipeline; + DxvkGraphicsPipeline* pipeline = nullptr; }; struct DxvkComputePipelineState { DxvkComputePipelineShaders shaders; DxvkComputePipelineStateInfo state; - Rc pipeline; + DxvkComputePipeline* pipeline = nullptr; }; diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 027f9a73..1bd6c800 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -198,7 +198,7 @@ namespace dxvk { * recompile the graphics pipeline against a given * pipeline state vector. */ - class DxvkGraphicsPipeline : public RcObject { + class DxvkGraphicsPipeline { public: diff --git a/src/dxvk/dxvk_pipemanager.cpp b/src/dxvk/dxvk_pipemanager.cpp index c13e91a2..378bb3d1 100644 --- a/src/dxvk/dxvk_pipemanager.cpp +++ b/src/dxvk/dxvk_pipemanager.cpp @@ -56,7 +56,7 @@ namespace dxvk { } - Rc DxvkPipelineManager::createComputePipeline( + DxvkComputePipeline* DxvkPipelineManager::createComputePipeline( const DxvkComputePipelineShaders& shaders) { if (shaders.cs == nullptr) return nullptr; @@ -65,16 +65,17 @@ namespace dxvk { auto pair = m_computePipelines.find(shaders); if (pair != m_computePipelines.end()) - return pair->second; + return &pair->second; - Rc pipeline = new DxvkComputePipeline(this, shaders); - - m_computePipelines.insert(std::make_pair(shaders, pipeline)); - return pipeline; + auto iter = m_computePipelines.emplace( + std::piecewise_construct, + std::tuple(shaders), + std::tuple(this, shaders)); + return &iter.first->second; } - Rc DxvkPipelineManager::createGraphicsPipeline( + DxvkGraphicsPipeline* DxvkPipelineManager::createGraphicsPipeline( const DxvkGraphicsPipelineShaders& shaders) { if (shaders.vs == nullptr) return nullptr; @@ -83,12 +84,13 @@ namespace dxvk { auto pair = m_graphicsPipelines.find(shaders); if (pair != m_graphicsPipelines.end()) - return pair->second; + return &pair->second; - Rc pipeline = new DxvkGraphicsPipeline(this, shaders); - - m_graphicsPipelines.insert(std::make_pair(shaders, pipeline)); - return pipeline; + auto iter = m_graphicsPipelines.emplace( + std::piecewise_construct, + std::tuple(shaders), + std::tuple(this, shaders)); + return &iter.first->second; } diff --git a/src/dxvk/dxvk_pipemanager.h b/src/dxvk/dxvk_pipemanager.h index 05280565..c5f57019 100644 --- a/src/dxvk/dxvk_pipemanager.h +++ b/src/dxvk/dxvk_pipemanager.h @@ -63,7 +63,7 @@ namespace dxvk { * \param [in] shaders Shaders for the pipeline * \returns Compute pipeline object */ - Rc createComputePipeline( + DxvkComputePipeline* createComputePipeline( const DxvkComputePipelineShaders& shaders); /** @@ -75,7 +75,7 @@ namespace dxvk { * \param [in] shaders Shaders for the pipeline * \returns Graphics pipeline object */ - Rc createGraphicsPipeline( + DxvkGraphicsPipeline* createGraphicsPipeline( const DxvkGraphicsPipelineShaders& shaders); /* @@ -114,13 +114,13 @@ namespace dxvk { std::unordered_map< DxvkComputePipelineShaders, - Rc, + DxvkComputePipeline, DxvkPipelineKeyHash, DxvkPipelineKeyEq> m_computePipelines; std::unordered_map< DxvkGraphicsPipelineShaders, - Rc, + DxvkGraphicsPipeline, DxvkPipelineKeyHash, DxvkPipelineKeyEq> m_graphicsPipelines;