mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Use lock-free list for compute pipeline lookup
This commit is contained in:
parent
67e2ee1b26
commit
477cb617ac
@ -34,31 +34,25 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkPipeline DxvkComputePipeline::getPipelineHandle(
|
VkPipeline DxvkComputePipeline::getPipelineHandle(
|
||||||
const DxvkComputePipelineStateInfo& state) {
|
const DxvkComputePipelineStateInfo& state) {
|
||||||
DxvkComputePipelineInstance* instance = nullptr;
|
DxvkComputePipelineInstance* instance = this->findInstance(state);
|
||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
|
||||||
|
|
||||||
|
if (unlikely(!instance)) {
|
||||||
|
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
||||||
instance = this->findInstance(state);
|
instance = this->findInstance(state);
|
||||||
|
|
||||||
if (instance)
|
if (!instance) {
|
||||||
return instance->pipeline();
|
instance = this->createInstance(state);
|
||||||
|
this->writePipelineStateToCache(state);
|
||||||
// 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)
|
|
||||||
return VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
this->writePipelineStateToCache(state);
|
|
||||||
return instance->pipeline();
|
return instance->pipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkComputePipeline::compilePipeline(
|
void DxvkComputePipeline::compilePipeline(
|
||||||
const DxvkComputePipelineStateInfo& state) {
|
const DxvkComputePipelineStateInfo& state) {
|
||||||
std::lock_guard<sync::Spinlock> lock(m_mutex);
|
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
||||||
|
|
||||||
if (!this->findInstance(state))
|
if (!this->findInstance(state))
|
||||||
this->createInstance(state);
|
this->createInstance(state);
|
||||||
@ -70,7 +64,7 @@ namespace dxvk {
|
|||||||
VkPipeline newPipelineHandle = this->createPipeline(state);
|
VkPipeline newPipelineHandle = this->createPipeline(state);
|
||||||
|
|
||||||
m_pipeMgr->m_numComputePipelines += 1;
|
m_pipeMgr->m_numComputePipelines += 1;
|
||||||
return &m_pipelines.emplace_back(state, newPipelineHandle);
|
return &(*m_pipelines.emplace(state, newPipelineHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../util/sync/sync_list.h"
|
||||||
|
|
||||||
#include "dxvk_bind_mask.h"
|
#include "dxvk_bind_mask.h"
|
||||||
#include "dxvk_graphics_state.h"
|
#include "dxvk_graphics_state.h"
|
||||||
#include "dxvk_pipecache.h"
|
#include "dxvk_pipecache.h"
|
||||||
@ -143,8 +144,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkPipelineLayout> m_layout;
|
Rc<DxvkPipelineLayout> m_layout;
|
||||||
|
|
||||||
sync::Spinlock m_mutex;
|
alignas(CACHE_LINE_SIZE)
|
||||||
std::vector<DxvkComputePipelineInstance> m_pipelines;
|
dxvk::mutex m_mutex;
|
||||||
|
sync::List<DxvkComputePipelineInstance> m_pipelines;
|
||||||
|
|
||||||
DxvkComputePipelineInstance* createInstance(
|
DxvkComputePipelineInstance* createInstance(
|
||||||
const DxvkComputePipelineStateInfo& state);
|
const DxvkComputePipelineStateInfo& state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user