ShaderHeader.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. namespace Ryujinx.Graphics.Gal.Shader
  2. {
  3. class ShaderHeader
  4. {
  5. public const int PointList = 1;
  6. public const int LineStrip = 6;
  7. public const int TriangleStrip = 7;
  8. public int SphType { get; private set; }
  9. public int Version { get; private set; }
  10. public int ShaderType { get; private set; }
  11. public bool MrtEnable { get; private set; }
  12. public bool KillsPixels { get; private set; }
  13. public bool DoesGlobalStore { get; private set; }
  14. public int SassVersion { get; private set; }
  15. public bool DoesLoadOrStore { get; private set; }
  16. public bool DoesFp64 { get; private set; }
  17. public int StreamOutMask { get; private set; }
  18. public int ShaderLocalMemoryLowSize { get; private set; }
  19. public int PerPatchAttributeCount { get; private set; }
  20. public int ShaderLocalMemoryHighSize { get; private set; }
  21. public int ThreadsPerInputPrimitive { get; private set; }
  22. public int ShaderLocalMemoryCrsSize { get; private set; }
  23. public int OutputTopology { get; private set; }
  24. public int MaxOutputVertexCount { get; private set; }
  25. public int StoreReqStart { get; private set; }
  26. public int StoreReqEnd { get; private set; }
  27. public ShaderHeader(IGalMemory Memory, long Position)
  28. {
  29. uint CommonWord0 = (uint)Memory.ReadInt32(Position + 0);
  30. uint CommonWord1 = (uint)Memory.ReadInt32(Position + 4);
  31. uint CommonWord2 = (uint)Memory.ReadInt32(Position + 8);
  32. uint CommonWord3 = (uint)Memory.ReadInt32(Position + 12);
  33. uint CommonWord4 = (uint)Memory.ReadInt32(Position + 16);
  34. SphType = ReadBits(CommonWord0, 0, 5);
  35. Version = ReadBits(CommonWord0, 5, 5);
  36. ShaderType = ReadBits(CommonWord0, 10, 4);
  37. MrtEnable = ReadBits(CommonWord0, 14, 1) != 0;
  38. KillsPixels = ReadBits(CommonWord0, 15, 1) != 0;
  39. DoesGlobalStore = ReadBits(CommonWord0, 16, 1) != 0;
  40. SassVersion = ReadBits(CommonWord0, 17, 4);
  41. DoesLoadOrStore = ReadBits(CommonWord0, 26, 1) != 0;
  42. DoesFp64 = ReadBits(CommonWord0, 27, 1) != 0;
  43. StreamOutMask = ReadBits(CommonWord0, 28, 4);
  44. ShaderLocalMemoryLowSize = ReadBits(CommonWord1, 0, 24);
  45. PerPatchAttributeCount = ReadBits(CommonWord1, 24, 8);
  46. ShaderLocalMemoryHighSize = ReadBits(CommonWord2, 0, 24);
  47. ThreadsPerInputPrimitive = ReadBits(CommonWord2, 24, 8);
  48. ShaderLocalMemoryCrsSize = ReadBits(CommonWord3, 0, 24);
  49. OutputTopology = ReadBits(CommonWord3, 24, 4);
  50. MaxOutputVertexCount = ReadBits(CommonWord4, 0, 12);
  51. StoreReqStart = ReadBits(CommonWord4, 12, 8);
  52. StoreReqEnd = ReadBits(CommonWord4, 24, 8);
  53. }
  54. private static int ReadBits(uint Word, int Offset, int BitWidth)
  55. {
  56. uint Mask = (1u << BitWidth) - 1u;
  57. return (int)((Word >> Offset) & Mask);
  58. }
  59. }
  60. }