glsl: Rework var alloc to not assign unused results
This commit is contained in:
parent
1269a0cf8b
commit
9f3ffb996b
9 changed files with 91 additions and 49 deletions
|
@ -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';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue