Vk Async Worker directly emplace in cache
This commit is contained in:
parent
4539073ce1
commit
c02464f64e
3 changed files with 41 additions and 58 deletions
|
@ -215,11 +215,7 @@ VKGraphicsPipeline* VKPipelineCache::GetGraphicsPipeline(
|
|||
last_graphics_key = key;
|
||||
|
||||
if (device.UseAsynchronousShaders()) {
|
||||
auto work = async_shaders.GetCompletedWork();
|
||||
for (auto& w : work) {
|
||||
auto& entry = graphics_cache.at(w.pipeline->GetCacheKey());
|
||||
entry = std::move(w.pipeline);
|
||||
}
|
||||
std::unique_lock lock{pipeline_cache};
|
||||
const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
|
||||
if (is_cache_miss) {
|
||||
LOG_INFO(Render_Vulkan, "Compile 0x{:016X}", key.Hash());
|
||||
|
@ -296,6 +292,18 @@ VKComputePipeline& VKPipelineCache::GetComputePipeline(const ComputePipelineCach
|
|||
return *entry;
|
||||
}
|
||||
|
||||
void VKPipelineCache::EmplacePipeline(std::unique_ptr<VKGraphicsPipeline> pipeline) {
|
||||
std::unique_lock lock{pipeline_cache};
|
||||
const auto [pair, is_cache_miss] = graphics_cache.try_emplace(pipeline->GetCacheKey());
|
||||
auto& entry = pair->second;
|
||||
if (entry) {
|
||||
LOG_INFO(Render_Vulkan, "Pipeline already here 0x{:016X}", pipeline->GetCacheKey().Hash());
|
||||
duplicates.push_back(std::move(pipeline));
|
||||
} else {
|
||||
entry = std::move(pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
void VKPipelineCache::OnShaderRemoval(Shader* shader) {
|
||||
bool finished = false;
|
||||
const auto Finish = [&] {
|
||||
|
|
|
@ -193,6 +193,8 @@ public:
|
|||
return renderpass_cache;
|
||||
}
|
||||
|
||||
void EmplacePipeline(std::unique_ptr<VKGraphicsPipeline> pipeline);
|
||||
|
||||
protected:
|
||||
void OnShaderRemoval(Shader* shader) final;
|
||||
|
||||
|
@ -216,6 +218,7 @@ private:
|
|||
VKGraphicsPipeline* last_graphics_pipeline = nullptr;
|
||||
std::vector<std::unique_ptr<VKGraphicsPipeline>> duplicates;
|
||||
|
||||
std::mutex pipeline_cache;
|
||||
std::unordered_map<GraphicsPipelineCacheKey, std::unique_ptr<VKGraphicsPipeline>>
|
||||
graphics_cache;
|
||||
std::unordered_map<ComputePipelineCacheKey, std::unique_ptr<VKComputePipeline>> compute_cache;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue