FormatInfo.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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);
  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. /// Whenever or not the texture format is a compressed format. Determined from block size.
  37. /// </summary>
  38. public bool IsCompressed => (BlockWidth | BlockHeight) != 1;
  39. /// <summary>
  40. /// Constructs the texture format info structure.
  41. /// </summary>
  42. /// <param name="format">The format of the texture data</param>
  43. /// <param name="blockWidth">The block width for compressed formats. Must be 1 for non-compressed formats</param>
  44. /// <param name="blockHeight">The block height for compressed formats. Must be 1 for non-compressed formats</param>
  45. /// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param>
  46. public FormatInfo(
  47. Format format,
  48. int blockWidth,
  49. int blockHeight,
  50. int bytesPerPixel)
  51. {
  52. Format = format;
  53. BlockWidth = blockWidth;
  54. BlockHeight = blockHeight;
  55. BytesPerPixel = bytesPerPixel;
  56. }
  57. }
  58. }