namespace Brutal.TextureApi.Abstractions;
///
/// Describes how one image (mip level) of a texture is laid out in memory.
///
public class TextureImageMemoryLayout
{
///
/// Create a TextureImageMemoryLayout from a set of texture properties.
///
/// The ImageExtent of the image
/// The rowpitch in bytes of the image
/// The number of bytes a single block takes up.
public TextureImageMemoryLayout(ImageExtent extent, ByteSize rowPitch, ByteSize blockSizeInBytes)
{
Extent = extent;
RowPitch = rowPitch;
RowPadBytes = RowPitch - Extent.Blocks.X * blockSizeInBytes;
}
///
/// Gets the ImageExtent of this TextureImageMemoryLayout. This includes both the extents in texels
/// and in blocks.
///
public ImageExtent Extent { get; }
///
/// Gets the number of bytes between the start of consecutive rows in the buffer.
///
public ByteSize RowPitch { get; }
///
/// Gets the number of padding bytes added to each row in the data structure.
///
public ByteSize RowPadBytes { get; }
///
/// The number of bytes the x extent texel blocks take up.
/// For uncompressed formats this is the extent texel width * bytes per texel.
/// For compressed formats this is the extent in whole blocks * bytes per block.
///
public ByteSize RowExtentBytes => RowPitch - RowPadBytes;
///
/// Does this layout have padding at the end of each row?
///
public bool IsRowPadded => RowPadBytes > 0;
}