diff options
| author | 2020-07-31 17:30:05 -0400 | |
|---|---|---|
| committer | 2020-08-16 12:02:22 -0400 | |
| commit | c02464f64e302b8c9ea0f310e6fd85834d26cca5 (patch) | |
| tree | ddf37cedd4f779690a677a89770b394905da7196 /src/video_core/renderer_vulkan | |
| parent | Address feedback. Bruteforce delete duplicates (diff) | |
| download | yuzu-c02464f64e302b8c9ea0f310e6fd85834d26cca5.tar.gz yuzu-c02464f64e302b8c9ea0f310e6fd85834d26cca5.tar.xz yuzu-c02464f64e302b8c9ea0f310e6fd85834d26cca5.zip | |
Vk Async Worker directly emplace in cache
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.h | 3 |
2 files changed, 16 insertions, 5 deletions
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( | |||
| 215 | last_graphics_key = key; | 215 | last_graphics_key = key; |
| 216 | 216 | ||
| 217 | if (device.UseAsynchronousShaders()) { | 217 | if (device.UseAsynchronousShaders()) { |
| 218 | auto work = async_shaders.GetCompletedWork(); | 218 | std::unique_lock lock{pipeline_cache}; |
| 219 | for (auto& w : work) { | ||
| 220 | auto& entry = graphics_cache.at(w.pipeline->GetCacheKey()); | ||
| 221 | entry = std::move(w.pipeline); | ||
| 222 | } | ||
| 223 | const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key); | 219 | const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key); |
| 224 | if (is_cache_miss) { | 220 | if (is_cache_miss) { |
| 225 | LOG_INFO(Render_Vulkan, "Compile 0x{:016X}", key.Hash()); | 221 | LOG_INFO(Render_Vulkan, "Compile 0x{:016X}", key.Hash()); |
| @@ -296,6 +292,18 @@ VKComputePipeline& VKPipelineCache::GetComputePipeline(const ComputePipelineCach | |||
| 296 | return *entry; | 292 | return *entry; |
| 297 | } | 293 | } |
| 298 | 294 | ||
| 295 | void VKPipelineCache::EmplacePipeline(std::unique_ptr<VKGraphicsPipeline> pipeline) { | ||
| 296 | std::unique_lock lock{pipeline_cache}; | ||
| 297 | const auto [pair, is_cache_miss] = graphics_cache.try_emplace(pipeline->GetCacheKey()); | ||
| 298 | auto& entry = pair->second; | ||
| 299 | if (entry) { | ||
| 300 | LOG_INFO(Render_Vulkan, "Pipeline already here 0x{:016X}", pipeline->GetCacheKey().Hash()); | ||
| 301 | duplicates.push_back(std::move(pipeline)); | ||
| 302 | } else { | ||
| 303 | entry = std::move(pipeline); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 299 | void VKPipelineCache::OnShaderRemoval(Shader* shader) { | 307 | void VKPipelineCache::OnShaderRemoval(Shader* shader) { |
| 300 | bool finished = false; | 308 | bool finished = false; |
| 301 | const auto Finish = [&] { | 309 | const auto Finish = [&] { |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 404f2b3f7..777ef2038 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h | |||
| @@ -193,6 +193,8 @@ public: | |||
| 193 | return renderpass_cache; | 193 | return renderpass_cache; |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | void EmplacePipeline(std::unique_ptr<VKGraphicsPipeline> pipeline); | ||
| 197 | |||
| 196 | protected: | 198 | protected: |
| 197 | void OnShaderRemoval(Shader* shader) final; | 199 | void OnShaderRemoval(Shader* shader) final; |
| 198 | 200 | ||
| @@ -216,6 +218,7 @@ private: | |||
| 216 | VKGraphicsPipeline* last_graphics_pipeline = nullptr; | 218 | VKGraphicsPipeline* last_graphics_pipeline = nullptr; |
| 217 | std::vector<std::unique_ptr<VKGraphicsPipeline>> duplicates; | 219 | std::vector<std::unique_ptr<VKGraphicsPipeline>> duplicates; |
| 218 | 220 | ||
| 221 | std::mutex pipeline_cache; | ||
| 219 | std::unordered_map<GraphicsPipelineCacheKey, std::unique_ptr<VKGraphicsPipeline>> | 222 | std::unordered_map<GraphicsPipelineCacheKey, std::unique_ptr<VKGraphicsPipeline>> |
| 220 | graphics_cache; | 223 | graphics_cache; |
| 221 | std::unordered_map<ComputePipelineCacheKey, std::unique_ptr<VKComputePipeline>> compute_cache; | 224 | std::unordered_map<ComputePipelineCacheKey, std::unique_ptr<VKComputePipeline>> compute_cache; |