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
-
objectTileMemoryBudget
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
budgetByteslongMemory budget in bytes.
tileSizePxintTile edge length in px.
formatTileTextureFormatStored texel format.
mipChainboolTrue 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
budgetByteslongMemory budget in bytes.
tileSizePxintTile edge length in px.
bytesPerPixelintBytes 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
budgetByteslongMemory budget in bytes.
tileSizePxintTile edge length in px.
bytesPerPixelintBytes stored per texel.
mipChainboolTrue 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
megabytesintSize 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
tileSizePxintTile edge length in px.
formatTileTextureFormatStored texel format.
mipChainboolTrue 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
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
tileSizePxintTile edge length in px.
bytesPerPixelintBytes stored per texel.
mipChainboolTrue to include every mip level, not the 33 percent approximation.
Returns
- long
Layer cost in bytes.