Vixen
dd8b0a81
csharp
public static class DataFormatDescriptor

The Khronos data format descriptor a KTX2 file carries.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A KTX2 file says what its bytes are twice: once as a VkFormat number in the header, and once as a descriptor that spells out the channels, their bit positions and the transfer function. The second exists so a reader that has never heard of the number can still work out what it is holding, and the specification requires it even when the number says everything.

This writes the basic block — colour model, primaries, transfer function, texel block dimensions, plane sizes and the samples the format calls for — and no more. It does not attempt the descriptor's fuller vocabulary, because nothing in this engine reads it: the VkFormat number is what Read uses, and the descriptor is written for other people's tools.

⚠ Written for other people's tools is why this was wrong for so long. Nothing here consumes the descriptor, so nothing here noticed that alpha was labelled channel 3 rather than 15, that float channels carried neither the SIGNED nor the FLOAT qualifier and claimed an integer's range, that an sRGB format's alpha channel needs the LINEAR qualifier because alpha is not sRGB-encoded, or that BC3 and BC5 are two samples rather than one. Ktx2ConformanceTests found all of it in one run; the values below are the ones Khronos's own writer produces, checked format by format.

Fields and properties (2)

  • public const int BasicBlockLength

    How long a descriptor block's fixed part is, before its samples.

  • public const int SampleLength

    How long one sample is.

Methods (1)

  • public static byte[] Build(PixelFormat format)

    Builds the descriptor for a format.

Used by (1)

  • Ktx2Vixen.Core.Imaging