Metadata in a KTX 2 file is a list of key and value pairs, found at
kvdByteOffset and filling kvdByteLength bytes (see the
header). It follows the data format descriptor
directly.
Entry layout
| Field | Size | Meaning |
|---|---|---|
| keyAndValueByteLength | 4 | Bytes of the key, its 00 and the value; padding not included. Little-endian. |
| key | varies | UTF-8 text ending in one 00 byte. |
| value | varies | Any bytes; the format depends on the key. |
| valuePadding | 0–3 | Zero bytes so the next length field starts on a multiple of 4. |
- Entries are sorted by key, comparing Unicode code points, and no key appears twice.
kvdByteLengthmust be exactly the sum of the entries and their padding, or the file is invalid.- Keys beginning with
KTXorktxare reserved for Khronos. Other keys are free for applications.
Predefined keys
| Key | Value | Meaning |
|---|---|---|
KTXcubemapIncomplete | 1 byte | Which faces of a cube map are present: bit 0x01 +X, 0x02 −X, 0x04 +Y, 0x08 −Y, 0x10 +Z, 0x20 −Z. At least one bit is set; the header then has faceCount 1 and the faces are stored as layers. Not with KTXanimData. |
KTXorientation | String ending in 00 | How texture coordinates map to the picture: r or l for x (right or left), then d or u for y (down or up), then o or i for z (out or in), one letter per dimension. Recommended: rd, ru, rdi, ruo. |
KTXglFormat | 12 bytes | Three 32-bit values: OpenGL glInternalformat, glFormat and glType, for data with no Vulkan format. glFormat and glType are 0 for compressed formats. |
KTXdxgiFormat__ | 4 bytes | A Direct3D DXGI_FORMAT value, for data with no Vulkan format. |
KTXmetalPixelFormat | 4 bytes | A Metal MTLPixelFormat value, for data with no Vulkan format. |
KTXswizzle | String of 4 characters and 00 | Where each of red, green, blue and alpha comes from: r, g, b, a, 0 or 1. Missing colour channels read as 0 and missing alpha as 1. No effect on depth and stencil formats. |
KTXwriter | UTF-8 string ending in 00 | The program that last wrote the file. |
KTXwriterScParams | UTF-8 string ending in 00 | The encoding and supercompression options used. Only with KTXwriter. |
KTXastcDecodeMode | String ending in 00 | rgb9e5 or unorm8: the decode precision for LDR ASTC data. Not for sRGB or other formats. |
KTXanimData | 12 bytes | Three 32-bit values: duration of each frame and timescale (duration ÷ timescale is seconds), and loopCount (0 forever, otherwise the number of plays). The layers are the frames. Not with KTXcubemapIncomplete. |
An entry
12 00 00 00 4B 54 58 6F 72 69 65 6E 74 61 74 69 6F 6E 00 72 64 00 00 00
KTXorientation and 00 (15 bytes); value rd and 00 (3 bytes); 2 padding bytes