Table of Contents

Class TileMemoryBudget

Converts a memory budget in bytes into how many Texture2DArray layers that budget can hold. The pipeline uses this; most apps never call it.

public static class TileMemoryBudget
Inheritance
object
TileMemoryBudget

Methods

MaxLayers(long, int, TileTextureFormat, bool)

How many layers of format budgetBytes can hold.

public static int MaxLayers(long budgetBytes, int tileSizePx, TileTextureFormat format, bool mipChain = false)

Parameters

budgetBytes long

Memory budget in bytes.

tileSizePx int

Tile edge length in px.

format TileTextureFormat

Stored texel format.

mipChain bool

True to charge every mip level per layer.

Returns

int

Layer count, at least 1 even when the budget is smaller than one tile.

MaxLayers(long, int, int)

How many no-mip layers budgetBytes can hold.

public static int MaxLayers(long budgetBytes, int tileSizePx, int bytesPerPixel)

Parameters

budgetBytes long

Memory budget in bytes.

tileSizePx int

Tile edge length in px.

bytesPerPixel int

Bytes stored per texel.

Returns

int

Layer count, at least 1 even when the budget is smaller than one tile.

MaxLayers(long, int, int, bool)

How many layers budgetBytes can hold, optionally charging a mip chain.

public static int MaxLayers(long budgetBytes, int tileSizePx, int bytesPerPixel, bool mipChain)

Parameters

budgetBytes long

Memory budget in bytes.

tileSizePx int

Tile edge length in px.

bytesPerPixel int

Bytes stored per texel.

mipChain bool

True to charge every mip level per layer.

Returns

int

Layer count, at least 1 even when the budget is smaller than one tile.

MegabytesToBytes(int)

Converts a megabyte count to bytes, clamping a negative input to 0.

public static long MegabytesToBytes(int megabytes)

Parameters

megabytes int

Size in mebibytes (1024 * 1024 bytes).

Returns

long

Equivalent size in bytes.

TileBytes(int, TileTextureFormat, bool)

Bytes of one layer in format, optionally charging a mip chain.

public static long TileBytes(int tileSizePx, TileTextureFormat format, bool mipChain = false)

Parameters

tileSizePx int

Tile edge length in px.

format TileTextureFormat

Stored texel format.

mipChain bool

True to include every mip level.

Returns

long

Layer cost in bytes.

TileBytes(int, int)

Bytes of one uncompressed layer without a mip chain.

public static long TileBytes(int tileSizePx, int bytesPerPixel)

Parameters

tileSizePx int

Tile edge length in px.

bytesPerPixel int

Bytes stored per texel.

Returns

long

tileSizePx squared times bytesPerPixel, in bytes.

TileBytes(int, int, bool)

Bytes of one uncompressed layer, charging the full mip chain when mipChain is true.

public static long TileBytes(int tileSizePx, int bytesPerPixel, bool mipChain)

Parameters

tileSizePx int

Tile edge length in px.

bytesPerPixel int

Bytes stored per texel.

mipChain bool

True to include every mip level, not the 33 percent approximation.

Returns

long

Layer cost in bytes.