OperandHelper.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 AttributePerPatch(int value)
  16. {
  17. return new Operand(OperandType.AttributePerPatch, value);
  18. }
  19. public static Operand Cbuf(int slot, int offset)
  20. {
  21. return new Operand(slot, offset);
  22. }
  23. public static Operand Const(int value)
  24. {
  25. return new Operand(OperandType.Constant, value);
  26. }
  27. public static Operand ConstF(float value)
  28. {
  29. return new Operand(OperandType.Constant, BitConverter.SingleToInt32Bits(value));
  30. }
  31. public static Operand Label()
  32. {
  33. return new Operand(OperandType.Label);
  34. }
  35. public static Operand Local()
  36. {
  37. return new Operand(OperandType.LocalVariable);
  38. }
  39. public static Operand Register(int index, RegisterType type)
  40. {
  41. return Register(new Register(index, type));
  42. }
  43. public static Operand Register(Register reg)
  44. {
  45. if (reg.IsRZ)
  46. {
  47. return Const(0);
  48. }
  49. else if (reg.IsPT)
  50. {
  51. return Const(IrConsts.True);
  52. }
  53. return new Operand(reg);
  54. }
  55. public static Operand Undef()
  56. {
  57. return new Operand(OperandType.Undefined);
  58. }
  59. }
  60. }