ColorFormat.cs 7.8 KB

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