1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-13 07:08:50 +01:00

[dxvk] Deal with multiple pipeline handles for graphics pipeline instances

Also make the handles atomic since worker threads may access them when
compiling optimized pipeline variants.
This commit is contained in:
Philip Rebohle 2022-07-06 04:15:31 +02:00
parent 90454438b2
commit b50ed2ceca
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 22 additions and 7 deletions

View File

@ -492,8 +492,10 @@ namespace dxvk {
DxvkGraphicsPipeline::~DxvkGraphicsPipeline() {
for (const auto& instance : m_pipelines)
this->destroyPipeline(instance.handle);
for (const auto& instance : m_pipelines) {
this->destroyPipeline(instance.baseHandle.load());
this->destroyPipeline(instance.fastHandle.load());
}
}
@ -545,7 +547,14 @@ namespace dxvk {
}
}
return std::make_pair(instance->handle, DxvkGraphicsPipelineType::FastPipeline);
// Find a pipeline handle to use. If no optimized pipeline has
// been compiled yet, use the slower base pipeline instead.
VkPipeline fastHandle = instance->fastHandle.load();
if (likely(fastHandle != VK_NULL_HANDLE))
return std::make_pair(fastHandle, DxvkGraphicsPipelineType::FastPipeline);
return std::make_pair(instance->baseHandle.load(), DxvkGraphicsPipelineType::BasePipeline);
}
@ -569,7 +578,7 @@ namespace dxvk {
VkPipeline pipeline = this->createPipeline(state);
m_stats->numGraphicsPipelines += 1;
return &(*m_pipelines.emplace(state, pipeline));
return &(*m_pipelines.emplace(state, VK_NULL_HANDLE, pipeline));
}

View File

@ -249,11 +249,17 @@ namespace dxvk {
DxvkGraphicsPipelineInstance() { }
DxvkGraphicsPipelineInstance(
const DxvkGraphicsPipelineStateInfo& state_,
VkPipeline handle_)
: state(state_), handle(handle_) { }
VkPipeline baseHandle_,
VkPipeline fastHandle_)
: state (state_),
baseHandle (baseHandle_),
fastHandle (fastHandle_),
isCompiling (fastHandle_ != VK_NULL_HANDLE) { }
DxvkGraphicsPipelineStateInfo state;
VkPipeline handle = VK_NULL_HANDLE;
std::atomic<VkPipeline> baseHandle = { VK_NULL_HANDLE };
std::atomic<VkPipeline> fastHandle = { VK_NULL_HANDLE };
std::atomic<VkBool32> isCompiling = { VK_FALSE };
};