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) {
|
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) {
|
for (const auto& i : m_instances) {
|
||||||
if (compareOps(i.ops, ops))
|
if (compareOps(i.ops, ops))
|
||||||
return i.handle;
|
return i.handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkRenderPass handle = this->createRenderPass(ops);
|
return VK_NULL_HANDLE;
|
||||||
m_instances.push_back({ ops, handle });
|
|
||||||
return handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkRenderPass DxvkRenderPass::createRenderPass(const DxvkRenderPassOps& ops) {
|
VkRenderPass DxvkRenderPass::createRenderPass(const DxvkRenderPassOps& ops) {
|
||||||
std::vector<VkAttachmentDescription> attachments;
|
std::vector<VkAttachmentDescription> attachments;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "../util/sync/sync_list.h"
|
||||||
|
|
||||||
#include "dxvk_hash.h"
|
#include "dxvk_hash.h"
|
||||||
#include "dxvk_include.h"
|
#include "dxvk_include.h"
|
||||||
#include "dxvk_limits.h"
|
#include "dxvk_limits.h"
|
||||||
@ -178,8 +180,11 @@ namespace dxvk {
|
|||||||
DxvkRenderPassFormat m_format;
|
DxvkRenderPassFormat m_format;
|
||||||
VkRenderPass m_default;
|
VkRenderPass m_default;
|
||||||
|
|
||||||
sync::Spinlock m_mutex;
|
dxvk::mutex m_mutex;
|
||||||
std::vector<Instance> m_instances;
|
sync::List<Instance> m_instances;
|
||||||
|
|
||||||
|
VkRenderPass findHandle(
|
||||||
|
const DxvkRenderPassOps& ops);
|
||||||
|
|
||||||
VkRenderPass createRenderPass(
|
VkRenderPass createRenderPass(
|
||||||
const DxvkRenderPassOps& ops);
|
const DxvkRenderPassOps& ops);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user