From 2cb9ceba1dfd5b18d923c05f0bd168fa928850fb Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 6 Jul 2022 02:23:44 +0200 Subject: [PATCH] [dxvk] Simplify pipeline instance data --- src/dxvk/dxvk_compute.cpp | 6 +++--- src/dxvk/dxvk_compute.h | 43 +++++++------------------------------- src/dxvk/dxvk_graphics.cpp | 6 +++--- src/dxvk/dxvk_graphics.h | 43 +++++++------------------------------- 4 files changed, 20 insertions(+), 78 deletions(-) diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index ffe8c983..50ffbd96 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -30,7 +30,7 @@ namespace dxvk { DxvkComputePipeline::~DxvkComputePipeline() { for (const auto& instance : m_pipelines) - this->destroyPipeline(instance.pipeline()); + this->destroyPipeline(instance.handle); } @@ -60,7 +60,7 @@ namespace dxvk { } } - return instance->pipeline(); + return instance->handle; } } @@ -88,7 +88,7 @@ namespace dxvk { DxvkComputePipelineInstance* DxvkComputePipeline::findInstance( const DxvkComputePipelineStateInfo& state) { for (auto& instance : m_pipelines) { - if (instance.isCompatible(state)) + if (instance.state == state) return &instance; } diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index d492f4d6..8dcfc314 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -39,44 +39,15 @@ namespace dxvk { /** * \brief Compute pipeline instance */ - class DxvkComputePipelineInstance { - - public: - - DxvkComputePipelineInstance() - : m_stateVector (), - m_pipeline (VK_NULL_HANDLE) { } - + struct DxvkComputePipelineInstance { + DxvkComputePipelineInstance() { } DxvkComputePipelineInstance( - const DxvkComputePipelineStateInfo& state, - VkPipeline pipe) - : m_stateVector (state), - m_pipeline (pipe) { } - - /** - * \brief Checks for matching pipeline state - * - * \param [in] stateVector Graphics pipeline state - * \param [in] renderPass Render pass handle - * \returns \c true if the specialization is compatible - */ - bool isCompatible(const DxvkComputePipelineStateInfo& state) const { - return m_stateVector == state; - } - - /** - * \brief Retrieves pipeline - * \returns The pipeline handle - */ - VkPipeline pipeline() const { - return m_pipeline; - } - - private: - - DxvkComputePipelineStateInfo m_stateVector; - VkPipeline m_pipeline; + const DxvkComputePipelineStateInfo& state_, + VkPipeline handle_) + : state(state_), handle(handle_) { } + DxvkComputePipelineStateInfo state; + VkPipeline handle = VK_NULL_HANDLE; }; diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index f0617488..a24059fd 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -493,7 +493,7 @@ namespace dxvk { DxvkGraphicsPipeline::~DxvkGraphicsPipeline() { for (const auto& instance : m_pipelines) - this->destroyPipeline(instance.pipeline()); + this->destroyPipeline(instance.handle); } @@ -545,7 +545,7 @@ namespace dxvk { } } - return instance->pipeline(); + return instance->handle; } @@ -576,7 +576,7 @@ namespace dxvk { DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::findInstance( const DxvkGraphicsPipelineStateInfo& state) { for (auto& instance : m_pipelines) { - if (instance.isCompatible(state)) + if (instance.state == state) return &instance; } diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index f69e8303..de4e4846 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -236,44 +236,15 @@ namespace dxvk { * Stores a state vector and the * corresponding pipeline handle. */ - class DxvkGraphicsPipelineInstance { - - public: - - DxvkGraphicsPipelineInstance() - : m_stateVector (), - m_pipeline (VK_NULL_HANDLE) { } - + struct DxvkGraphicsPipelineInstance { + DxvkGraphicsPipelineInstance() { } DxvkGraphicsPipelineInstance( - const DxvkGraphicsPipelineStateInfo& state, - VkPipeline pipe) - : m_stateVector (state), - m_pipeline (pipe) { } - - /** - * \brief Checks for matching pipeline state - * - * \param [in] stateVector Graphics pipeline state - * \returns \c true if the specialization is compatible - */ - bool isCompatible( - const DxvkGraphicsPipelineStateInfo& state) { - return m_stateVector == state; - } - - /** - * \brief Retrieves pipeline - * \returns The pipeline handle - */ - VkPipeline pipeline() const { - return m_pipeline; - } - - private: - - DxvkGraphicsPipelineStateInfo m_stateVector; - VkPipeline m_pipeline; + const DxvkGraphicsPipelineStateInfo& state_, + VkPipeline handle_) + : state(state_), handle(handle_) { } + DxvkGraphicsPipelineStateInfo state; + VkPipeline handle = VK_NULL_HANDLE; };