A KTX 2 file names its format twice: vkFormat is a Vulkan
VkFormat number, and the
data format descriptor describes
the texel block. The viewer reads both, and warns when they disagree. For a file with
vkFormat 0 only the descriptor says what the texels are. This page lists what
the viewer turns into a picture and what it only describes.
Decoded to pictures
| Family | Formats | How the texels are read |
|---|---|---|
| Uncompressed | Every R, RG, RGB, RGBA, BGRA and ABGR layout in 4 to 32 bits a channel (or 64-bit floating point), normalised, integer, floating point or sRGB (UNORM, SNORM, UINT, SINT, SFLOAT, SRGB); packed 4-4-4-4, 5-6-5, 5-5-5-1, 8-8-8-8 and 2-10-10-10; the 10-bit and 12-bit forms in 16-bit words (R10X6…, R12X4…); B10G11R11_UFLOAT; E5B9G9R9_UFLOAT; A8_UNORM; depth and stencil formats (D16, D32_SFLOAT, X8_D24, D24_UNORM_S8_UINT, S8_UINT and the others) | From the descriptor’s samples: each has a bit offset, a bit length, a channel, whether it is signed or floating point, and the values that stand for 0 and 1. The 11- and 10-bit floating-point samples and the shared exponent of E5B9G9R9 are read as the formats define them. |
| BC (S3TC, RGTC, BPTC) | BC1_RGB, BC1_RGBA, BC2, BC3, BC4, BC5 (unsigned and signed), BC6H (unsigned and signed), BC7; also from descriptors with the models BC1 to BC7 | Blocks of 4 × 4 in 8 or 16 bytes; all eight modes of BC7 and all fourteen modes of BC6H. |
| ETC and EAC | ETC2_R8G8B8, ETC2_R8G8B8A1, ETC2_R8G8B8A8, EAC_R11, EAC_R11G11 (unsigned and signed); ETC1 from the descriptor model ETC1 | Blocks of 4 × 4 in 8 or 16 bytes: the individual, differential, T, H and planar modes, punch-through alpha, and 8-bit and 11-bit EAC. |
| ASTC | The 2D block sizes 4×4, 5×4, 5×5, 6×5, 6×6, 8×5, 8×6, 8×8, 10×5, 10×6, 10×8, 10×10, 12×10 and 12×12, in UNORM, SRGB and SFLOAT (high dynamic range) | Blocks of 16 bytes: every block mode, one to four partitions, dual planes, all sixteen colour endpoint modes (LDR and HDR), and void-extent blocks. |
| Basis Universal ETC1S | Colour model ETC1S with BasisLZ supercompression (1 or 2 slices: RGB, RGBA, RRR, RG) | The codebooks and slices are decoded to ETC1 blocks, then to pixels. See Basis Universal data. |
| Basis Universal UASTC | UASTC LDR 4x4 (all 19 modes), UASTC HDR 4x4 and UASTC HDR 6x6 (ASTC HDR blocks) | Straight to pixels; the HDR forms with the ASTC decoder. |
Zstandard and ZLIB supercompression make no difference to the family: the level is decompressed first. The mip levels, array layers, cube faces and depth slices are all shown (see levels and images).
Described but not decoded
- PVRTC and PVRTC2 (
PVRTC1_2BPP,PVRTC1_4BPP,PVRTC2_2BPP,PVRTC2_4BPP,UNORMandSRGB, and the descriptor models PVRTC and PVRTC2): the layout of the levels is known and shown; no pictures are made. - ASTC of three dimensions (
ASTC_3x3x3toASTC_6x6x6, the_EXTformats): layout shown, no pictures. - Colour-difference (YCbCr) formats: the 4:2:2 formats (
G8B8G8R8_422_UNORMand its relatives) and any format with the colour model YUV: layout shown, not converted to RGB. - UASTC HDR 6x6 with the intermediate supercompression (scheme 4): the global data is shown as bytes.
The rules the pictures follow
- BC1 to BC3. The 5- and 6-bit colour endpoints are widened and the two
colours between them worked out in that precision and rounded once to 8 bits. A BC1
block whose first colour is not above its second has a black fourth colour that is
transparent in
BC1_RGBAand opaque inBC1_RGB; the colour block of BC2 and BC3 is always in four-colour mode. The alpha of BC3 is interpolated with truncating division. - BC4 and BC5. The values between the two endpoints are rounded. A signed endpoint of −128 counts as −127. A signed value is shown as v / 2 + 0.5.
- BC6H and ASTC HDR. The pictures are high dynamic range. Each channel is tone mapped as x / (1 + x) when any value in the picture is above 1, and gamma encoded for the screen.
- ASTC. A picture takes the top 8 bits of each 16-bit result (the
decode mode
unorm8). A block the specification calls invalid is magenta, and so is a partition of a block that uses a high dynamic range endpoint in a low dynamic range format. - EAC. A multiplier of 0 in an EAC block counts as 1 (as 1/8 of a step in the 11-bit formats). The 11-bit values are widened to 16 bits.
- UASTC. Interpolated on the stored values, not the linear light, whatever the transfer function.
- Display. There is no colour management: values are shown as stored (an sRGB texture is shown as its sRGB values). Normalised integers fill 0 to 1; a signed normalised value is shown as 0 where it is negative. Unnormalised integers are scaled to their range so they can be seen. A texture with only a red channel is shown as grey; one with red and green as red and green. Depth and stencil are shown as grey.
How the decoders are checked
- BC1 to BC7 give the same pixels as bcdec (a public domain decoder) on 4,000 random blocks of each format, BC6H as half-float bits.
- ETC1, ETC2 and EAC give the same values as Ericsson’s reference decoder on 20,000 random blocks of each kind.
- ASTC gives the same pixels as ARM’s astcenc for every block size above in all three profiles, on 4,000 blocks each (half of them with a valid block mode chosen first, so every partition count, dual plane and endpoint mode occurs).
- ETC1S and UASTC give the same pixels as Khronos’
ktx extract --transcode rgba8on the Khronos conformance textures. - The files of Khronos’ conformance set for every format above open and decode. The uncompressed formats are checked by reading the same bytes two ways only for 8-bit RGBA; for the others the descriptor reading is not compared with another reader.
- UASTC HDR 6x6 (not intermediate) is decoded as ASTC 6x6 HDR blocks; there is no sample of it here to check that against.
VkFormat numbers
The viewer knows the name of every VkFormat in the Vulkan registry (280 values):
the core formats 0 to 184 (for instance 37 is
R8G8B8A8_UNORM, 131 BC1_RGB_UNORM_BLOCK,
146 BC7_SRGB_BLOCK, 147 ETC2_R8G8B8_UNORM_BLOCK,
157 ASTC_4x4_UNORM_BLOCK and 184
ASTC_12x12_SRGB_BLOCK), and the extension formats: the ASTC high dynamic range blocks from
1000066000, PVRTC from 1000054000, the 4:2:2 and multi-planar
formats from 1000156000, A4R4G4B4 from 1000340000,
R16G16_SFIXED5_NV 1000464000, A1B5G5R5 and
A8_UNORM from 1000470000 and the three-dimensional ASTC
blocks from 1000288000. A value that is not in the registry is shown as “not a Vulkan format”. KTX 2 does not
allow the scaled formats (USCALED, SSCALED) or the multi-planar formats.
Sources
- Vulkan specification – Khronos Group: the format list and its compressed formats
- Khronos Data Format Specification – the block layouts of BC, ETC, ASTC and the colour models
- astcenc – ARM: the reference ASTC decoder, Apache-2.0
- bcdec – single-header BC1 to BC7 decoders, MIT
- KTX-Software – Khronos: the
ktxtool and its conformance test files, Apache-2.0