OperandHelper.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Ryujinx.Graphics.Shader.Decoders;
  2. using System;
  3. namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
  4. {
  5. static class OperandHelper
  6. {
  7. public static Operand Argument(int value)
  8. {
  9. return new Operand(OperandType.Argument, value);
  10. }
  11. public static Operand Attribute(int value)
  12. {
  13. return new Operand(OperandType.Attribute, value);
  14. }
  15. public static Operand Cbuf(int slot, int offset)
  16. {
  17. return new Operand(slot, offset);
  18. }
  19. public static Operand Const(int value)
  20. {
  21. return new Operand(OperandType.Constant, value);
  22. }
  23. public static Operand ConstF(float value)
  24. {
  25. return new Operand(OperandType.Constant, BitConverter.SingleToInt32Bits(value));
  26. }
  27. public static Operand Label()
  28. {
  29. return new Operand(OperandType.Label);
  30. }
  31. public static Operand Local()
  32. {
  33. return new Operand(OperandType.LocalVariable);
  34. }
  35. public static Operand Register(int index, RegisterType type)
  36. {
  37. return Register(new Register(index, type));
  38. }
  39. public static Operand Register(Register reg)
  40. {
  41. if (reg.IsRZ)
  42. {
  43. return Const(0);
  44. }
  45. else if (reg.IsPT)
  46. {
  47. return Const(IrConsts.True);
  48. }
  49. return new Operand(reg);
  50. }
  51. public static Operand Undef()
  52. {
  53. return new Operand(OperandType.Undefined);
  54. }
  55. }
  56. }