2019-10-12 23:02:07 -07:00
|
|
|
using Ryujinx.Graphics.GAL;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Image
|
|
|
|
{
|
2019-12-29 15:26:37 -08:00
|
|
|
/// <summary>
|
|
|
|
/// Represents texture format information.
|
|
|
|
/// </summary>
|
2022-12-05 05:47:39 -08:00
|
|
|
readonly struct FormatInfo
|
2019-10-12 23:02:07 -07:00
|
|
|
{
|
2019-12-29 15:26:37 -08:00
|
|
|
/// <summary>
|
|
|
|
/// A default, generic RGBA8 texture format.
|
|
|
|
/// </summary>
|
2020-09-10 16:48:48 -07:00
|
|
|
public static FormatInfo Default { get; } = new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
|
2019-10-12 23:02:07 -07:00
|
|
|
|
2019-12-29 15:26:37 -08:00
|
|
|
/// <summary>
|
|
|
|
/// The format of the texture data.
|
|
|
|
/// </summary>
|
2019-10-12 23:02:07 -07:00
|
|
|
public Format Format { get; }
|
|
|
|
|
2019-12-29 15:26:37 -08:00
|
|
|
/// <summary>
|
2020-01-01 07:39:09 -08:00
|
|
|
/// The block width for compressed formats.
|
2019-12-29 15:26:37 -08:00
|
|
|
/// </summary>
|
2020-01-01 07:39:09 -08:00
|
|
|
/// <remarks>
|
|
|
|
/// Must be 1 for non-compressed formats.
|
|
|
|
/// </remarks>
|
2019-12-29 15:26:37 -08:00
|
|
|
public int BlockWidth { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-01-01 07:39:09 -08:00
|
|
|
/// The block height for compressed formats.
|
2019-12-29 15:26:37 -08:00
|
|
|
/// </summary>
|
2020-01-01 07:39:09 -08:00
|
|
|
/// <remarks>
|
|
|
|
/// Must be 1 for non-compressed formats.
|
|
|
|
/// </remarks>
|
2019-12-29 15:26:37 -08:00
|
|
|
public int BlockHeight { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The number of bytes occupied by a single pixel in memory of the texture data.
|
|
|
|
/// </summary>
|
2019-10-12 23:02:07 -07:00
|
|
|
public int BytesPerPixel { get; }
|
|
|
|
|
2020-09-10 16:48:48 -07:00
|
|
|
/// <summary>
|
|
|
|
/// The maximum number of components this format has defined (in RGBA order).
|
|
|
|
/// </summary>
|
|
|
|
public int Components { get; }
|
|
|
|
|
2019-12-29 15:26:37 -08:00
|
|
|
/// <summary>
|
|
|
|
/// Whenever or not the texture format is a compressed format. Determined from block size.
|
|
|
|
/// </summary>
|
2019-10-12 23:02:07 -07:00
|
|
|
public bool IsCompressed => (BlockWidth | BlockHeight) != 1;
|
|
|
|
|
2019-12-29 15:26:37 -08:00
|
|
|
/// <summary>
|
|
|
|
/// Constructs the texture format info structure.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="format">The format of the texture data</param>
|
|
|
|
/// <param name="blockWidth">The block width for compressed formats. Must be 1 for non-compressed formats</param>
|
|
|
|
/// <param name="blockHeight">The block height for compressed formats. Must be 1 for non-compressed formats</param>
|
|
|
|
/// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param>
|
2019-10-12 23:02:07 -07:00
|
|
|
public FormatInfo(
|
|
|
|
Format format,
|
|
|
|
int blockWidth,
|
|
|
|
int blockHeight,
|
2020-09-10 16:48:48 -07:00
|
|
|
int bytesPerPixel,
|
|
|
|
int components)
|
2019-10-12 23:02:07 -07:00
|
|
|
{
|
|
|
|
Format = format;
|
|
|
|
BlockWidth = blockWidth;
|
|
|
|
BlockHeight = blockHeight;
|
|
|
|
BytesPerPixel = bytesPerPixel;
|
2020-09-10 16:48:48 -07:00
|
|
|
Components = components;
|
2019-10-12 23:02:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|