mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Simplify pipeline object locking
Any more complex approach is not very useful at the moment because we have to put a lock around the actual compile function anyway.
This commit is contained in:
parent
0be291e123
commit
8bcd47d6dc
@ -48,34 +48,18 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkPipeline DxvkComputePipeline::getPipelineHandle(
|
VkPipeline DxvkComputePipeline::getPipelineHandle(
|
||||||
const DxvkComputePipelineStateInfo& state) {
|
const DxvkComputePipelineStateInfo& state) {
|
||||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
VkPipeline newPipelineBase = VK_NULL_HANDLE;
|
||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
|
||||||
|
|
||||||
if (this->findPipeline(state, pipeline))
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no pipeline instance exists with the given state
|
|
||||||
// vector, create a new one and add it to the list.
|
|
||||||
VkPipeline newPipelineBase = m_basePipeline.load();
|
|
||||||
VkPipeline newPipelineHandle = VK_NULL_HANDLE;
|
VkPipeline newPipelineHandle = VK_NULL_HANDLE;
|
||||||
|
|
||||||
// FIXME for some reason, compiling the exact
|
|
||||||
// same pipeline crashes inside driver code
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||||
newPipelineHandle = this->compilePipeline(
|
|
||||||
state, newPipelineBase);
|
if (this->findPipeline(state, newPipelineHandle))
|
||||||
}
|
return newPipelineHandle;
|
||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
// If no pipeline instance exists with the given state
|
||||||
|
// vector, create a new one and add it to the list.
|
||||||
// Discard the pipeline if another thread
|
newPipelineBase = m_basePipeline.load();
|
||||||
// was faster compiling the same pipeline
|
newPipelineHandle = this->compilePipeline(state, newPipelineBase);
|
||||||
if (this->findPipeline(state, pipeline)) {
|
|
||||||
this->destroyPipeline(newPipelineHandle);
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new pipeline to the set
|
// Add new pipeline to the set
|
||||||
m_pipelines.push_back({ state, newPipelineHandle });
|
m_pipelines.push_back({ state, newPipelineHandle });
|
||||||
|
@ -85,45 +85,27 @@ namespace dxvk {
|
|||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) {
|
const DxvkRenderPass& renderPass) {
|
||||||
VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
|
VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
|
||||||
|
|
||||||
|
VkPipeline newPipelineBase = VK_NULL_HANDLE;
|
||||||
|
VkPipeline newPipelineHandle = VK_NULL_HANDLE;
|
||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||||
|
|
||||||
const DxvkGraphicsPipelineInstance* instance =
|
auto instance = this->findInstance(state, renderPassHandle);
|
||||||
this->findInstance(state, renderPassHandle);
|
|
||||||
|
|
||||||
if (instance != nullptr)
|
if (instance != nullptr)
|
||||||
return instance->pipeline();
|
return instance->pipeline();
|
||||||
}
|
|
||||||
|
|
||||||
// If the pipeline state vector is invalid, don't try
|
// If the pipeline state vector is invalid, don't try
|
||||||
// to create a new pipeline, it won't work anyway.
|
// to create a new pipeline, it won't work anyway.
|
||||||
if (!this->validatePipelineState(state))
|
if (!this->validatePipelineState(state))
|
||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
|
|
||||||
// If no pipeline instance exists with the given state
|
// If no pipeline instance exists with the given state
|
||||||
// vector, create a new one and add it to the list.
|
// vector, create a new one and add it to the list.
|
||||||
VkPipeline newPipelineBase = m_basePipeline.load();
|
newPipelineBase = m_basePipeline.load();
|
||||||
VkPipeline newPipelineHandle = VK_NULL_HANDLE;
|
newPipelineHandle = this->compilePipeline(state, renderPassHandle, newPipelineBase);
|
||||||
|
|
||||||
// FIXME for some reason, compiling the exact
|
|
||||||
// same pipeline crashes inside driver code
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
|
||||||
newPipelineHandle = this->compilePipeline(
|
|
||||||
state, renderPassHandle, newPipelineBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
|
||||||
|
|
||||||
// Discard the pipeline if another thread
|
|
||||||
// was faster compiling the same pipeline
|
|
||||||
const DxvkGraphicsPipelineInstance* instance =
|
|
||||||
this->findInstance(state, renderPassHandle);
|
|
||||||
|
|
||||||
if (instance != nullptr) {
|
|
||||||
this->destroyPipeline(newPipelineHandle);
|
|
||||||
return instance->pipeline();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new pipeline to the set
|
// Add new pipeline to the set
|
||||||
m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle);
|
m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle);
|
||||||
m_pipeMgr->m_numGraphicsPipelines += 1;
|
m_pipeMgr->m_numGraphicsPipelines += 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user