TextureCompatibility.cs 25 KB

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