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:
parent
90454438b2
commit
b50ed2ceca
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 };
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user