mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 20:52:10 +01:00
[dxvk] Use lock-free list for render pass instances
And replace the spin lock with a regular mutex.
This commit is contained in:
parent
477cb617ac
commit
0ade12dc83
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user