OperandHelper.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 Attribute(int value, InterpolationQualifier iq = InterpolationQualifier.None)
  8. {
  9. return new Operand(OperandType.Attribute, value, iq);
  10. }
  11. public static Operand Cbuf(int slot, int offset)
  12. {
  13. return new Operand(slot, offset);
  14. }
  15. public static Operand Const(int value)
  16. {
  17. return new Operand(OperandType.Constant, value);
  18. }
  19. public static Operand ConstF(float value)
  20. {
  21. return new Operand(OperandType.Constant, BitConverter.SingleToInt32Bits(value));
  22. }
  23. public static Operand Label()
  24. {
  25. return new Operand(OperandType.Label);
  26. }
  27. public static Operand Local()
  28. {
  29. return new Operand(OperandType.LocalVariable);
  30. }
  31. public static Operand Register(int index, RegisterType type)
  32. {
  33. return Register(new Register(index, type));
  34. }
  35. public static Operand Register(Register reg)
  36. {
  37. if (reg.IsRZ)
  38. {
  39. return Const(0);
  40. }
  41. else if (reg.IsPT)
  42. {
  43. return Const(IrConsts.True);
  44. }
  45. return new Operand(reg);
  46. }
  47. public static Operand Undef()
  48. {
  49. return new Operand(OperandType.Undefined);
  50. }
  51. }
  52. }