FormatInfo.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Ryujinx.Graphics.GAL;
  2. namespace Ryujinx.Graphics.Gpu.Image
  3. {
  4. /// <summary>
  5. /// Represents texture format information.
  6. /// </summary>
  7. struct FormatInfo
  8. {
  9. /// <summary>
  10. /// A default, generic RGBA8 texture format.
  11. /// </summary>
  12. public static FormatInfo Default { get; } = new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
  13. /// <summary>
  14. /// The format of the texture data.
  15. /// </summary>
  16. public Format Format { get; }
  17. /// <summary>
  18. /// The block width for compressed formats.
  19. /// </summary>
  20. /// <remarks>
  21. /// Must be 1 for non-compressed formats.
  22. /// </remarks>
  23. public int BlockWidth { get; }
  24. /// <summary>
  25. /// The block height for compressed formats.
  26. /// </summary>
  27. /// <remarks>
  28. /// Must be 1 for non-compressed formats.
  29. /// </remarks>
  30. public int BlockHeight { get; }
  31. /// <summary>
  32. /// The number of bytes occupied by a single pixel in memory of the texture data.
  33. /// </summary>
  34. public int BytesPerPixel { get; }
  35. /// <summary>
  36. /// The maximum number of components this format has defined (in RGBA order).
  37. /// </summary>
  38. public int Components { get; }
  39. /// <summary>
  40. /// Whenever or not the texture format is a compressed format. Determined from block size.
  41. /// </summary>
  42. public bool IsCompressed => (BlockWidth | BlockHeight) != 1;
  43. /// <summary>
  44. /// Constructs the texture format info structure.
  45. /// </summary>
  46. /// <param name="format">The format of the texture data</param>
  47. /// <param name="blockWidth">The block width for compressed formats. Must be 1 for non-compressed formats</param>
  48. /// <param name="blockHeight">The block height for compressed formats. Must be 1 for non-compressed formats</param>
  49. /// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param>
  50. public FormatInfo(
  51. Format format,
  52. int blockWidth,
  53. int blockHeight,
  54. int bytesPerPixel,
  55. int components)
  56. {
  57. Format = format;
  58. BlockWidth = blockWidth;
  59. BlockHeight = blockHeight;
  60. BytesPerPixel = bytesPerPixel;
  61. Components = components;
  62. }
  63. }
  64. }