From ec8559f40a66a21d1eada10b69bd4fbec0807a3f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 29 Oct 2018 12:11:33 +0100 Subject: [PATCH] [dxvk] Remove unneeded atomic that holds base pipeline handles No longer needed because the full pipeline object gets locked anyway. --- src/dxvk/dxvk_compute.cpp | 11 ++++------- src/dxvk/dxvk_compute.h | 2 +- src/dxvk/dxvk_graphics.cpp | 11 ++++------- src/dxvk/dxvk_graphics.h | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index e05db143..fdc2a3cf 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -48,7 +48,6 @@ namespace dxvk { VkPipeline DxvkComputePipeline::getPipelineHandle( const DxvkComputePipelineStateInfo& state) { - VkPipeline newPipelineBase = VK_NULL_HANDLE; VkPipeline newPipelineHandle = VK_NULL_HANDLE; { std::lock_guard lock(m_mutex); @@ -58,17 +57,15 @@ namespace dxvk { // If no pipeline instance exists with the given state // vector, create a new one and add it to the list. - newPipelineBase = m_basePipeline.load(); - newPipelineHandle = this->compilePipeline(state, newPipelineBase); + newPipelineHandle = this->compilePipeline(state, m_basePipeline); // Add new pipeline to the set m_pipelines.push_back({ state, newPipelineHandle }); m_pipeMgr->m_numComputePipelines += 1; + + if (!m_basePipeline && newPipelineHandle) + m_basePipeline = newPipelineHandle; } - - // Use the new pipeline as the base pipeline for derivative pipelines - if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE) - m_basePipeline.compare_exchange_strong(newPipelineBase, newPipelineHandle); if (newPipelineHandle != VK_NULL_HANDLE) this->writePipelineStateToCache(state); diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 985f18e5..8063d8e5 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -80,7 +80,7 @@ namespace dxvk { sync::Spinlock m_mutex; std::vector m_pipelines; - std::atomic m_basePipeline = { VK_NULL_HANDLE }; + VkPipeline m_basePipeline = VK_NULL_HANDLE; bool findPipeline( const DxvkComputePipelineStateInfo& state, diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 86b476b5..58d984d1 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -108,7 +108,6 @@ namespace dxvk { const DxvkRenderPass& renderPass) { VkRenderPass renderPassHandle = renderPass.getDefaultHandle(); - VkPipeline newPipelineBase = VK_NULL_HANDLE; VkPipeline newPipelineHandle = VK_NULL_HANDLE; { std::lock_guard lock(m_mutex); @@ -125,18 +124,16 @@ namespace dxvk { // If no pipeline instance exists with the given state // vector, create a new one and add it to the list. - newPipelineBase = m_basePipeline.load(); - newPipelineHandle = this->compilePipeline(state, renderPassHandle, newPipelineBase); + newPipelineHandle = this->compilePipeline(state, renderPassHandle, m_basePipeline); // Add new pipeline to the set m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle); m_pipeMgr->m_numGraphicsPipelines += 1; + + if (!m_basePipeline && newPipelineHandle) + m_basePipeline = newPipelineHandle; } - // Use the new pipeline as the base pipeline for derivative pipelines - if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE) - m_basePipeline.compare_exchange_strong(newPipelineBase, newPipelineHandle); - if (newPipelineHandle != VK_NULL_HANDLE) this->writePipelineStateToCache(state, renderPass.format()); diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index c02d5722..128bec10 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -239,7 +239,7 @@ namespace dxvk { std::vector m_pipelines; // Pipeline handles used for derivative pipelines - std::atomic m_basePipeline = { VK_NULL_HANDLE }; + VkPipeline m_basePipeline = VK_NULL_HANDLE; const DxvkGraphicsPipelineInstance* findInstance( const DxvkGraphicsPipelineStateInfo& state,