TextureCompatibility.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. using Ryujinx.Common;
  2. using Ryujinx.Graphics.GAL;
  3. using Ryujinx.Graphics.Texture;
  4. using System;
  5. namespace Ryujinx.Graphics.Gpu.Image
  6. {
  7. /// <summary>
  8. /// Texture format compatibility checks.
  9. /// </summary>
  10. static class TextureCompatibility
  11. {
  12. private enum FormatClass
  13. {
  14. Unclassified,
  15. BCn64,
  16. BCn128,
  17. Bc1Rgb,
  18. Bc1Rgba,
  19. Bc2,
  20. Bc3,
  21. Bc4,
  22. Bc5,
  23. Bc6,
  24. Bc7
  25. }
  26. /// <summary>
  27. /// Checks if a format is host incompatible.
  28. /// </summary>
  29. /// <remarks>
  30. /// Host incompatible formats can't be used directly, the texture data needs to be converted
  31. /// to a compatible format first.
  32. /// </remarks>
  33. /// <param name="info">Texture information</param>
  34. /// <param name="caps">Host GPU capabilities</param>
  35. /// <returns>True if the format is incompatible, false otherwise</returns>
  36. public static bool IsFormatHostIncompatible(TextureInfo info, Capabilities caps)
  37. {
  38. Format originalFormat = info.FormatInfo.Format;
  39. return ToHostCompatibleFormat(info, caps).Format != originalFormat;
  40. }
  41. /// <summary>
  42. /// Converts a incompatible format to a host compatible format, or return the format directly
  43. /// if it is already host compatible.
  44. /// </summary>
  45. /// <remarks>
  46. /// This can be used to convert a incompatible compressed format to the decompressor
  47. /// output format.
  48. /// </remarks>
  49. /// <param name="info">Texture information</param>
  50. /// <param name="caps">Host GPU capabilities</param>
  51. /// <returns>A host compatible format</returns>
  52. public static FormatInfo ToHostCompatibleFormat(TextureInfo info, Capabilities caps)
  53. {
  54. if (!caps.SupportsAstcCompression)
  55. {
  56. if (info.FormatInfo.Format.IsAstcUnorm())
  57. {
  58. return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
  59. }
  60. else if (info.FormatInfo.Format.IsAstcSrgb())
  61. {
  62. return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4);
  63. }
  64. }
  65. if (info.Target == Target.Texture3D)
  66. {
  67. // The host API does not support 3D BC4/BC5 compressed formats.
  68. // We assume software decompression will be done for those textures,
  69. // and so we adjust the format here to match the decompressor output.
  70. switch (info.FormatInfo.Format)
  71. {
  72. case Format.Bc4Unorm:
  73. return new FormatInfo(Format.R8Unorm, 1, 1, 1, 1);
  74. case Format.Bc4Snorm:
  75. return new FormatInfo(Format.R8Snorm, 1, 1, 1, 1);
  76. case Format.Bc5Unorm:
  77. return new FormatInfo(Format.R8G8Unorm, 1, 1, 2, 2);
  78. case Format.Bc5Snorm:
  79. return new FormatInfo(Format.R8G8Snorm, 1, 1, 2, 2);
  80. }
  81. }
  82. return info.FormatInfo;
  83. }
  84. /// <summary>
  85. /// Checks if two formats are compatible, according to the host API copy format compatibility rules.
  86. /// </summary>
  87. /// <param name="lhs">First comparand</param>
  88. /// <param name="rhs">Second comparand</param>
  89. /// <returns>True if the formats are compatible, false otherwise</returns>
  90. public static bool FormatCompatible(FormatInfo lhs, FormatInfo rhs)
  91. {
  92. if (lhs.Format.IsDepthOrStencil() || rhs.Format.IsDepthOrStencil())
  93. {
  94. return lhs.Format == rhs.Format;
  95. }
  96. if (lhs.Format.IsAstc() || rhs.Format.IsAstc())
  97. {
  98. return lhs.Format == rhs.Format;
  99. }
  100. if (lhs.IsCompressed && rhs.IsCompressed)
  101. {
  102. FormatClass lhsClass = GetFormatClass(lhs.Format);
  103. FormatClass rhsClass = GetFormatClass(rhs.Format);
  104. return lhsClass == rhsClass;
  105. }
  106. else
  107. {
  108. return lhs.BytesPerPixel == rhs.BytesPerPixel;
  109. }
  110. }
  111. /// <summary>
  112. /// Checks if the texture format matches with the specified texture information.
  113. /// </summary>
  114. /// <param name="lhs">Texture information to compare</param>
  115. /// <param name="rhs">Texture information to compare with</param>
  116. /// <param name="forSampler">Indicates that the texture will be used for shader sampling</param>
  117. /// <param name="forCopy">Indicates that the texture will be used as copy source or target</param>
  118. /// <returns>A value indicating how well the formats match</returns>
  119. public static TextureMatchQuality FormatMatches(TextureInfo lhs, TextureInfo rhs, bool forSampler, bool forCopy)
  120. {
  121. // D32F and R32F texture have the same representation internally,
  122. // however the R32F format is used to sample from depth textures.
  123. if (lhs.FormatInfo.Format == Format.D32Float && rhs.FormatInfo.Format == Format.R32Float && (forSampler || forCopy))
  124. {
  125. return TextureMatchQuality.FormatAlias;
  126. }
  127. if (forCopy)
  128. {
  129. // The 2D engine does not support depth-stencil formats, so it will instead
  130. // use equivalent color formats. We must also consider them as compatible.
  131. if (lhs.FormatInfo.Format == Format.S8Uint && rhs.FormatInfo.Format == Format.R8Unorm)
  132. {
  133. return TextureMatchQuality.FormatAlias;
  134. }
  135. if (lhs.FormatInfo.Format == Format.D16Unorm && rhs.FormatInfo.Format == Format.R16Unorm)
  136. {
  137. return TextureMatchQuality.FormatAlias;
  138. }
  139. if ((lhs.FormatInfo.Format == Format.D24UnormS8Uint ||
  140. lhs.FormatInfo.Format == Format.D24X8Unorm) && rhs.FormatInfo.Format == Format.B8G8R8A8Unorm)
  141. {
  142. return TextureMatchQuality.FormatAlias;
  143. }
  144. }
  145. return lhs.FormatInfo.Format == rhs.FormatInfo.Format ? TextureMatchQuality.Perfect : TextureMatchQuality.NoMatch;
  146. }
  147. /// <summary>
  148. /// Checks if the texture layout specified matches with this texture layout.
  149. /// The layout information is composed of the Stride for linear textures, or GOB block size
  150. /// for block linear textures.
  151. /// </summary>
  152. /// <param name="lhs">Texture information to compare</param>
  153. /// <param name="rhs">Texture information to compare with</param>
  154. /// <returns>True if the layout matches, false otherwise</returns>
  155. public static bool LayoutMatches(TextureInfo lhs, TextureInfo rhs)
  156. {
  157. if (lhs.IsLinear != rhs.IsLinear)
  158. {
  159. return false;
  160. }
  161. // For linear textures, gob block sizes are ignored.
  162. // For block linear textures, the stride is ignored.
  163. if (rhs.IsLinear)
  164. {
  165. return lhs.Stride == rhs.Stride;
  166. }
  167. else
  168. {
  169. return lhs.GobBlocksInY == rhs.GobBlocksInY &&
  170. lhs.GobBlocksInZ == rhs.GobBlocksInZ;
  171. }
  172. }
  173. /// <summary>
  174. /// Obtain the minimum compatibility level of two provided view compatibility results.
  175. /// </summary>
  176. /// <param name="first">The first compatibility level</param>
  177. /// <param name="second">The second compatibility level</param>
  178. /// <returns>The minimum compatibility level of two provided view compatibility results</returns>
  179. public static TextureViewCompatibility PropagateViewCompatibility(TextureViewCompatibility first, TextureViewCompatibility second)
  180. {
  181. if (first == TextureViewCompatibility.Incompatible || second == TextureViewCompatibility.Incompatible)
  182. {
  183. return TextureViewCompatibility.Incompatible;
  184. }
  185. else if (first == TextureViewCompatibility.CopyOnly || second == TextureViewCompatibility.CopyOnly)
  186. {
  187. return TextureViewCompatibility.CopyOnly;
  188. }
  189. else
  190. {
  191. return TextureViewCompatibility.Full;
  192. }
  193. }
  194. /// <summary>
  195. /// Checks if the sizes of two given textures are view compatible.
  196. /// </summary>
  197. /// <param name="lhs">Texture information of the texture view</param>
  198. /// <param name="rhs">Texture information of the texture view to match against</param>
  199. /// <param name="level">Mipmap level of the texture view in relation to this texture</param>
  200. /// <returns>The view compatibility level of the view sizes</returns>
  201. public static TextureViewCompatibility ViewSizeMatches(TextureInfo lhs, TextureInfo rhs, int level)
  202. {
  203. Size size = GetAlignedSize(lhs, level);
  204. Size otherSize = GetAlignedSize(rhs);
  205. TextureViewCompatibility result = TextureViewCompatibility.Full;
  206. // For copies, we can copy a subset of the 3D texture slices,
  207. // so the depth may be different in this case.
  208. if (rhs.Target == Target.Texture3D && size.Depth != otherSize.Depth)
  209. {
  210. result = TextureViewCompatibility.CopyOnly;
  211. }
  212. if (size.Width == otherSize.Width && size.Height == otherSize.Height)
  213. {
  214. return result;
  215. }
  216. else if (lhs.IsLinear && rhs.IsLinear)
  217. {
  218. // Copy between linear textures with matching stride.
  219. int stride = BitUtils.AlignUp(Math.Max(1, lhs.Stride >> level), Constants.StrideAlignment);
  220. return stride == rhs.Stride ? TextureViewCompatibility.CopyOnly : TextureViewCompatibility.Incompatible;
  221. }
  222. else
  223. {
  224. return TextureViewCompatibility.Incompatible;
  225. }
  226. }
  227. /// <summary>
  228. /// Checks if the potential child texture fits within the level and layer bounds of the parent.
  229. /// </summary>
  230. /// <param name="parent">Texture information for the parent</param>
  231. /// <param name="child">Texture information for the child</param>
  232. /// <param name="layer">Base layer of the child texture</param>
  233. /// <param name="level">Base level of the child texture</param>
  234. /// <returns>Full compatiblity if the child's layer and level count fit within the parent, incompatible otherwise</returns>
  235. public static TextureViewCompatibility ViewSubImagesInBounds(TextureInfo parent, TextureInfo child, int layer, int level)
  236. {
  237. if (level + child.Levels <= parent.Levels &&
  238. layer + child.GetSlices() <= parent.GetSlices())
  239. {
  240. return TextureViewCompatibility.Full;
  241. }
  242. else
  243. {
  244. return TextureViewCompatibility.Incompatible;
  245. }
  246. }
  247. /// <summary>
  248. /// Checks if the texture sizes of the supplied texture informations match.
  249. /// </summary>
  250. /// <param name="lhs">Texture information to compare</param>
  251. /// <param name="rhs">Texture information to compare with</param>
  252. /// <returns>True if the size matches, false otherwise</returns>
  253. public static bool SizeMatches(TextureInfo lhs, TextureInfo rhs)
  254. {
  255. return SizeMatches(lhs, rhs, alignSizes: false);
  256. }
  257. /// <summary>
  258. /// Checks if the texture sizes of the supplied texture informations match the given level
  259. /// </summary>
  260. /// <param name="lhs">Texture information to compare</param>
  261. /// <param name="rhs">Texture information to compare with</param>
  262. /// <param name="level">Mipmap level of this texture to compare with</param>
  263. /// <returns>True if the size matches with the level, false otherwise</returns>
  264. public static bool SizeMatches(TextureInfo lhs, TextureInfo rhs, int level)
  265. {
  266. return Math.Max(1, lhs.Width >> level) == rhs.Width &&
  267. Math.Max(1, lhs.Height >> level) == rhs.Height &&
  268. Math.Max(1, lhs.GetDepth() >> level) == rhs.GetDepth();
  269. }
  270. /// <summary>
  271. /// Checks if the texture sizes of the supplied texture informations match.
  272. /// </summary>
  273. /// <param name="lhs">Texture information to compare</param>
  274. /// <param name="rhs">Texture information to compare with</param>
  275. /// <param name="alignSizes">True to align the sizes according to the texture layout for comparison</param>
  276. /// <returns>True if the sizes matches, false otherwise</returns>
  277. public static bool SizeMatches(TextureInfo lhs, TextureInfo rhs, bool alignSizes)
  278. {
  279. if (lhs.GetLayers() != rhs.GetLayers())
  280. {
  281. return false;
  282. }
  283. bool isTextureBuffer = lhs.Target == Target.TextureBuffer || rhs.Target == Target.TextureBuffer;
  284. if (alignSizes && !isTextureBuffer)
  285. {
  286. Size size0 = GetAlignedSize(lhs);
  287. Size size1 = GetAlignedSize(rhs);
  288. return size0.Width == size1.Width &&
  289. size0.Height == size1.Height &&
  290. size0.Depth == size1.Depth;
  291. }
  292. else
  293. {
  294. return lhs.Width == rhs.Width &&
  295. lhs.Height == rhs.Height &&
  296. lhs.GetDepth() == rhs.GetDepth();
  297. }
  298. }
  299. /// <summary>
  300. /// Gets the aligned sizes of the specified texture information.
  301. /// The alignment depends on the texture layout and format bytes per pixel.
  302. /// </summary>
  303. /// <param name="info">Texture information to calculate the aligned size from</param>
  304. /// <param name="level">Mipmap level for texture views</param>
  305. /// <returns>The aligned texture size</returns>
  306. public static Size GetAlignedSize(TextureInfo info, int level = 0)
  307. {
  308. int width = Math.Max(1, info.Width >> level);
  309. int height = Math.Max(1, info.Height >> level);
  310. if (info.IsLinear)
  311. {
  312. return SizeCalculator.GetLinearAlignedSize(
  313. width,
  314. height,
  315. info.FormatInfo.BlockWidth,
  316. info.FormatInfo.BlockHeight,
  317. info.FormatInfo.BytesPerPixel);
  318. }
  319. else
  320. {
  321. int depth = Math.Max(1, info.GetDepth() >> level);
  322. return SizeCalculator.GetBlockLinearAlignedSize(
  323. width,
  324. height,
  325. depth,
  326. info.FormatInfo.BlockWidth,
  327. info.FormatInfo.BlockHeight,
  328. info.FormatInfo.BytesPerPixel,
  329. info.GobBlocksInY,
  330. info.GobBlocksInZ,
  331. info.GobBlocksInTileX);
  332. }
  333. }
  334. /// <summary>
  335. /// Check if it's possible to create a view with the layout of the second texture information from the first.
  336. /// The layout information is composed of the Stride for linear textures, or GOB block size
  337. /// for block linear textures.
  338. /// </summary>
  339. /// <param name="lhs">Texture information of the texture view</param>
  340. /// <param name="rhs">Texture information of the texture view to compare against</param>
  341. /// <param name="level">Start level of the texture view, in relation with the first texture</param>
  342. /// <returns>True if the layout is compatible, false otherwise</returns>
  343. public static bool ViewLayoutCompatible(TextureInfo lhs, TextureInfo rhs, int level)
  344. {
  345. if (lhs.IsLinear != rhs.IsLinear)
  346. {
  347. return false;
  348. }
  349. // For linear textures, gob block sizes are ignored.
  350. // For block linear textures, the stride is ignored.
  351. if (rhs.IsLinear)
  352. {
  353. int stride = Math.Max(1, lhs.Stride >> level);
  354. stride = BitUtils.AlignUp(stride, 32);
  355. return stride == rhs.Stride;
  356. }
  357. else
  358. {
  359. int height = Math.Max(1, lhs.Height >> level);
  360. int depth = Math.Max(1, lhs.GetDepth() >> level);
  361. (int gobBlocksInY, int gobBlocksInZ) = SizeCalculator.GetMipGobBlockSizes(
  362. height,
  363. depth,
  364. lhs.FormatInfo.BlockHeight,
  365. lhs.GobBlocksInY,
  366. lhs.GobBlocksInZ);
  367. return gobBlocksInY == rhs.GobBlocksInY &&
  368. gobBlocksInZ == rhs.GobBlocksInZ;
  369. }
  370. }
  371. /// <summary>
  372. /// Checks if the view format of the first texture format is compatible with the format of the second.
  373. /// In general, the formats are considered compatible if the bytes per pixel values are equal,
  374. /// but there are more complex rules for some formats, like compressed or depth-stencil formats.
  375. /// This follows the host API copy compatibility rules.
  376. /// </summary>
  377. /// <param name="lhs">Texture information of the texture view</param>
  378. /// <param name="rhs">Texture information of the texture view</param>
  379. /// <returns>The view compatibility level of the texture formats</returns>
  380. public static TextureViewCompatibility ViewFormatCompatible(TextureInfo lhs, TextureInfo rhs)
  381. {
  382. if (FormatCompatible(lhs.FormatInfo, rhs.FormatInfo))
  383. {
  384. if (lhs.FormatInfo.IsCompressed != rhs.FormatInfo.IsCompressed)
  385. {
  386. return TextureViewCompatibility.CopyOnly;
  387. }
  388. else
  389. {
  390. return TextureViewCompatibility.Full;
  391. }
  392. }
  393. return TextureViewCompatibility.Incompatible;
  394. }
  395. /// <summary>
  396. /// Check if the target of the first texture view information is compatible with the target of the second texture view information.
  397. /// This follows the host API target compatibility rules.
  398. /// </summary>
  399. /// <param name="lhs">Texture information of the texture view</param
  400. /// <param name="rhs">Texture information of the texture view</param>
  401. /// <param name="isCopy">True to check for copy rather than view compatibility</param>
  402. /// <returns>True if the targets are compatible, false otherwise</returns>
  403. public static TextureViewCompatibility ViewTargetCompatible(TextureInfo lhs, TextureInfo rhs)
  404. {
  405. bool result = false;
  406. switch (lhs.Target)
  407. {
  408. case Target.Texture1D:
  409. case Target.Texture1DArray:
  410. result = rhs.Target == Target.Texture1D ||
  411. rhs.Target == Target.Texture1DArray;
  412. break;
  413. case Target.Texture2D:
  414. result = rhs.Target == Target.Texture2D ||
  415. rhs.Target == Target.Texture2DArray;
  416. break;
  417. case Target.Texture2DArray:
  418. case Target.Cubemap:
  419. case Target.CubemapArray:
  420. result = rhs.Target == Target.Texture2D ||
  421. rhs.Target == Target.Texture2DArray ||
  422. rhs.Target == Target.Cubemap ||
  423. rhs.Target == Target.CubemapArray;
  424. break;
  425. case Target.Texture2DMultisample:
  426. case Target.Texture2DMultisampleArray:
  427. result = rhs.Target == Target.Texture2DMultisample ||
  428. rhs.Target == Target.Texture2DMultisampleArray;
  429. break;
  430. case Target.Texture3D:
  431. if (rhs.Target == Target.Texture2D)
  432. {
  433. return TextureViewCompatibility.CopyOnly;
  434. }
  435. result = rhs.Target == Target.Texture3D;
  436. break;
  437. }
  438. return result ? TextureViewCompatibility.Full : TextureViewCompatibility.Incompatible;
  439. }
  440. /// <summary>
  441. /// Checks if a swizzle component in two textures functionally match, taking into account if the components are defined.
  442. /// </summary>
  443. /// <param name="lhs">Texture information to compare</param>
  444. /// <param name="rhs">Texture information to compare with</param>
  445. /// <param name="swizzleLhs">Swizzle component for the first texture</param>
  446. /// <param name="swizzleRhs">Swizzle component for the second texture</param>
  447. /// <param name="component">Component index, starting at 0 for red</param>
  448. /// <returns>True if the swizzle components functionally match, false othersize</returns>
  449. private static bool SwizzleComponentMatches(TextureInfo lhs, TextureInfo rhs, SwizzleComponent swizzleLhs, SwizzleComponent swizzleRhs, int component)
  450. {
  451. int lhsComponents = lhs.FormatInfo.Components;
  452. int rhsComponents = rhs.FormatInfo.Components;
  453. if (lhsComponents == 4 && rhsComponents == 4)
  454. {
  455. return swizzleLhs == swizzleRhs;
  456. }
  457. // Swizzles after the number of components a format defines are "undefined".
  458. // We allow these to not be equal under certain circumstances.
  459. // This can only happen when there are less than 4 components in a format.
  460. // It tends to happen when float depth textures are sampled.
  461. bool lhsDefined = (swizzleLhs - SwizzleComponent.Red) < lhsComponents;
  462. bool rhsDefined = (swizzleRhs - SwizzleComponent.Red) < rhsComponents;
  463. if (lhsDefined == rhsDefined)
  464. {
  465. // If both are undefined, return true. Otherwise just check if they're equal.
  466. return lhsDefined ? swizzleLhs == swizzleRhs : true;
  467. }
  468. else
  469. {
  470. SwizzleComponent defined = lhsDefined ? swizzleLhs : swizzleRhs;
  471. SwizzleComponent undefined = lhsDefined ? swizzleRhs : swizzleLhs;
  472. // Undefined swizzle can be matched by a forced value (0, 1), exact equality, or expected value.
  473. // For example, R___ matches R001, RGBA but not RBGA.
  474. return defined == undefined || defined < SwizzleComponent.Red || defined == SwizzleComponent.Red + component;
  475. }
  476. }
  477. /// <summary>
  478. /// Checks if the texture shader sampling parameters of two texture informations match.
  479. /// </summary>
  480. /// <param name="lhs">Texture information to compare</param>
  481. /// <param name="rhs">Texture information to compare with</param>
  482. /// <returns>True if the texture shader sampling parameters matches, false otherwise</returns>
  483. public static bool SamplerParamsMatches(TextureInfo lhs, TextureInfo rhs)
  484. {
  485. return lhs.DepthStencilMode == rhs.DepthStencilMode &&
  486. SwizzleComponentMatches(lhs, rhs, lhs.SwizzleR, rhs.SwizzleR, 0) &&
  487. SwizzleComponentMatches(lhs, rhs, lhs.SwizzleG, rhs.SwizzleG, 1) &&
  488. SwizzleComponentMatches(lhs, rhs, lhs.SwizzleB, rhs.SwizzleB, 2) &&
  489. SwizzleComponentMatches(lhs, rhs, lhs.SwizzleA, rhs.SwizzleA, 3);
  490. }
  491. /// <summary>
  492. /// Check if the texture target and samples count (for multisampled textures) matches.
  493. /// </summary>
  494. /// <param name="first">Texture information to compare with</param>
  495. /// <param name="rhs">Texture information to compare with</param>
  496. /// <returns>True if the texture target and samples count matches, false otherwise</returns>
  497. public static bool TargetAndSamplesCompatible(TextureInfo lhs, TextureInfo rhs)
  498. {
  499. return lhs.Target == rhs.Target &&
  500. lhs.SamplesInX == rhs.SamplesInX &&
  501. lhs.SamplesInY == rhs.SamplesInY;
  502. }
  503. /// <summary>
  504. /// Gets the texture format class, for compressed textures, or Unclassified otherwise.
  505. /// </summary>
  506. /// <param name="format">The format</param>
  507. /// <returns>Format class</returns>
  508. private static FormatClass GetFormatClass(Format format)
  509. {
  510. switch (format)
  511. {
  512. case Format.Bc1RgbSrgb:
  513. case Format.Bc1RgbUnorm:
  514. return FormatClass.Bc1Rgb;
  515. case Format.Bc1RgbaSrgb:
  516. case Format.Bc1RgbaUnorm:
  517. return FormatClass.Bc1Rgba;
  518. case Format.Bc2Srgb:
  519. case Format.Bc2Unorm:
  520. return FormatClass.Bc2;
  521. case Format.Bc3Srgb:
  522. case Format.Bc3Unorm:
  523. return FormatClass.Bc3;
  524. case Format.Bc4Snorm:
  525. case Format.Bc4Unorm:
  526. return FormatClass.Bc4;
  527. case Format.Bc5Snorm:
  528. case Format.Bc5Unorm:
  529. return FormatClass.Bc5;
  530. case Format.Bc6HSfloat:
  531. case Format.Bc6HUfloat:
  532. return FormatClass.Bc6;
  533. case Format.Bc7Srgb:
  534. case Format.Bc7Unorm:
  535. return FormatClass.Bc7;
  536. }
  537. return FormatClass.Unclassified;
  538. }
  539. }
  540. }