From 2d83b39532f2a4723d70093a6abd9a1236a0f760 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Apr 2020 22:43:01 -0400 Subject: [PATCH 1/3] gl_shader_manager: Avoid unnecessary std::vector copy in LoadDiskCache() Same behavior, but without an unnecessary reallocation. --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index d232dceb45..de496ac6db 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -445,7 +445,7 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, if (!transferable) { return; } - const auto raws = *transferable; + const auto& raws = *transferable; auto [decompiled, dumps] = disk_cache.LoadPrecompiled(); From 138539c9a09b26879afc7a16518c8c5dd8b136aa Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Apr 2020 22:46:55 -0400 Subject: [PATCH 2/3] gl_shader_manager: Eliminate variable shadowing Resolves a few -Wshadow warnings. --- .../renderer_opengl/gl_shader_manager.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index de496ac6db..5718433db5 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -468,13 +468,13 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, std::vector load_raws_index; // Loads both decompiled and precompiled shaders from the cache. If either one is missing for const auto LoadPrecompiledWorker = - [&](std::size_t begin, std::size_t end, const std::vector& raws, - const ShaderDecompiledMap& decompiled, const ShaderDumpsMap& dumps) { + [&](std::size_t begin, std::size_t end, const std::vector& raw_cache, + const ShaderDecompiledMap& decompiled_map, const ShaderDumpsMap& dump_map) { for (std::size_t i = 0; i < end; ++i) { if (stop_loading || compilation_failed) { return; } - const auto& raw{raws[i]}; + const auto& raw{raw_cache[i]}; const u64 unique_identifier{raw.GetUniqueIdentifier()}; const u64 calculated_hash = @@ -488,12 +488,12 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, return; } - const auto dump{dumps.find(unique_identifier)}; - const auto decomp{decompiled.find(unique_identifier)}; + const auto dump{dump_map.find(unique_identifier)}; + const auto decomp{decompiled_map.find(unique_identifier)}; OGLProgram shader; - if (dump != dumps.end() && decomp != decompiled.end()) { + if (dump != dump_map.end() && decomp != decompiled_map.end()) { // Only load this shader if its sanitize_mul setting matches if (decomp->second.sanitize_mul == VideoCore::g_hw_shader_accurate_mul) { continue; @@ -533,7 +533,7 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, load_raws_index.push_back(i); } if (callback) { - callback(VideoCore::LoadCallbackStage::Decompile, i, raws.size()); + callback(VideoCore::LoadCallbackStage::Decompile, i, raw_cache.size()); } } }; @@ -554,12 +554,12 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, compilation_failed = false; const auto LoadTransferable = [&](std::size_t begin, std::size_t end, - const std::vector& raws) { + const std::vector& raw_cache) { for (std::size_t i = 0; i < end; ++i) { if (stop_loading || compilation_failed) { return; } - const auto& raw{raws[i]}; + const auto& raw{raw_cache[i]}; const u64 unique_identifier{raw.GetUniqueIdentifier()}; bool sanitize_mul = false; @@ -603,7 +603,7 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, } if (callback) { - callback(VideoCore::LoadCallbackStage::Build, i, raws.size()); + callback(VideoCore::LoadCallbackStage::Build, i, raw_cache.size()); } } }; From ca4f7266c0a0f5e44877febc450bd5558f18a0d4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Apr 2020 22:48:57 -0400 Subject: [PATCH 3/3] gl_shader_manager: Remove unused variable within LoadDiskCache() --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 5718433db5..35e937f7f8 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -460,7 +460,6 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, bool precompiled_cache_altered = false; std::mutex mutex; - std::size_t built_shaders = 0; // It doesn't have be atomic since it's used behind a mutex std::atomic_bool compilation_failed = false; if (callback) { callback(VideoCore::LoadCallbackStage::Decompile, 0, raws.size());