Table of Contents

Class Bc1MipChain

CPU mip-chain arithmetic and 2x2 box downsampling for block-compressed tiles, floored at 1x1.

public static class Bc1MipChain
Inheritance
object
Bc1MipChain

Remarks

Compressed formats cannot generate mips on the GPU. The floor is 1x1 so the level count matches LevelCount(int); a 4x4 floor would desync from the uncompressed chain. Levels below 4x4 are legal in BC1 and still occupy one whole block.

Fields

MinDimension

Smallest mip edge in texels, 1.

public const int MinDimension = 1

Field Value

int

Methods

Downsample(byte[], int, int, byte[], int, int)

Downsamples RGBA8888 with a 2x2 box filter into a caller-owned buffer.

public static void Downsample(byte[] src, int srcW, int srcH, byte[] dst, int dstW, int dstH)

Parameters

src byte[]

Source RGBA8888, srcWsrcH4 bytes row-major.

srcW int

Source width in texels.

srcH int

Source height in texels.

dst byte[]

Destination, dstWdstH4 bytes row-major.

dstW int

Destination width in texels.

dstH int

Destination height in texels.

Remarks

A source edge is clamped rather than read out of bounds, so dstW*2 can exceed srcW by one texel without crashing.

LevelCount(int, int)

Levels in a full chain from the given base size down to 1x1.

public static int LevelCount(int width, int height)

Parameters

width int

Base-level width in texels, greater than 0.

height int

Base-level height in texels, greater than 0.

Returns

int

Level count, 1 when both axes are already 1.

LevelDimensions(int, int, int, out int, out int)

Texel size of one mip level, floored at MinDimension.

public static void LevelDimensions(int width, int height, int level, out int w, out int h)

Parameters

width int

Base-level width in texels.

height int

Base-level height in texels.

level int

Mip index, 0 is the base.

w int

Level width in texels.

h int

Level height in texels.