[dxvk] Use lock-free list for render pass instances

And replace the spin lock with a regular mutex.
This commit is contained in:
Philip Rebohle 2022-02-20 00:04:06 +01:00
parent 477cb617ac
commit 0ade12dc83
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 26 additions and 8 deletions

View File

@ -60,18 +60,31 @@ namespace dxvk {
VkRenderPass DxvkRenderPass::getHandle(const DxvkRenderPassOps& ops) {
std::lock_guard<sync::Spinlock> lock(m_mutex);
VkRenderPass handle = this->findHandle(ops);
if (unlikely(!handle)) {
std::lock_guard<dxvk::mutex> 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<VkAttachmentDescription> attachments;

View File

@ -4,6 +4,8 @@
#include <vector>
#include <unordered_map>
#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<Instance> m_instances;
dxvk::mutex m_mutex;
sync::List<Instance> m_instances;
VkRenderPass findHandle(
const DxvkRenderPassOps& ops);
VkRenderPass createRenderPass(
const DxvkRenderPassOps& ops);