diff --git a/src/dxvk/dxvk_renderpass.cpp b/src/dxvk/dxvk_renderpass.cpp index baa5a3cb2..ee07945ba 100644 --- a/src/dxvk/dxvk_renderpass.cpp +++ b/src/dxvk/dxvk_renderpass.cpp @@ -60,18 +60,31 @@ namespace dxvk { VkRenderPass DxvkRenderPass::getHandle(const DxvkRenderPassOps& ops) { - std::lock_guard lock(m_mutex); + VkRenderPass handle = this->findHandle(ops); + + if (unlikely(!handle)) { + std::lock_guard lock(m_mutex); + handle = this->findHandle(ops); + + if (!handle) { + handle = this->createRenderPass(ops); + m_instances.insert({ ops, handle }); + } + } + return handle; + } + + + VkRenderPass DxvkRenderPass::findHandle(const DxvkRenderPassOps& ops) { for (const auto& i : m_instances) { if (compareOps(i.ops, ops)) return i.handle; } - - VkRenderPass handle = this->createRenderPass(ops); - m_instances.push_back({ ops, handle }); - return handle; + + return VK_NULL_HANDLE; } - + VkRenderPass DxvkRenderPass::createRenderPass(const DxvkRenderPassOps& ops) { std::vector attachments; diff --git a/src/dxvk/dxvk_renderpass.h b/src/dxvk/dxvk_renderpass.h index a5e105504..ea265b84f 100644 --- a/src/dxvk/dxvk_renderpass.h +++ b/src/dxvk/dxvk_renderpass.h @@ -4,6 +4,8 @@ #include #include +#include "../util/sync/sync_list.h" + #include "dxvk_hash.h" #include "dxvk_include.h" #include "dxvk_limits.h" @@ -178,8 +180,11 @@ namespace dxvk { DxvkRenderPassFormat m_format; VkRenderPass m_default; - sync::Spinlock m_mutex; - std::vector m_instances; + dxvk::mutex m_mutex; + sync::List m_instances; + + VkRenderPass findHandle( + const DxvkRenderPassOps& ops); VkRenderPass createRenderPass( const DxvkRenderPassOps& ops);