From c02464f64e302b8c9ea0f310e6fd85834d26cca5 Mon Sep 17 00:00:00 2001 From: ameerj Date: Fri, 31 Jul 2020 17:30:05 -0400 Subject: Vk Async Worker directly emplace in cache --- src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/video_core/renderer_vulkan/vk_pipeline_cache.cpp') diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index a7ce621ca..1a8b2c62b 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -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 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 = [&] { -- cgit v1.2.3