summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glsl/emit_context.h
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-31 01:13:22 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:37 +0200
commit9f3ffb996b0d02ca64b492d22ff158e8f3659257 (patch)
tree48993eaf320484cf042071a81a1a6b1dcc829eb9 /src/shader_recompiler/backend/glsl/emit_context.h
parentglsl: Rework variable allocator to allow for variable reuse (diff)
downloadyuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.tar
yuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.tar.gz
yuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.tar.bz2
yuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.tar.lz
yuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.tar.xz
yuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.tar.zst
yuzu-9f3ffb996b0d02ca64b492d22ff158e8f3659257.zip
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.h')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.h8
1 files changed, 7 insertions, 1 deletions
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 <GlslVarType type, typename... Args>
void Add(const char* format_str, IR::Inst& inst, Args&&... args) {
- code += fmt::format(format_str, var_alloc.Define(inst, type), std::forward<Args>(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>(args)...);
+ } else {
+ code += fmt::format(format_str, var_def, std::forward<Args>(args)...);
+ }
// TODO: Remove this
code += '\n';
}