RtFormat.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using Ryujinx.Graphics.GAL;
  2. using Ryujinx.Graphics.Gpu.Image;
  3. namespace Ryujinx.Graphics.Gpu.State
  4. {
  5. enum RtFormat
  6. {
  7. D32Float = 0xa,
  8. D16Unorm = 0x13,
  9. D24UnormS8Uint = 0x14,
  10. D24Unorm = 0x15,
  11. S8UintD24Unorm = 0x16,
  12. S8Uint = 0x17,
  13. D32FloatS8Uint = 0x19,
  14. R32G32B32A32Float = 0xc0,
  15. R32G32B32A32Sint = 0xc1,
  16. R32G32B32A32Uint = 0xc2,
  17. R32G32B32X32Float = 0xc3,
  18. R32G32B32X32Sint = 0xc4,
  19. R32G32B32X32Uint = 0xc5,
  20. R16G16B16X16Unorm = 0xc6,
  21. R16G16B16X16Snorm = 0xc7,
  22. R16G16B16X16Sint = 0xc8,
  23. R16G16B16X16Uint = 0xc9,
  24. R16G16B16A16Float = 0xca,
  25. R32G32Float = 0xcb,
  26. R32G32Sint = 0xcc,
  27. R32G32Uint = 0xcd,
  28. R16G16B16X16Float = 0xce,
  29. B8G8R8A8Unorm = 0xcf,
  30. B8G8R8A8Srgb = 0xd0,
  31. R10G10B10A2Unorm = 0xd1,
  32. R10G10B10A2Uint = 0xd2,
  33. R8G8B8A8Unorm = 0xd5,
  34. R8G8B8A8Srgb = 0xd6,
  35. R8G8B8X8Snorm = 0xd7,
  36. R8G8B8X8Sint = 0xd8,
  37. R8G8B8X8Uint = 0xd9,
  38. R16G16Unorm = 0xda,
  39. R16G16Snorm = 0xdb,
  40. R16G16Sint = 0xdc,
  41. R16G16Uint = 0xdd,
  42. R16G16Float = 0xde,
  43. R11G11B10Float = 0xe0,
  44. R32Sint = 0xe3,
  45. R32Uint = 0xe4,
  46. R32Float = 0xe5,
  47. B8G8R8X8Unorm = 0xe6,
  48. B8G8R8X8Srgb = 0xe7,
  49. B5G6R5Unorm = 0xe8,
  50. B5G5R5A1Unorm = 0xe9,
  51. R8G8Unorm = 0xea,
  52. R8G8Snorm = 0xeb,
  53. R8G8Sint = 0xec,
  54. R8G8Uint = 0xed,
  55. R16Unorm = 0xee,
  56. R16Snorm = 0xef,
  57. R16Sint = 0xf0,
  58. R16Uint = 0xf1,
  59. R16Float = 0xf2,
  60. R8Unorm = 0xf3,
  61. R8Snorm = 0xf4,
  62. R8Sint = 0xf5,
  63. R8Uint = 0xf6,
  64. B5G5R5X1Unorm = 0xf8,
  65. R8G8B8X8Unorm = 0xf9,
  66. R8G8B8X8Srgb = 0xfa
  67. }
  68. static class RtFormatConverter
  69. {
  70. public static FormatInfo Convert(this RtFormat format)
  71. {
  72. switch (format)
  73. {
  74. case RtFormat.D32Float: return new FormatInfo(Format.D32Float, 1, 1, 4);
  75. case RtFormat.D16Unorm: return new FormatInfo(Format.D16Unorm, 1, 1, 2);
  76. case RtFormat.D24UnormS8Uint: return new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4);
  77. case RtFormat.D24Unorm: return new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4);
  78. case RtFormat.S8UintD24Unorm: return new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4);
  79. case RtFormat.S8Uint: return new FormatInfo(Format.S8Uint, 1, 1, 1);
  80. case RtFormat.D32FloatS8Uint: return new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8);
  81. case RtFormat.R32G32B32A32Float: return new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16);
  82. case RtFormat.R32G32B32A32Sint: return new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16);
  83. case RtFormat.R32G32B32A32Uint: return new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16);
  84. case RtFormat.R32G32B32X32Float: return new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16);
  85. case RtFormat.R32G32B32X32Sint: return new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16);
  86. case RtFormat.R32G32B32X32Uint: return new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16);
  87. case RtFormat.R16G16B16X16Unorm: return new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8);
  88. case RtFormat.R16G16B16X16Snorm: return new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8);
  89. case RtFormat.R16G16B16X16Sint: return new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8);
  90. case RtFormat.R16G16B16X16Uint: return new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8);
  91. case RtFormat.R16G16B16A16Float: return new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8);
  92. case RtFormat.R32G32Float: return new FormatInfo(Format.R32G32Float, 1, 1, 8);
  93. case RtFormat.R32G32Sint: return new FormatInfo(Format.R32G32Sint, 1, 1, 8);
  94. case RtFormat.R32G32Uint: return new FormatInfo(Format.R32G32Uint, 1, 1, 8);
  95. case RtFormat.R16G16B16X16Float: return new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8);
  96. case RtFormat.B8G8R8A8Unorm: return new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4);
  97. case RtFormat.B8G8R8A8Srgb: return new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4);
  98. case RtFormat.R10G10B10A2Unorm: return new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4);
  99. case RtFormat.R10G10B10A2Uint: return new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4);
  100. case RtFormat.R8G8B8A8Unorm: return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4);
  101. case RtFormat.R8G8B8A8Srgb: return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4);
  102. case RtFormat.R8G8B8X8Snorm: return new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4);
  103. case RtFormat.R8G8B8X8Sint: return new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4);
  104. case RtFormat.R8G8B8X8Uint: return new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4);
  105. case RtFormat.R16G16Unorm: return new FormatInfo(Format.R16G16Unorm, 1, 1, 4);
  106. case RtFormat.R16G16Snorm: return new FormatInfo(Format.R16G16Snorm, 1, 1, 4);
  107. case RtFormat.R16G16Sint: return new FormatInfo(Format.R16G16Sint, 1, 1, 4);
  108. case RtFormat.R16G16Uint: return new FormatInfo(Format.R16G16Uint, 1, 1, 4);
  109. case RtFormat.R16G16Float: return new FormatInfo(Format.R16G16Float, 1, 1, 4);
  110. case RtFormat.R11G11B10Float: return new FormatInfo(Format.R11G11B10Float, 1, 1, 4);
  111. case RtFormat.R32Sint: return new FormatInfo(Format.R32Sint, 1, 1, 4);
  112. case RtFormat.R32Uint: return new FormatInfo(Format.R32Uint, 1, 1, 4);
  113. case RtFormat.R32Float: return new FormatInfo(Format.R32Float, 1, 1, 4);
  114. case RtFormat.B8G8R8X8Unorm: return new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4);
  115. case RtFormat.B8G8R8X8Srgb: return new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4);
  116. case RtFormat.B5G6R5Unorm: return new FormatInfo(Format.B5G6R5Unorm, 1, 1, 2);
  117. case RtFormat.B5G5R5A1Unorm: return new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2);
  118. case RtFormat.R8G8Unorm: return new FormatInfo(Format.R8G8Unorm, 1, 1, 2);
  119. case RtFormat.R8G8Snorm: return new FormatInfo(Format.R8G8Snorm, 1, 1, 2);
  120. case RtFormat.R8G8Sint: return new FormatInfo(Format.R8G8Sint, 1, 1, 2);
  121. case RtFormat.R8G8Uint: return new FormatInfo(Format.R8G8Uint, 1, 1, 2);
  122. case RtFormat.R16Unorm: return new FormatInfo(Format.R16Unorm, 1, 1, 2);
  123. case RtFormat.R16Snorm: return new FormatInfo(Format.R16Snorm, 1, 1, 2);
  124. case RtFormat.R16Sint: return new FormatInfo(Format.R16Sint, 1, 1, 2);
  125. case RtFormat.R16Uint: return new FormatInfo(Format.R16Uint, 1, 1, 2);
  126. case RtFormat.R16Float: return new FormatInfo(Format.R16Float, 1, 1, 2);
  127. case RtFormat.R8Unorm: return new FormatInfo(Format.R8Unorm, 1, 1, 1);
  128. case RtFormat.R8Snorm: return new FormatInfo(Format.R8Snorm, 1, 1, 1);
  129. case RtFormat.R8Sint: return new FormatInfo(Format.R8Sint, 1, 1, 1);
  130. case RtFormat.R8Uint: return new FormatInfo(Format.R8Uint, 1, 1, 1);
  131. case RtFormat.B5G5R5X1Unorm: return new FormatInfo(Format.B5G5R5X1Unorm, 1, 1, 2);
  132. case RtFormat.R8G8B8X8Unorm: return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4);
  133. case RtFormat.R8G8B8X8Srgb: return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4);
  134. }
  135. return FormatInfo.Default;
  136. }
  137. }
  138. }