From 9760795bfb854733c4696fa9e7e04f788ea489a7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 15 Oct 2019 18:14:52 -0400 Subject: [PATCH] gl_shader_decompiler: Avoid unnecessary copies of MetaImage MetaImage contains a std::vector, so copying here could result in unnecessary reallocations. Given the operation lives throughout the entire scope, this is safe to do. --- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 6a610a3bc..3bd3d2244 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1235,7 +1235,7 @@ private: std::string BuildImageValues(Operation operation) { constexpr std::array constructors{"uint", "uvec2", "uvec3", "uvec4"}; - const auto meta{std::get(operation.GetMeta())}; + const auto& meta{std::get(operation.GetMeta())}; const std::size_t values_count{meta.values.size()}; std::string expr = fmt::format("{}(", constructors.at(values_count - 1)); @@ -1780,14 +1780,14 @@ private: return {"0", Type::Int}; } - const auto meta{std::get(operation.GetMeta())}; + const auto& meta{std::get(operation.GetMeta())}; return {fmt::format("imageLoad({}, {}){}", GetImage(meta.image), BuildIntegerCoordinates(operation), GetSwizzle(meta.element)), Type::Uint}; } Expression ImageStore(Operation operation) { - const auto meta{std::get(operation.GetMeta())}; + const auto& meta{std::get(operation.GetMeta())}; code.AddLine("imageStore({}, {}, {});", GetImage(meta.image), BuildIntegerCoordinates(operation), BuildImageValues(operation)); return {}; @@ -1795,7 +1795,7 @@ private: template Expression AtomicImage(Operation operation) { - const auto meta{std::get(operation.GetMeta())}; + const auto& meta{std::get(operation.GetMeta())}; ASSERT(meta.values.size() == 1); return {fmt::format("imageAtomic{}({}, {}, {})", opname, GetImage(meta.image),