diff options
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> | |||
| 41 | void CompositeInsert(EmitContext& ctx, IR::Inst& inst, Register composite, ObjectType object, | 41 | void CompositeInsert(EmitContext& ctx, IR::Inst& inst, Register composite, ObjectType object, |
| 42 | u32 index, char type) { | 42 | u32 index, char type) { |
| 43 | const Register ret{ctx.reg_alloc.Define(inst)}; | 43 | const Register ret{ctx.reg_alloc.Define(inst)}; |
| 44 | if (ret != composite) { | 44 | const char swizzle{"xyzw"[index]}; |
| 45 | ctx.Add("MOV.{} {},{};", type, ret, composite); | 45 | if (ret != composite && ret == object) { |
| 46 | // The object is aliased with the return value, so we have to use a temporary to insert | ||
| 47 | ctx.Add("MOV.{} RC,{};" | ||
| 48 | "MOV.{} RC.{},{};" | ||
| 49 | "MOV.{} {},RC;", | ||
| 50 | type, composite, type, swizzle, object, type, ret); | ||
| 51 | } else if (ret != composite) { | ||
| 52 | // The input composite is not aliased with the return value so we have to copy it before | ||
| 53 | // hand. But the insert object is not aliased with the return value, so we don't have to | ||
| 54 | // worry about that | ||
| 55 | ctx.Add("MOV.{} {},{};MOV.{},{}.{},{};", type, ret, composite, type, ret, swizzle, object); | ||
| 56 | } else { | ||
| 57 | // The return value is alised so we can just insert the object, it doesn't matter if it's | ||
| 58 | // aliased | ||
| 59 | ctx.Add("MOV.{} {}.{},{};", type, ret, swizzle, object); | ||
| 46 | } | 60 | } |
| 47 | ctx.Add("MOV.{} {}.{},{};", type, ret, "xyzw"[index], object); | ||
| 48 | } | 61 | } |
| 49 | } // Anonymous namespace | 62 | } // Anonymous namespace |
| 50 | 63 | ||