Table of Contents

Interface ITileBlockCodec

Write and transcode half for a GPU-ready block-compressed tile format, on top of ITileCodec's read half.

public interface ITileBlockCodec : ITileCodec
Inherited Members

Properties

Id

Stable lowercase identifier for this codec, for example "bc1", "etc2", or "astc4x4".

string Id { get; }

Property Value

string

Remarks

Serialized scenes carry this string. Do not localize it, and do not change the spelling once shipped. One id is one GPU block format including its parameters: a family such as ASTC ships as separate ids ("astc4x4", "astc6x6"), never a bare "astc".

Methods

DecodeLevel(byte[], int, int, int, byte[], int)

Decodes one already-extracted mip level's raw blocks back to RGBA8888.

void DecodeLevel(byte[] blocks, int offset, int width, int height, byte[] outRgba, int outOffset)

Parameters

blocks byte[]

Level bytes, LevelBlockBytes(int, int) readable from offset.

offset int

Start of this level in blocks, in bytes.

width int

Level width in texels.

height int

Level height in texels.

outRgba byte[]

Destination, widthheight4 RGBA8888 bytes row-major from outOffset.

outOffset int

Start write index in outRgba, in bytes.

Remarks

Cache migration only needs the base level; the rest of a stored chain is discarded and rebuilt by the new codec's WritePayload(int, int, byte[], byte[], byte[], int). The default throws NotSupportedException so a codec that has not overridden this still compiles and simply skips local migration.

LevelBlockBytes(int, int)

Byte count of one mip level as raw blocks, block-rounded.

int LevelBlockBytes(int widthTexels, int heightTexels)

Parameters

widthTexels int

Level width in texels.

heightTexels int

Level height in texels.

Returns

int

Size in bytes of each TryBuildMips(byte[], int, int, int, int, byte[][]) buffer for this level. A tail smaller than one block still costs one whole block.

RequiredPayloadBytes(int, int)

Byte count of one whole disk payload (header plus every mip of a full chain) for a base level of the given dimensions.

int RequiredPayloadBytes(int width, int height)

Parameters

width int

Base-level width in texels.

height int

Base-level height in texels.

Returns

int

Payload size in bytes.

WritePayload(int, int, byte[], byte[], byte[], int)

Encodes base-level RGBA8888 into a full mip-chain disk payload.

int WritePayload(int width, int height, byte[] rgba, byte[] scratchRgba, byte[] outPayload, int outOffset)

Parameters

width int

Base-level width in texels.

height int

Base-level height in texels.

rgba byte[]

Base-level widthheight4 RGBA8888 bytes; a working buffer, not preserved.

scratchRgba byte[]

Caller-owned scratch of at least widthheight4 bytes; a working buffer, not preserved.

outPayload byte[]

Caller-owned destination, at least RequiredPayloadBytes(int, int) bytes from outOffset.

outOffset int

Start write index in outPayload, in bytes.

Returns

int

Bytes written, equal to RequiredPayloadBytes(int, int).

Remarks

rgba and scratchRgba are ping-pong working buffers. After return, neither holds the original level-0 pixels. Pass a copy if you still need them.