diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-05-11 00:20:15 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:31 +0200 |
commit | 70fbede213bfadfc4015b3227e57fca34bea46eb (patch) | |
tree | 72a860110d4228ba5a9bc6ca977b0fed55385d77 /src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp | |
parent | glasm: Implement shuffle and vote instructions on GLASM (diff) | |
download | yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.tar yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.tar.gz yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.tar.bz2 yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.tar.lz yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.tar.xz yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.tar.zst yuzu-70fbede213bfadfc4015b3227e57fca34bea46eb.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp index 94dc5019d..22321f386 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp @@ -41,10 +41,23 @@ template <typename ObjectType> void CompositeInsert(EmitContext& ctx, IR::Inst& inst, Register composite, ObjectType object, u32 index, char type) { const Register ret{ctx.reg_alloc.Define(inst)}; - if (ret != composite) { - ctx.Add("MOV.{} {},{};", type, ret, composite); + const char swizzle{"xyzw"[index]}; + if (ret != composite && ret == object) { + // The object is aliased with the return value, so we have to use a temporary to insert + ctx.Add("MOV.{} RC,{};" + "MOV.{} RC.{},{};" + "MOV.{} {},RC;", + type, composite, type, swizzle, object, type, ret); + } else if (ret != composite) { + // The input composite is not aliased with the return value so we have to copy it before + // hand. But the insert object is not aliased with the return value, so we don't have to + // worry about that + ctx.Add("MOV.{} {},{};MOV.{},{}.{},{};", type, ret, composite, type, ret, swizzle, object); + } else { + // The return value is alised so we can just insert the object, it doesn't matter if it's + // aliased + ctx.Add("MOV.{} {}.{},{};", type, ret, swizzle, object); } - ctx.Add("MOV.{} {}.{},{};", type, ret, "xyzw"[index], object); } } // Anonymous namespace |