InstEmitMove.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Ryujinx.Graphics.Shader.Decoders;
  2. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  3. using Ryujinx.Graphics.Shader.Translation;
  4. using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
  5. using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
  6. namespace Ryujinx.Graphics.Shader.Instructions
  7. {
  8. static partial class InstEmit
  9. {
  10. public static void Mov(EmitterContext context)
  11. {
  12. OpCodeAlu op = (OpCodeAlu)context.CurrOp;
  13. context.Copy(GetDest(context), GetSrcB(context));
  14. }
  15. public static void S2r(EmitterContext context)
  16. {
  17. // TODO: Better impl.
  18. OpCodeAlu op = (OpCodeAlu)context.CurrOp;
  19. SystemRegister sysReg = (SystemRegister)op.RawOpCode.Extract(20, 8);
  20. Operand src;
  21. switch (sysReg)
  22. {
  23. case SystemRegister.ThreadIdX: src = Attribute(AttributeConsts.ThreadIdX); break;
  24. case SystemRegister.ThreadIdY: src = Attribute(AttributeConsts.ThreadIdY); break;
  25. case SystemRegister.ThreadIdZ: src = Attribute(AttributeConsts.ThreadIdZ); break;
  26. case SystemRegister.CtaIdX: src = Attribute(AttributeConsts.CtaIdX); break;
  27. case SystemRegister.CtaIdY: src = Attribute(AttributeConsts.CtaIdY); break;
  28. case SystemRegister.CtaIdZ: src = Attribute(AttributeConsts.CtaIdZ); break;
  29. default: src = Const(0); break;
  30. }
  31. context.Copy(GetDest(context), src);
  32. }
  33. public static void Sel(EmitterContext context)
  34. {
  35. OpCodeAlu op = (OpCodeAlu)context.CurrOp;
  36. Operand pred = GetPredicate39(context);
  37. Operand srcA = GetSrcA(context);
  38. Operand srcB = GetSrcB(context);
  39. Operand res = context.ConditionalSelect(pred, srcA, srcB);
  40. context.Copy(GetDest(context), res);
  41. }
  42. }
  43. }