From 9f3ffb996b0d02ca64b492d22ff158e8f3659257 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 30 May 2021 19:13:22 -0400 Subject: glsl: Rework var alloc to not assign unused results --- src/shader_recompiler/backend/glsl/emit_context.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/shader_recompiler/backend/glsl/emit_context.h') diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h index 2f1062954..423fc6104 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.h +++ b/src/shader_recompiler/backend/glsl/emit_context.h @@ -37,7 +37,13 @@ public: template void Add(const char* format_str, IR::Inst& inst, Args&&... args) { - code += fmt::format(format_str, var_alloc.Define(inst, type), std::forward(args)...); + const auto var_def{var_alloc.AddDefine(inst, type)}; + if (var_def.empty()) { + // skip assigment. + code += fmt::format(&format_str[3], std::forward(args)...); + } else { + code += fmt::format(format_str, var_def, std::forward(args)...); + } // TODO: Remove this code += '\n'; } -- cgit v1.2.3