OpCodeTextureScalar.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Ryujinx.Graphics.Shader.Instructions;
  2. namespace Ryujinx.Graphics.Shader.Decoders
  3. {
  4. class OpCodeTextureScalar : OpCode
  5. {
  6. #region "Component mask LUT"
  7. private const int ____ = 0x0;
  8. private const int R___ = 0x1;
  9. private const int _G__ = 0x2;
  10. private const int RG__ = 0x3;
  11. private const int __B_ = 0x4;
  12. private const int RGB_ = 0x7;
  13. private const int ___A = 0x8;
  14. private const int R__A = 0x9;
  15. private const int _G_A = 0xa;
  16. private const int RG_A = 0xb;
  17. private const int __BA = 0xc;
  18. private const int R_BA = 0xd;
  19. private const int _GBA = 0xe;
  20. private const int RGBA = 0xf;
  21. private static int[,] _maskLut = new int[,]
  22. {
  23. { R___, _G__, __B_, ___A, RG__, R__A, _G_A, __BA },
  24. { RGB_, RG_A, R_BA, _GBA, RGBA, ____, ____, ____ }
  25. };
  26. #endregion
  27. public Register Rd0 { get; }
  28. public Register Ra { get; }
  29. public Register Rb { get; }
  30. public Register Rd1 { get; }
  31. public int Immediate { get; }
  32. public int ComponentMask { get; }
  33. protected int RawType;
  34. public bool IsFp16 { get; }
  35. public OpCodeTextureScalar(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode)
  36. {
  37. Rd0 = new Register(opCode.Extract(0, 8), RegisterType.Gpr);
  38. Ra = new Register(opCode.Extract(8, 8), RegisterType.Gpr);
  39. Rb = new Register(opCode.Extract(20, 8), RegisterType.Gpr);
  40. Rd1 = new Register(opCode.Extract(28, 8), RegisterType.Gpr);
  41. Immediate = opCode.Extract(36, 13);
  42. int compSel = opCode.Extract(50, 3);
  43. RawType = opCode.Extract(53, 4);
  44. IsFp16 = !opCode.Extract(59);
  45. ComponentMask = _maskLut[Rd1.IsRZ ? 0 : 1, compSel];
  46. }
  47. }
  48. }