OpCodeTextureScalar.cs 2.0 KB

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