glsl: Rework var alloc to not assign unused results

This commit is contained in:
ameerj
2021-05-30 19:13:22 -04:00
parent 1269a0cf8b
commit 9f3ffb996b
9 changed files with 91 additions and 49 deletions

View File

@ -26,7 +26,13 @@ void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
}
void EmitConditionRef(EmitContext& ctx, IR::Inst& inst, const IR::Value& value) {
ctx.AddU1("{}={};", inst, ctx.var_alloc.Consume(value));
// Fake one usage to get a real variable out of the condition
inst.DestructiveAddUsage(1);
const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U1)};
const auto input{ctx.var_alloc.Consume(value)};
if (ret != input) {
ctx.Add("{}={};", ret, input);
}
}
void EmitBitCastU16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst) {