InstEmitMove.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.ThreadId:
  24. {
  25. Operand tidX = Attribute(AttributeConsts.ThreadIdX);
  26. Operand tidY = Attribute(AttributeConsts.ThreadIdY);
  27. Operand tidZ = Attribute(AttributeConsts.ThreadIdZ);
  28. tidY = context.ShiftLeft(tidY, Const(16));
  29. tidZ = context.ShiftLeft(tidZ, Const(26));
  30. src = context.BitwiseOr(tidX, context.BitwiseOr(tidY, tidZ));
  31. break;
  32. }
  33. case SystemRegister.ThreadIdX: src = Attribute(AttributeConsts.ThreadIdX); break;
  34. case SystemRegister.ThreadIdY: src = Attribute(AttributeConsts.ThreadIdY); break;
  35. case SystemRegister.ThreadIdZ: src = Attribute(AttributeConsts.ThreadIdZ); break;
  36. case SystemRegister.CtaIdX: src = Attribute(AttributeConsts.CtaIdX); break;
  37. case SystemRegister.CtaIdY: src = Attribute(AttributeConsts.CtaIdY); break;
  38. case SystemRegister.CtaIdZ: src = Attribute(AttributeConsts.CtaIdZ); break;
  39. default: src = Const(0); break;
  40. }
  41. context.Copy(GetDest(context), src);
  42. }
  43. public static void Sel(EmitterContext context)
  44. {
  45. OpCodeAlu op = (OpCodeAlu)context.CurrOp;
  46. Operand pred = GetPredicate39(context);
  47. Operand srcA = GetSrcA(context);
  48. Operand srcB = GetSrcB(context);
  49. Operand res = context.ConditionalSelect(pred, srcA, srcB);
  50. context.Copy(GetDest(context), res);
  51. }
  52. }
  53. }