TextureFormats

Size arithmetic for the texture formats the engine uploads. Block-compressed formats are measured in 4×4 blocks rather than texels, so a mip level's byte count is the block count rounded up, never a row pitch.

Public Methods

IsBlockCompressed

public static bool IsBlockCompressed(Format format)

Reports whether format stores 4×4 block-compressed data.

Parameters:

  • format (Format): The format to classify.

Returns: bool

ElementSizeBytes

public static uint ElementSizeBytes(Format format)

Bytes occupied by one element of format — one 4×4 block for compressed formats, one texel otherwise.

Parameters:

  • format (Format): The format to measure.

Returns: uint

LevelSizeBytes

public static uint LevelSizeBytes(Format format, uint width, uint height)

Bytes occupied by a tightly-packed width×height mip level of format, rounding compressed extents up to whole 4×4 blocks.

Parameters:

  • format (Format): The format of the level.
  • width (uint): Level width in texels.
  • height (uint): Level height in texels.

Returns: uint

LevelExtent

public static (uint Width, uint Height) LevelExtent(uint width, uint height, int level)

Extent of mip level level of a width× height base image, never smaller than 1×1.

Parameters:

  • width (uint): Base level width.
  • height (uint): Base level height.
  • level (int): Zero-based mip level.

Returns: (uint Width, uint Height)

FullMipChainLength

public static uint FullMipChainLength(uint width, uint height)

Number of mip levels in a complete chain down to 1×1 for the given base extent.

Parameters:

  • width (uint): Base level width.
  • height (uint): Base level height.

Returns: uint