diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index 86985890..4e060908 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -34,31 +34,25 @@ namespace dxvk { VkPipeline DxvkComputePipeline::getPipelineHandle( const DxvkComputePipelineStateInfo& state) { - DxvkComputePipelineInstance* instance = nullptr; - - { std::lock_guard lock(m_mutex); + DxvkComputePipelineInstance* instance = this->findInstance(state); + if (unlikely(!instance)) { + std::lock_guard lock(m_mutex); instance = this->findInstance(state); - if (instance) - return instance->pipeline(); - - // If no pipeline instance exists with the given state - // vector, create a new one and add it to the list. - instance = this->createInstance(state); + if (!instance) { + instance = this->createInstance(state); + this->writePipelineStateToCache(state); + } } - - if (!instance) - return VK_NULL_HANDLE; - this->writePipelineStateToCache(state); return instance->pipeline(); } void DxvkComputePipeline::compilePipeline( const DxvkComputePipelineStateInfo& state) { - std::lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); if (!this->findInstance(state)) this->createInstance(state); @@ -70,7 +64,7 @@ namespace dxvk { VkPipeline newPipelineHandle = this->createPipeline(state); m_pipeMgr->m_numComputePipelines += 1; - return &m_pipelines.emplace_back(state, newPipelineHandle); + return &(*m_pipelines.emplace(state, newPipelineHandle)); } diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 5be89d6c..186d17ef 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -1,8 +1,9 @@ #pragma once -#include #include +#include "../util/sync/sync_list.h" + #include "dxvk_bind_mask.h" #include "dxvk_graphics_state.h" #include "dxvk_pipecache.h" @@ -143,8 +144,9 @@ namespace dxvk { Rc m_layout; - sync::Spinlock m_mutex; - std::vector m_pipelines; + alignas(CACHE_LINE_SIZE) + dxvk::mutex m_mutex; + sync::List m_pipelines; DxvkComputePipelineInstance* createInstance( const DxvkComputePipelineStateInfo& state);