FormatTable.cs 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. using Ryujinx.Graphics.GAL;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. namespace Ryujinx.Graphics.Gpu.Image
  5. {
  6. /// <summary>
  7. /// Contains format tables, for texture and vertex attribute formats.
  8. /// </summary>
  9. static class FormatTable
  10. {
  11. #pragma warning disable IDE0055 // Disable formatting
  12. [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
  13. private enum TextureFormat : uint
  14. {
  15. // Formats
  16. R32G32B32A32 = 0x01,
  17. R32G32B32 = 0x02,
  18. R16G16B16A16 = 0x03,
  19. R32G32 = 0x04,
  20. R32B24G8 = 0x05,
  21. X8B8G8R8 = 0x07,
  22. A8B8G8R8 = 0x08,
  23. A2B10G10R10 = 0x09,
  24. R16G16 = 0x0c,
  25. G8R24 = 0x0d,
  26. G24R8 = 0x0e,
  27. R32 = 0x0f,
  28. A4B4G4R4 = 0x12,
  29. A5B5G5R1 = 0x13,
  30. A1B5G5R5 = 0x14,
  31. B5G6R5 = 0x15,
  32. B6G5R5 = 0x16,
  33. G8R8 = 0x18,
  34. R16 = 0x1b,
  35. Y8Video = 0x1c,
  36. R8 = 0x1d,
  37. G4R4 = 0x1e,
  38. R1 = 0x1f,
  39. E5B9G9R9SharedExp = 0x20,
  40. Bf10Gf11Rf11 = 0x21,
  41. G8B8G8R8 = 0x22,
  42. B8G8R8G8 = 0x23,
  43. Bc1 = 0x24,
  44. Bc2 = 0x25,
  45. Bc3 = 0x26,
  46. Bc4 = 0x27,
  47. Bc5 = 0x28,
  48. Bc6HSf16 = 0x10,
  49. Bc6HUf16 = 0x11,
  50. Bc7U = 0x17,
  51. Etc2Rgb = 0x06,
  52. Etc2RgbPta = 0x0a,
  53. Etc2Rgba = 0x0b,
  54. Eac = 0x19,
  55. Eacx2 = 0x1a,
  56. Z24S8 = 0x29,
  57. X8Z24 = 0x2a,
  58. S8Z24 = 0x2b,
  59. X4V4Z24Cov4R4V = 0x2c,
  60. X4V4Z24Cov8R8V = 0x2d,
  61. V8Z24Cov4R12V = 0x2e,
  62. Zf32 = 0x2f,
  63. Zf32X24S8 = 0x30,
  64. X8Z24X20V4S8Cov4R4V = 0x31,
  65. X8Z24X20V4S8Cov8R8V = 0x32,
  66. Zf32X20V4X8Cov4R4V = 0x33,
  67. Zf32X20V4X8Cov8R8V = 0x34,
  68. Zf32X20V4S8Cov4R4V = 0x35,
  69. Zf32X20V4S8Cov8R8V = 0x36,
  70. X8Z24X16V8S8Cov4R12V = 0x37,
  71. Zf32X16V8X8Cov4R12V = 0x38,
  72. Zf32X16V8S8Cov4R12V = 0x39,
  73. Z16 = 0x3a,
  74. V8Z24Cov8R24V = 0x3b,
  75. X8Z24X16V8S8Cov8R24V = 0x3c,
  76. Zf32X16V8X8Cov8R24V = 0x3d,
  77. Zf32X16V8S8Cov8R24V = 0x3e,
  78. Astc2D4x4 = 0x40,
  79. Astc2D5x4 = 0x50,
  80. Astc2D5x5 = 0x41,
  81. Astc2D6x5 = 0x51,
  82. Astc2D6x6 = 0x42,
  83. Astc2D8x5 = 0x55,
  84. Astc2D8x6 = 0x52,
  85. Astc2D8x8 = 0x44,
  86. Astc2D10x5 = 0x56,
  87. Astc2D10x6 = 0x57,
  88. Astc2D10x8 = 0x53,
  89. Astc2D10x10 = 0x45,
  90. Astc2D12x10 = 0x54,
  91. Astc2D12x12 = 0x46,
  92. // Types
  93. Snorm = 0x1,
  94. Unorm = 0x2,
  95. Sint = 0x3,
  96. Uint = 0x4,
  97. SnormForceFp16 = 0x5,
  98. UnormForceFp16 = 0x6,
  99. Float = 0x7,
  100. // Component Types
  101. RSnorm = Snorm << 7,
  102. GSnorm = Snorm << 10,
  103. BSnorm = Snorm << 13,
  104. ASnorm = Snorm << 16,
  105. RUnorm = Unorm << 7,
  106. GUnorm = Unorm << 10,
  107. BUnorm = Unorm << 13,
  108. AUnorm = Unorm << 16,
  109. RSint = Sint << 7,
  110. GSint = Sint << 10,
  111. BSint = Sint << 13,
  112. ASint = Sint << 16,
  113. RUint = Uint << 7,
  114. GUint = Uint << 10,
  115. BUint = Uint << 13,
  116. AUint = Uint << 16,
  117. RSnormForceFp16 = SnormForceFp16 << 7,
  118. GSnormForceFp16 = SnormForceFp16 << 10,
  119. BSnormForceFp16 = SnormForceFp16 << 13,
  120. ASnormForceFp16 = SnormForceFp16 << 16,
  121. RUnormForceFp16 = UnormForceFp16 << 7,
  122. GUnormForceFp16 = UnormForceFp16 << 10,
  123. BUnormForceFp16 = UnormForceFp16 << 13,
  124. AUnormForceFp16 = UnormForceFp16 << 16,
  125. RFloat = Float << 7,
  126. GFloat = Float << 10,
  127. BFloat = Float << 13,
  128. AFloat = Float << 16,
  129. Srgb = 0x1 << 19, // Custom encoding
  130. // Combinations
  131. R8Unorm = R8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2491d
  132. R8Snorm = R8 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x1249d
  133. R8Uint = R8 | RUint | GUint | BUint | AUint, // 0x4921d
  134. R8Sint = R8 | RSint | GSint | BSint | ASint, // 0x36d9d
  135. R16Float = R16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff9b
  136. R16Unorm = R16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2491b
  137. R16Snorm = R16 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x1249b
  138. R16Uint = R16 | RUint | GUint | BUint | AUint, // 0x4921b
  139. R16Sint = R16 | RSint | GSint | BSint | ASint, // 0x36d9b
  140. R32Float = R32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff8f
  141. R32Uint = R32 | RUint | GUint | BUint | AUint, // 0x4920f
  142. R32Sint = R32 | RSint | GSint | BSint | ASint, // 0x36d8f
  143. G8R8Unorm = G8R8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24918
  144. G8R8Snorm = G8R8 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x12498
  145. G8R8Uint = G8R8 | RUint | GUint | BUint | AUint, // 0x49218
  146. G8R8Sint = G8R8 | RSint | GSint | BSint | ASint, // 0x36d98
  147. R16G16Float = R16G16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff8c
  148. R16G16Unorm = R16G16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2490c
  149. R16G16Snorm = R16G16 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x1248c
  150. R16G16Uint = R16G16 | RUint | GUint | BUint | AUint, // 0x4920c
  151. R16G16Sint = R16G16 | RSint | GSint | BSint | ASint, // 0x36d8c
  152. R32G32Float = R32G32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff84
  153. R32G32Uint = R32G32 | RUint | GUint | BUint | AUint, // 0x49204
  154. R32G32Sint = R32G32 | RSint | GSint | BSint | ASint, // 0x36d84
  155. R32G32B32Float = R32G32B32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff82
  156. R32G32B32Uint = R32G32B32 | RUint | GUint | BUint | AUint, // 0x49202
  157. R32G32B32Sint = R32G32B32 | RSint | GSint | BSint | ASint, // 0x36d82
  158. A8B8G8R8Unorm = A8B8G8R8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24908
  159. A8B8G8R8Snorm = A8B8G8R8 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x12488
  160. A8B8G8R8Uint = A8B8G8R8 | RUint | GUint | BUint | AUint, // 0x49208
  161. A8B8G8R8Sint = A8B8G8R8 | RSint | GSint | BSint | ASint, // 0x36d88
  162. R16G16B16A16Float = R16G16B16A16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff83
  163. R16G16B16A16Unorm = R16G16B16A16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24903
  164. R16G16B16A16Snorm = R16G16B16A16 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x12483
  165. R16G16B16A16Uint = R16G16B16A16 | RUint | GUint | BUint | AUint, // 0x49203
  166. R16G16B16A16Sint = R16G16B16A16 | RSint | GSint | BSint | ASint, // 0x36d83
  167. R32G32B32A32Float = R32G32B32A32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff81
  168. R32G32B32A32Uint = R32G32B32A32 | RUint | GUint | BUint | AUint, // 0x49201
  169. R32G32B32A32Sint = R32G32B32A32 | RSint | GSint | BSint | ASint, // 0x36d81
  170. Z16Unorm = Z16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2493a
  171. Zf32RFloatGUintBUintAUint = Zf32 | RFloat | GUint | BUint | AUint, // 0x493af
  172. Zf32Float = Zf32 | RFloat | GFloat | BFloat | AFloat, // 0x7ffaf
  173. G24R8RUintGUnormBUnormAUnorm = G24R8 | RUint | GUnorm | BUnorm | AUnorm, // 0x24a0e
  174. Z24S8RUintGUnormBUnormAUnorm = Z24S8 | RUint | GUnorm | BUnorm | AUnorm, // 0x24a29
  175. Z24S8RUintGUnormBUintAUint = Z24S8 | RUint | GUnorm | BUint | AUint, // 0x48a29
  176. S8Z24RUnormGUintBUintAUint = S8Z24 | RUnorm | GUint | BUint | AUint, // 0x4912b
  177. R32B24G8RFloatGUintBUnormAUnorm = R32B24G8 | RFloat | GUint | BUnorm | AUnorm, // 0x25385
  178. Zf32X24S8RFloatGUintBUnormAUnorm = Zf32X24S8 | RFloat | GUint | BUnorm | AUnorm, // 0x253b0
  179. A8B8G8R8UnormSrgb = A8B8G8R8 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4908
  180. G4R4Unorm = G4R4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2491e
  181. A4B4G4R4Unorm = A4B4G4R4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24912
  182. A1B5G5R5Unorm = A1B5G5R5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24914
  183. B5G6R5Unorm = B5G6R5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24915
  184. A2B10G10R10Unorm = A2B10G10R10 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24909
  185. A2B10G10R10Uint = A2B10G10R10 | RUint | GUint | BUint | AUint, // 0x49209
  186. Bf10Gf11Rf11Float = Bf10Gf11Rf11 | RFloat | GFloat | BFloat | AFloat, // 0x7ffa1
  187. E5B9G9R9SharedExpFloat = E5B9G9R9SharedExp | RFloat | GFloat | BFloat | AFloat, // 0x7ffa0
  188. Bc1Unorm = Bc1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24924
  189. Bc2Unorm = Bc2 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24925
  190. Bc3Unorm = Bc3 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24926
  191. Bc1UnormSrgb = Bc1 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4924
  192. Bc2UnormSrgb = Bc2 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4925
  193. Bc3UnormSrgb = Bc3 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4926
  194. Bc4Unorm = Bc4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24927
  195. Bc4Snorm = Bc4 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x124a7
  196. Bc5Unorm = Bc5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24928
  197. Bc5Snorm = Bc5 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x124a8
  198. Bc7UUnorm = Bc7U | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24917
  199. Bc7UUnormSrgb = Bc7U | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4917
  200. Bc6HSf16Float = Bc6HSf16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff90
  201. Bc6HUf16Float = Bc6HUf16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff91
  202. Etc2RgbUnorm = Etc2Rgb | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24906
  203. Etc2RgbPtaUnorm = Etc2RgbPta | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2490a
  204. Etc2RgbaUnorm = Etc2Rgba | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2490b
  205. Etc2RgbUnormSrgb = Etc2Rgb | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4906
  206. Etc2RgbPtaUnormSrgb = Etc2RgbPta | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa490a
  207. Etc2RgbaUnormSrgb = Etc2Rgba | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa490b
  208. Astc2D4x4Unorm = Astc2D4x4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24940
  209. Astc2D5x4Unorm = Astc2D5x4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24950
  210. Astc2D5x5Unorm = Astc2D5x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24941
  211. Astc2D6x5Unorm = Astc2D6x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24951
  212. Astc2D6x6Unorm = Astc2D6x6 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24942
  213. Astc2D8x5Unorm = Astc2D8x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24955
  214. Astc2D8x6Unorm = Astc2D8x6 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24952
  215. Astc2D8x8Unorm = Astc2D8x8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24944
  216. Astc2D10x5Unorm = Astc2D10x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24956
  217. Astc2D10x6Unorm = Astc2D10x6 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24957
  218. Astc2D10x8Unorm = Astc2D10x8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24953
  219. Astc2D10x10Unorm = Astc2D10x10 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24945
  220. Astc2D12x10Unorm = Astc2D12x10 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24954
  221. Astc2D12x12Unorm = Astc2D12x12 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24946
  222. Astc2D4x4UnormSrgb = Astc2D4x4 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4940
  223. Astc2D5x4UnormSrgb = Astc2D5x4 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4950
  224. Astc2D5x5UnormSrgb = Astc2D5x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4941
  225. Astc2D6x5UnormSrgb = Astc2D6x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4951
  226. Astc2D6x6UnormSrgb = Astc2D6x6 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4942
  227. Astc2D8x5UnormSrgb = Astc2D8x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4955
  228. Astc2D8x6UnormSrgb = Astc2D8x6 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4952
  229. Astc2D8x8UnormSrgb = Astc2D8x8 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4944
  230. Astc2D10x5UnormSrgb = Astc2D10x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4956
  231. Astc2D10x6UnormSrgb = Astc2D10x6 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4957
  232. Astc2D10x8UnormSrgb = Astc2D10x8 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4953
  233. Astc2D10x10UnormSrgb = Astc2D10x10 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4945
  234. Astc2D12x10UnormSrgb = Astc2D12x10 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4954
  235. Astc2D12x12UnormSrgb = Astc2D12x12 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4946
  236. A5B5G5R1Unorm = A5B5G5R1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24913
  237. }
  238. [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
  239. private enum VertexAttributeFormat : uint
  240. {
  241. // Width
  242. R32G32B32A32 = 0x01,
  243. R32G32B32 = 0x02,
  244. R16G16B16A16 = 0x03,
  245. R32G32 = 0x04,
  246. R16G16B16 = 0x05,
  247. A8B8G8R8 = 0x2f,
  248. R8G8B8A8 = 0x0a,
  249. X8B8G8R8 = 0x33,
  250. A2B10G10R10 = 0x30,
  251. B10G11R11 = 0x31,
  252. R16G16 = 0x0f,
  253. R32 = 0x12,
  254. R8G8B8 = 0x13,
  255. G8R8 = 0x32,
  256. R8G8 = 0x18,
  257. R16 = 0x1b,
  258. R8 = 0x1d,
  259. A8 = 0x34,
  260. // Type
  261. Snorm = 0x01,
  262. Unorm = 0x02,
  263. Sint = 0x03,
  264. Uint = 0x04,
  265. Uscaled = 0x05,
  266. Sscaled = 0x06,
  267. Float = 0x07,
  268. // Combinations
  269. R8Unorm = (R8 << 21) | (Unorm << 27), // 0x13a00000
  270. R8Snorm = (R8 << 21) | (Snorm << 27), // 0x0ba00000
  271. R8Uint = (R8 << 21) | (Uint << 27), // 0x23a00000
  272. R8Sint = (R8 << 21) | (Sint << 27), // 0x1ba00000
  273. R16Float = (R16 << 21) | (Float << 27), // 0x3b600000
  274. R16Unorm = (R16 << 21) | (Unorm << 27), // 0x13600000
  275. R16Snorm = (R16 << 21) | (Snorm << 27), // 0x0b600000
  276. R16Uint = (R16 << 21) | (Uint << 27), // 0x23600000
  277. R16Sint = (R16 << 21) | (Sint << 27), // 0x1b600000
  278. R32Float = (R32 << 21) | (Float << 27), // 0x3a400000
  279. R32Uint = (R32 << 21) | (Uint << 27), // 0x22400000
  280. R32Sint = (R32 << 21) | (Sint << 27), // 0x1a400000
  281. R8G8Unorm = (R8G8 << 21) | (Unorm << 27), // 0x13000000
  282. R8G8Snorm = (R8G8 << 21) | (Snorm << 27), // 0x0b000000
  283. R8G8Uint = (R8G8 << 21) | (Uint << 27), // 0x23000000
  284. R8G8Sint = (R8G8 << 21) | (Sint << 27), // 0x1b000000
  285. R16G16Float = (R16G16 << 21) | (Float << 27), // 0x39e00000
  286. R16G16Unorm = (R16G16 << 21) | (Unorm << 27), // 0x11e00000
  287. R16G16Snorm = (R16G16 << 21) | (Snorm << 27), // 0x09e00000
  288. R16G16Uint = (R16G16 << 21) | (Uint << 27), // 0x21e00000
  289. R16G16Sint = (R16G16 << 21) | (Sint << 27), // 0x19e00000
  290. R32G32Float = (R32G32 << 21) | (Float << 27), // 0x38800000
  291. R32G32Uint = (R32G32 << 21) | (Uint << 27), // 0x20800000
  292. R32G32Sint = (R32G32 << 21) | (Sint << 27), // 0x18800000
  293. R8G8B8Unorm = (R8G8B8 << 21) | (Unorm << 27), // 0x12600000
  294. R8G8B8Snorm = (R8G8B8 << 21) | (Snorm << 27), // 0x0a600000
  295. R8G8B8Uint = (R8G8B8 << 21) | (Uint << 27), // 0x22600000
  296. R8G8B8Sint = (R8G8B8 << 21) | (Sint << 27), // 0x1a600000
  297. R16G16B16Float = (R16G16B16 << 21) | (Float << 27), // 0x38a00000
  298. R16G16B16Unorm = (R16G16B16 << 21) | (Unorm << 27), // 0x10a00000
  299. R16G16B16Snorm = (R16G16B16 << 21) | (Snorm << 27), // 0x08a00000
  300. R16G16B16Uint = (R16G16B16 << 21) | (Uint << 27), // 0x20a00000
  301. R16G16B16Sint = (R16G16B16 << 21) | (Sint << 27), // 0x18a00000
  302. R32G32B32Float = (R32G32B32 << 21) | (Float << 27), // 0x38400000
  303. R32G32B32Uint = (R32G32B32 << 21) | (Uint << 27), // 0x20400000
  304. R32G32B32Sint = (R32G32B32 << 21) | (Sint << 27), // 0x18400000
  305. R8G8B8A8Unorm = (R8G8B8A8 << 21) | (Unorm << 27), // 0x11400000
  306. R8G8B8A8Snorm = (R8G8B8A8 << 21) | (Snorm << 27), // 0x09400000
  307. R8G8B8A8Uint = (R8G8B8A8 << 21) | (Uint << 27), // 0x21400000
  308. R8G8B8A8Sint = (R8G8B8A8 << 21) | (Sint << 27), // 0x19400000
  309. R16G16B16A16Float = (R16G16B16A16 << 21) | (Float << 27), // 0x38600000
  310. R16G16B16A16Unorm = (R16G16B16A16 << 21) | (Unorm << 27), // 0x10600000
  311. R16G16B16A16Snorm = (R16G16B16A16 << 21) | (Snorm << 27), // 0x08600000
  312. R16G16B16A16Uint = (R16G16B16A16 << 21) | (Uint << 27), // 0x20600000
  313. R16G16B16A16Sint = (R16G16B16A16 << 21) | (Sint << 27), // 0x18600000
  314. R32G32B32A32Float = (R32G32B32A32 << 21) | (Float << 27), // 0x38200000
  315. R32G32B32A32Uint = (R32G32B32A32 << 21) | (Uint << 27), // 0x20200000
  316. R32G32B32A32Sint = (R32G32B32A32 << 21) | (Sint << 27), // 0x18200000
  317. A2B10G10R10Unorm = (A2B10G10R10 << 21) | (Unorm << 27), // 0x16000000
  318. A2B10G10R10Uint = (A2B10G10R10 << 21) | (Uint << 27), // 0x26000000
  319. B10G11R11Float = (B10G11R11 << 21) | (Float << 27), // 0x3e200000
  320. R8Uscaled = (R8 << 21) | (Uscaled << 27), // 0x2ba00000
  321. R8Sscaled = (R8 << 21) | (Sscaled << 27), // 0x33a00000
  322. R16Uscaled = (R16 << 21) | (Uscaled << 27), // 0x2b600000
  323. R16Sscaled = (R16 << 21) | (Sscaled << 27), // 0x33600000
  324. R32Uscaled = (R32 << 21) | (Uscaled << 27), // 0x2a400000
  325. R32Sscaled = (R32 << 21) | (Sscaled << 27), // 0x32400000
  326. R8G8Uscaled = (R8G8 << 21) | (Uscaled << 27), // 0x2b000000
  327. R8G8Sscaled = (R8G8 << 21) | (Sscaled << 27), // 0x33000000
  328. R16G16Uscaled = (R16G16 << 21) | (Uscaled << 27), // 0x29e00000
  329. R16G16Sscaled = (R16G16 << 21) | (Sscaled << 27), // 0x31e00000
  330. R32G32Uscaled = (R32G32 << 21) | (Uscaled << 27), // 0x28800000
  331. R32G32Sscaled = (R32G32 << 21) | (Sscaled << 27), // 0x30800000
  332. R8G8B8Uscaled = (R8G8B8 << 21) | (Uscaled << 27), // 0x2a600000
  333. R8G8B8Sscaled = (R8G8B8 << 21) | (Sscaled << 27), // 0x32600000
  334. R16G16B16Uscaled = (R16G16B16 << 21) | (Uscaled << 27), // 0x28a00000
  335. R16G16B16Sscaled = (R16G16B16 << 21) | (Sscaled << 27), // 0x30a00000
  336. R32G32B32Uscaled = (R32G32B32 << 21) | (Uscaled << 27), // 0x28400000
  337. R32G32B32Sscaled = (R32G32B32 << 21) | (Sscaled << 27), // 0x30400000
  338. R8G8B8A8Uscaled = (R8G8B8A8 << 21) | (Uscaled << 27), // 0x29400000
  339. R8G8B8A8Sscaled = (R8G8B8A8 << 21) | (Sscaled << 27), // 0x31400000
  340. R16G16B16A16Uscaled = (R16G16B16A16 << 21) | (Uscaled << 27), // 0x28600000
  341. R16G16B16A16Sscaled = (R16G16B16A16 << 21) | (Sscaled << 27), // 0x30600000
  342. R32G32B32A32Uscaled = (R32G32B32A32 << 21) | (Uscaled << 27), // 0x28200000
  343. R32G32B32A32Sscaled = (R32G32B32A32 << 21) | (Sscaled << 27), // 0x30200000
  344. A2B10G10R10Snorm = (A2B10G10R10 << 21) | (Snorm << 27), // 0x0e000000
  345. A2B10G10R10Sint = (A2B10G10R10 << 21) | (Sint << 27), // 0x1e000000
  346. A2B10G10R10Uscaled = (A2B10G10R10 << 21) | (Uscaled << 27), // 0x2e000000
  347. A2B10G10R10Sscaled = (A2B10G10R10 << 21) | (Sscaled << 27), // 0x36000000
  348. }
  349. private static readonly Dictionary<TextureFormat, FormatInfo> _textureFormats = new()
  350. {
  351. { TextureFormat.R8Unorm, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) },
  352. { TextureFormat.R8Snorm, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) },
  353. { TextureFormat.R8Uint, new FormatInfo(Format.R8Uint, 1, 1, 1, 1) },
  354. { TextureFormat.R8Sint, new FormatInfo(Format.R8Sint, 1, 1, 1, 1) },
  355. { TextureFormat.R16Float, new FormatInfo(Format.R16Float, 1, 1, 2, 1) },
  356. { TextureFormat.R16Unorm, new FormatInfo(Format.R16Unorm, 1, 1, 2, 1) },
  357. { TextureFormat.R16Snorm, new FormatInfo(Format.R16Snorm, 1, 1, 2, 1) },
  358. { TextureFormat.R16Uint, new FormatInfo(Format.R16Uint, 1, 1, 2, 1) },
  359. { TextureFormat.R16Sint, new FormatInfo(Format.R16Sint, 1, 1, 2, 1) },
  360. { TextureFormat.R32Float, new FormatInfo(Format.R32Float, 1, 1, 4, 1) },
  361. { TextureFormat.R32Uint, new FormatInfo(Format.R32Uint, 1, 1, 4, 1) },
  362. { TextureFormat.R32Sint, new FormatInfo(Format.R32Sint, 1, 1, 4, 1) },
  363. { TextureFormat.G8R8Unorm, new FormatInfo(Format.R8G8Unorm, 1, 1, 2, 2) },
  364. { TextureFormat.G8R8Snorm, new FormatInfo(Format.R8G8Snorm, 1, 1, 2, 2) },
  365. { TextureFormat.G8R8Uint, new FormatInfo(Format.R8G8Uint, 1, 1, 2, 2) },
  366. { TextureFormat.G8R8Sint, new FormatInfo(Format.R8G8Sint, 1, 1, 2, 2) },
  367. { TextureFormat.R16G16Float, new FormatInfo(Format.R16G16Float, 1, 1, 4, 2) },
  368. { TextureFormat.R16G16Unorm, new FormatInfo(Format.R16G16Unorm, 1, 1, 4, 2) },
  369. { TextureFormat.R16G16Snorm, new FormatInfo(Format.R16G16Snorm, 1, 1, 4, 2) },
  370. { TextureFormat.R16G16Uint, new FormatInfo(Format.R16G16Uint, 1, 1, 4, 2) },
  371. { TextureFormat.R16G16Sint, new FormatInfo(Format.R16G16Sint, 1, 1, 4, 2) },
  372. { TextureFormat.R32G32Float, new FormatInfo(Format.R32G32Float, 1, 1, 8, 2) },
  373. { TextureFormat.R32G32Uint, new FormatInfo(Format.R32G32Uint, 1, 1, 8, 2) },
  374. { TextureFormat.R32G32Sint, new FormatInfo(Format.R32G32Sint, 1, 1, 8, 2) },
  375. { TextureFormat.R32G32B32Float, new FormatInfo(Format.R32G32B32Float, 1, 1, 12, 3) },
  376. { TextureFormat.R32G32B32Uint, new FormatInfo(Format.R32G32B32Uint, 1, 1, 12, 3) },
  377. { TextureFormat.R32G32B32Sint, new FormatInfo(Format.R32G32B32Sint, 1, 1, 12, 3) },
  378. { TextureFormat.A8B8G8R8Unorm, new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4) },
  379. { TextureFormat.A8B8G8R8Snorm, new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4, 4) },
  380. { TextureFormat.A8B8G8R8Uint, new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4, 4) },
  381. { TextureFormat.A8B8G8R8Sint, new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4, 4) },
  382. { TextureFormat.R16G16B16A16Float, new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4) },
  383. { TextureFormat.R16G16B16A16Unorm, new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8, 4) },
  384. { TextureFormat.R16G16B16A16Snorm, new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8, 4) },
  385. { TextureFormat.R16G16B16A16Uint, new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8, 4) },
  386. { TextureFormat.R16G16B16A16Sint, new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8, 4) },
  387. { TextureFormat.R32G32B32A32Float, new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4) },
  388. { TextureFormat.R32G32B32A32Uint, new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4) },
  389. { TextureFormat.R32G32B32A32Sint, new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4) },
  390. { TextureFormat.Z16Unorm, new FormatInfo(Format.D16Unorm, 1, 1, 2, 1) },
  391. { TextureFormat.Zf32RFloatGUintBUintAUint, new FormatInfo(Format.D32Float, 1, 1, 4, 1) },
  392. { TextureFormat.Zf32Float, new FormatInfo(Format.D32Float, 1, 1, 4, 1) },
  393. { TextureFormat.G24R8RUintGUnormBUnormAUnorm, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
  394. { TextureFormat.Z24S8RUintGUnormBUnormAUnorm, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
  395. { TextureFormat.Z24S8RUintGUnormBUintAUint, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
  396. { TextureFormat.S8Z24RUnormGUintBUintAUint, new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2) },
  397. { TextureFormat.R32B24G8RFloatGUintBUnormAUnorm, new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2) },
  398. { TextureFormat.Zf32X24S8RFloatGUintBUnormAUnorm, new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2) },
  399. { TextureFormat.A8B8G8R8UnormSrgb, new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4) },
  400. { TextureFormat.G4R4Unorm, new FormatInfo(Format.R4G4Unorm, 1, 1, 1, 2) },
  401. { TextureFormat.A4B4G4R4Unorm, new FormatInfo(Format.R4G4B4A4Unorm, 1, 1, 2, 4) },
  402. { TextureFormat.A1B5G5R5Unorm, new FormatInfo(Format.R5G5B5A1Unorm, 1, 1, 2, 4) },
  403. { TextureFormat.B5G6R5Unorm, new FormatInfo(Format.R5G6B5Unorm, 1, 1, 2, 3) },
  404. { TextureFormat.A2B10G10R10Unorm, new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4, 4) },
  405. { TextureFormat.A2B10G10R10Uint, new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4, 4) },
  406. { TextureFormat.Bf10Gf11Rf11Float, new FormatInfo(Format.R11G11B10Float, 1, 1, 4, 3) },
  407. { TextureFormat.E5B9G9R9SharedExpFloat, new FormatInfo(Format.R9G9B9E5Float, 1, 1, 4, 4) },
  408. { TextureFormat.Bc1Unorm, new FormatInfo(Format.Bc1RgbaUnorm, 4, 4, 8, 4) },
  409. { TextureFormat.Bc2Unorm, new FormatInfo(Format.Bc2Unorm, 4, 4, 16, 4) },
  410. { TextureFormat.Bc3Unorm, new FormatInfo(Format.Bc3Unorm, 4, 4, 16, 4) },
  411. { TextureFormat.Bc1UnormSrgb, new FormatInfo(Format.Bc1RgbaSrgb, 4, 4, 8, 4) },
  412. { TextureFormat.Bc2UnormSrgb, new FormatInfo(Format.Bc2Srgb, 4, 4, 16, 4) },
  413. { TextureFormat.Bc3UnormSrgb, new FormatInfo(Format.Bc3Srgb, 4, 4, 16, 4) },
  414. { TextureFormat.Bc4Unorm, new FormatInfo(Format.Bc4Unorm, 4, 4, 8, 1) },
  415. { TextureFormat.Bc4Snorm, new FormatInfo(Format.Bc4Snorm, 4, 4, 8, 1) },
  416. { TextureFormat.Bc5Unorm, new FormatInfo(Format.Bc5Unorm, 4, 4, 16, 2) },
  417. { TextureFormat.Bc5Snorm, new FormatInfo(Format.Bc5Snorm, 4, 4, 16, 2) },
  418. { TextureFormat.Bc7UUnorm, new FormatInfo(Format.Bc7Unorm, 4, 4, 16, 4) },
  419. { TextureFormat.Bc7UUnormSrgb, new FormatInfo(Format.Bc7Srgb, 4, 4, 16, 4) },
  420. { TextureFormat.Bc6HSf16Float, new FormatInfo(Format.Bc6HSfloat, 4, 4, 16, 4) },
  421. { TextureFormat.Bc6HUf16Float, new FormatInfo(Format.Bc6HUfloat, 4, 4, 16, 4) },
  422. { TextureFormat.Etc2RgbUnorm, new FormatInfo(Format.Etc2RgbUnorm, 4, 4, 8, 3) },
  423. { TextureFormat.Etc2RgbPtaUnorm, new FormatInfo(Format.Etc2RgbPtaUnorm, 4, 4, 8, 4) },
  424. { TextureFormat.Etc2RgbaUnorm, new FormatInfo(Format.Etc2RgbaUnorm, 4, 4, 16, 4) },
  425. { TextureFormat.Etc2RgbUnormSrgb, new FormatInfo(Format.Etc2RgbSrgb, 4, 4, 8, 3) },
  426. { TextureFormat.Etc2RgbPtaUnormSrgb, new FormatInfo(Format.Etc2RgbPtaSrgb, 4, 4, 8, 4) },
  427. { TextureFormat.Etc2RgbaUnormSrgb, new FormatInfo(Format.Etc2RgbaSrgb, 4, 4, 16, 4) },
  428. { TextureFormat.Astc2D4x4Unorm, new FormatInfo(Format.Astc4x4Unorm, 4, 4, 16, 4) },
  429. { TextureFormat.Astc2D5x4Unorm, new FormatInfo(Format.Astc5x4Unorm, 5, 4, 16, 4) },
  430. { TextureFormat.Astc2D5x5Unorm, new FormatInfo(Format.Astc5x5Unorm, 5, 5, 16, 4) },
  431. { TextureFormat.Astc2D6x5Unorm, new FormatInfo(Format.Astc6x5Unorm, 6, 5, 16, 4) },
  432. { TextureFormat.Astc2D6x6Unorm, new FormatInfo(Format.Astc6x6Unorm, 6, 6, 16, 4) },
  433. { TextureFormat.Astc2D8x5Unorm, new FormatInfo(Format.Astc8x5Unorm, 8, 5, 16, 4) },
  434. { TextureFormat.Astc2D8x6Unorm, new FormatInfo(Format.Astc8x6Unorm, 8, 6, 16, 4) },
  435. { TextureFormat.Astc2D8x8Unorm, new FormatInfo(Format.Astc8x8Unorm, 8, 8, 16, 4) },
  436. { TextureFormat.Astc2D10x5Unorm, new FormatInfo(Format.Astc10x5Unorm, 10, 5, 16, 4) },
  437. { TextureFormat.Astc2D10x6Unorm, new FormatInfo(Format.Astc10x6Unorm, 10, 6, 16, 4) },
  438. { TextureFormat.Astc2D10x8Unorm, new FormatInfo(Format.Astc10x8Unorm, 10, 8, 16, 4) },
  439. { TextureFormat.Astc2D10x10Unorm, new FormatInfo(Format.Astc10x10Unorm, 10, 10, 16, 4) },
  440. { TextureFormat.Astc2D12x10Unorm, new FormatInfo(Format.Astc12x10Unorm, 12, 10, 16, 4) },
  441. { TextureFormat.Astc2D12x12Unorm, new FormatInfo(Format.Astc12x12Unorm, 12, 12, 16, 4) },
  442. { TextureFormat.Astc2D4x4UnormSrgb, new FormatInfo(Format.Astc4x4Srgb, 4, 4, 16, 4) },
  443. { TextureFormat.Astc2D5x4UnormSrgb, new FormatInfo(Format.Astc5x4Srgb, 5, 4, 16, 4) },
  444. { TextureFormat.Astc2D5x5UnormSrgb, new FormatInfo(Format.Astc5x5Srgb, 5, 5, 16, 4) },
  445. { TextureFormat.Astc2D6x5UnormSrgb, new FormatInfo(Format.Astc6x5Srgb, 6, 5, 16, 4) },
  446. { TextureFormat.Astc2D6x6UnormSrgb, new FormatInfo(Format.Astc6x6Srgb, 6, 6, 16, 4) },
  447. { TextureFormat.Astc2D8x5UnormSrgb, new FormatInfo(Format.Astc8x5Srgb, 8, 5, 16, 4) },
  448. { TextureFormat.Astc2D8x6UnormSrgb, new FormatInfo(Format.Astc8x6Srgb, 8, 6, 16, 4) },
  449. { TextureFormat.Astc2D8x8UnormSrgb, new FormatInfo(Format.Astc8x8Srgb, 8, 8, 16, 4) },
  450. { TextureFormat.Astc2D10x5UnormSrgb, new FormatInfo(Format.Astc10x5Srgb, 10, 5, 16, 4) },
  451. { TextureFormat.Astc2D10x6UnormSrgb, new FormatInfo(Format.Astc10x6Srgb, 10, 6, 16, 4) },
  452. { TextureFormat.Astc2D10x8UnormSrgb, new FormatInfo(Format.Astc10x8Srgb, 10, 8, 16, 4) },
  453. { TextureFormat.Astc2D10x10UnormSrgb, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) },
  454. { TextureFormat.Astc2D12x10UnormSrgb, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) },
  455. { TextureFormat.Astc2D12x12UnormSrgb, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) },
  456. { TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) },
  457. };
  458. private static readonly Dictionary<VertexAttributeFormat, Format> _attribFormats = new()
  459. {
  460. { VertexAttributeFormat.R8Unorm, Format.R8Unorm },
  461. { VertexAttributeFormat.R8Snorm, Format.R8Snorm },
  462. { VertexAttributeFormat.R8Uint, Format.R8Uint },
  463. { VertexAttributeFormat.R8Sint, Format.R8Sint },
  464. { VertexAttributeFormat.R16Float, Format.R16Float },
  465. { VertexAttributeFormat.R16Unorm, Format.R16Unorm },
  466. { VertexAttributeFormat.R16Snorm, Format.R16Snorm },
  467. { VertexAttributeFormat.R16Uint, Format.R16Uint },
  468. { VertexAttributeFormat.R16Sint, Format.R16Sint },
  469. { VertexAttributeFormat.R32Float, Format.R32Float },
  470. { VertexAttributeFormat.R32Uint, Format.R32Uint },
  471. { VertexAttributeFormat.R32Sint, Format.R32Sint },
  472. { VertexAttributeFormat.R8G8Unorm, Format.R8G8Unorm },
  473. { VertexAttributeFormat.R8G8Snorm, Format.R8G8Snorm },
  474. { VertexAttributeFormat.R8G8Uint, Format.R8G8Uint },
  475. { VertexAttributeFormat.R8G8Sint, Format.R8G8Sint },
  476. { VertexAttributeFormat.R16G16Float, Format.R16G16Float },
  477. { VertexAttributeFormat.R16G16Unorm, Format.R16G16Unorm },
  478. { VertexAttributeFormat.R16G16Snorm, Format.R16G16Snorm },
  479. { VertexAttributeFormat.R16G16Uint, Format.R16G16Uint },
  480. { VertexAttributeFormat.R16G16Sint, Format.R16G16Sint },
  481. { VertexAttributeFormat.R32G32Float, Format.R32G32Float },
  482. { VertexAttributeFormat.R32G32Uint, Format.R32G32Uint },
  483. { VertexAttributeFormat.R32G32Sint, Format.R32G32Sint },
  484. { VertexAttributeFormat.R8G8B8Unorm, Format.R8G8B8Unorm },
  485. { VertexAttributeFormat.R8G8B8Snorm, Format.R8G8B8Snorm },
  486. { VertexAttributeFormat.R8G8B8Uint, Format.R8G8B8Uint },
  487. { VertexAttributeFormat.R8G8B8Sint, Format.R8G8B8Sint },
  488. { VertexAttributeFormat.R16G16B16Float, Format.R16G16B16Float },
  489. { VertexAttributeFormat.R16G16B16Unorm, Format.R16G16B16Unorm },
  490. { VertexAttributeFormat.R16G16B16Snorm, Format.R16G16B16Snorm },
  491. { VertexAttributeFormat.R16G16B16Uint, Format.R16G16B16Uint },
  492. { VertexAttributeFormat.R16G16B16Sint, Format.R16G16B16Sint },
  493. { VertexAttributeFormat.R32G32B32Float, Format.R32G32B32Float },
  494. { VertexAttributeFormat.R32G32B32Uint, Format.R32G32B32Uint },
  495. { VertexAttributeFormat.R32G32B32Sint, Format.R32G32B32Sint },
  496. { VertexAttributeFormat.R8G8B8A8Unorm, Format.R8G8B8A8Unorm },
  497. { VertexAttributeFormat.R8G8B8A8Snorm, Format.R8G8B8A8Snorm },
  498. { VertexAttributeFormat.R8G8B8A8Uint, Format.R8G8B8A8Uint },
  499. { VertexAttributeFormat.R8G8B8A8Sint, Format.R8G8B8A8Sint },
  500. { VertexAttributeFormat.R16G16B16A16Float, Format.R16G16B16A16Float },
  501. { VertexAttributeFormat.R16G16B16A16Unorm, Format.R16G16B16A16Unorm },
  502. { VertexAttributeFormat.R16G16B16A16Snorm, Format.R16G16B16A16Snorm },
  503. { VertexAttributeFormat.R16G16B16A16Uint, Format.R16G16B16A16Uint },
  504. { VertexAttributeFormat.R16G16B16A16Sint, Format.R16G16B16A16Sint },
  505. { VertexAttributeFormat.R32G32B32A32Float, Format.R32G32B32A32Float },
  506. { VertexAttributeFormat.R32G32B32A32Uint, Format.R32G32B32A32Uint },
  507. { VertexAttributeFormat.R32G32B32A32Sint, Format.R32G32B32A32Sint },
  508. { VertexAttributeFormat.A2B10G10R10Unorm, Format.R10G10B10A2Unorm },
  509. { VertexAttributeFormat.A2B10G10R10Uint, Format.R10G10B10A2Uint },
  510. { VertexAttributeFormat.B10G11R11Float, Format.R11G11B10Float },
  511. { VertexAttributeFormat.R8Uscaled, Format.R8Uscaled },
  512. { VertexAttributeFormat.R8Sscaled, Format.R8Sscaled },
  513. { VertexAttributeFormat.R16Uscaled, Format.R16Uscaled },
  514. { VertexAttributeFormat.R16Sscaled, Format.R16Sscaled },
  515. { VertexAttributeFormat.R32Uscaled, Format.R32Uscaled },
  516. { VertexAttributeFormat.R32Sscaled, Format.R32Sscaled },
  517. { VertexAttributeFormat.R8G8Uscaled, Format.R8G8Uscaled },
  518. { VertexAttributeFormat.R8G8Sscaled, Format.R8G8Sscaled },
  519. { VertexAttributeFormat.R16G16Uscaled, Format.R16G16Uscaled },
  520. { VertexAttributeFormat.R16G16Sscaled, Format.R16G16Sscaled },
  521. { VertexAttributeFormat.R32G32Uscaled, Format.R32G32Uscaled },
  522. { VertexAttributeFormat.R32G32Sscaled, Format.R32G32Sscaled },
  523. { VertexAttributeFormat.R8G8B8Uscaled, Format.R8G8B8Uscaled },
  524. { VertexAttributeFormat.R8G8B8Sscaled, Format.R8G8B8Sscaled },
  525. { VertexAttributeFormat.R16G16B16Uscaled, Format.R16G16B16Uscaled },
  526. { VertexAttributeFormat.R16G16B16Sscaled, Format.R16G16B16Sscaled },
  527. { VertexAttributeFormat.R32G32B32Uscaled, Format.R32G32B32Uscaled },
  528. { VertexAttributeFormat.R32G32B32Sscaled, Format.R32G32B32Sscaled },
  529. { VertexAttributeFormat.R8G8B8A8Uscaled, Format.R8G8B8A8Uscaled },
  530. { VertexAttributeFormat.R8G8B8A8Sscaled, Format.R8G8B8A8Sscaled },
  531. { VertexAttributeFormat.R16G16B16A16Uscaled, Format.R16G16B16A16Uscaled },
  532. { VertexAttributeFormat.R16G16B16A16Sscaled, Format.R16G16B16A16Sscaled },
  533. { VertexAttributeFormat.R32G32B32A32Uscaled, Format.R32G32B32A32Uscaled },
  534. { VertexAttributeFormat.R32G32B32A32Sscaled, Format.R32G32B32A32Sscaled },
  535. { VertexAttributeFormat.A2B10G10R10Snorm, Format.R10G10B10A2Snorm },
  536. { VertexAttributeFormat.A2B10G10R10Sint, Format.R10G10B10A2Sint },
  537. { VertexAttributeFormat.A2B10G10R10Uscaled, Format.R10G10B10A2Uscaled },
  538. { VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled },
  539. };
  540. #pragma warning restore IDE0055
  541. /// <summary>
  542. /// Try getting the texture format from an encoded format integer from the Maxwell texture descriptor.
  543. /// </summary>
  544. /// <param name="encoded">The encoded format integer from the texture descriptor</param>
  545. /// <param name="isSrgb">Indicates if the format is a sRGB format</param>
  546. /// <param name="format">The output texture format</param>
  547. /// <returns>True if the format is valid, false otherwise</returns>
  548. public static bool TryGetTextureFormat(uint encoded, bool isSrgb, out FormatInfo format)
  549. {
  550. encoded |= (isSrgb ? 1u << 19 : 0u);
  551. return _textureFormats.TryGetValue((TextureFormat)encoded, out format);
  552. }
  553. /// <summary>
  554. /// Try getting the vertex attribute format from an encoded format integer from Maxwell attribute registers.
  555. /// </summary>
  556. /// <param name="encoded">The encoded format integer from the attribute registers</param>
  557. /// <param name="format">The output vertex attribute format</param>
  558. /// <returns>True if the format is valid, false otherwise</returns>
  559. public static bool TryGetAttribFormat(uint encoded, out Format format)
  560. {
  561. return _attribFormats.TryGetValue((VertexAttributeFormat)encoded, out format);
  562. }
  563. }
  564. }