FormatInfo.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. Must be 1 for non-compressed formats.
  19. /// </summary>
  20. public int BlockWidth { get; }
  21. /// <summary>
  22. /// The block height for compressed formats. Must be 1 for non-compressed formats.
  23. /// </summary>
  24. public int BlockHeight { get; }
  25. /// <summary>
  26. /// The number of bytes occupied by a single pixel in memory of the texture data.
  27. /// </summary>
  28. public int BytesPerPixel { get; }
  29. /// <summary>
  30. /// Whenever or not the texture format is a compressed format. Determined from block size.
  31. /// </summary>
  32. public bool IsCompressed => (BlockWidth | BlockHeight) != 1;
  33. /// <summary>
  34. /// Constructs the texture format info structure.
  35. /// </summary>
  36. /// <param name="format">The format of the texture data</param>
  37. /// <param name="blockWidth">The block width for compressed formats. Must be 1 for non-compressed formats</param>
  38. /// <param name="blockHeight">The block height for compressed formats. Must be 1 for non-compressed formats</param>
  39. /// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param>
  40. public FormatInfo(
  41. Format format,
  42. int blockWidth,
  43. int blockHeight,
  44. int bytesPerPixel)
  45. {
  46. Format = format;
  47. BlockWidth = blockWidth;
  48. BlockHeight = blockHeight;
  49. BytesPerPixel = bytesPerPixel;
  50. }
  51. }
  52. }