FormatTable.cs 44 KB

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