Most DDS files hold block-compressed textures. The compressed data is a plain sequence of fixed-size blocks, each covering 4 by 4 texels, in the order the data layout page describes. A texture dimension that is not a multiple of 4 is padded up to the next block, which is why a level smaller than 4 by 4 still takes a whole block, and why a reader must use the physical size of each mipmap level rather than the declared one. This page follows Microsoft’s Direct3D 10 and 11 block compression documents.
Block sizes
| Format | Bytes per block | Stores | Legacy names |
|---|---|---|---|
| BC1 | 8 | Colour as 5:6:5, optionally 1 bit of alpha | D3DFMT_DXT1, FourCC DXT1 |
| BC2 | 16 | Colour as 5:6:5 and 4 bits of explicit alpha | DXT2 (premultiplied) and DXT3 |
| BC3 | 16 | Colour as 5:6:5 and 8 bits of interpolated alpha | DXT4 (premultiplied) and DXT5 |
| BC4 | 8 | One 8-bit channel, unsigned or signed | FourCC ATI1; BC4U and BC4S in DDS |
| BC5 | 16 | Two 8-bit channels, unsigned or signed | FourCC ATI2; BC5S for signed in DDS |
| BC6H | 16 | Three channels of half-precision floating point (HDR) | none |
| BC7 | 16 | Three channels of 4 to 7 bits with 0 to 8 bits of alpha | none |
The DXT2 and DXT4 codings are the same as DXT3 and DXT5; Microsoft says the premultiplied alpha distinction must be handled by the shaders when rendering.
BC1
A block holds two reference colours, color_0 and color_1, each
a 16-bit 5:6:5 value (5 bits red, 6 bits green, 5 bits blue), and 16 two-bit indices, one
for each texel (a to p in Microsoft’s diagram). The index picks
one of four colours:
| Index | Colour with four colours | Colour with one-bit alpha |
|---|---|---|
| 00 | color_0 | color_0 |
| 01 | color_1 | color_1 |
| 10 | 2/3 × color_0 + 1/3 × color_1 | 1/2 × color_0 + 1/2 × color_1 |
| 11 | 1/3 × color_0 + 2/3 × color_1 | 0, transparent |
The Direct3D 10 text gives both tables but, in the text read, not the test that tells a reader which one a block uses, nor the bit order of the fields inside the 8 bytes: those are in its diagram. They are not stated here.
BC2
A BC2 block stores its colour with the same number of bits and layout as BC1 (8 bytes) plus 64 more bits of alpha, which is a separate 4-bit value for each of the 16 texels. Microsoft recommends it for colour with alpha of low coherence, and BC3 for alpha of high coherence. Which half comes first and the order of the 4-bit values are in Microsoft’s diagram and are not stated in the text read.
BC3, BC4 and BC5 interpolation
BC3 stores its alpha like BC4 stores a colour: two 8-bit reference values and 16 three-bit indices, 64 bits in all, with the colour half coded as BC1. BC4 is that 64-bit block on its own; BC5 is two of them, the first for red and the second for green (Microsoft’s text names red first). The reference values are called alpha_0 and alpha_1 (BC3) or red_0 and red_1 (BC4, BC5), and the index selects one of eight values. The comparison decides how many values are interpolated:
| Index | When reference 0 > reference 1 | Otherwise |
|---|---|---|
| 000 | reference 0 | reference 0 |
| 001 | reference 1 | reference 1 |
| 010 | (6 × ref 0 + 1 × ref 1) / 7 | (4 × ref 0 + 1 × ref 1) / 5 |
| 011 | (5 × ref 0 + 2 × ref 1) / 7 | (3 × ref 0 + 2 × ref 1) / 5 |
| 100 | (4 × ref 0 + 3 × ref 1) / 7 | (2 × ref 0 + 3 × ref 1) / 5 |
| 101 | (3 × ref 0 + 4 × ref 1) / 7 | (1 × ref 0 + 4 × ref 1) / 5 |
| 110 | (2 × ref 0 + 5 × ref 1) / 7 | 0 (BC3: 0; BC4 and BC5 unsigned: 0.0; signed: −1.0) |
| 111 | (1 × ref 0 + 6 × ref 1) / 7 | 255 for BC3 alpha, 1.0 for BC4 and BC5 (signed or unsigned) |
For the signed formats (BC4_SNORM and BC5_SNORM) the reference
values are signed and the same comparison is made. The block layout is otherwise the same, and
the two extra values of the second column are −1.0 and 1.0.
BC6H and BC7
Direct3D 11 added two formats of 16 bytes per block. BC6H stores three channels of
half-precision floating point (a 5-bit biased exponent and a 10 or 11 bit mantissa, with
an optional sign) for high dynamic range data, as
DXGI_FORMAT_BC6H_UF16 or DXGI_FORMAT_BC6H_SF16. BC7 stores
standard colour data of 4 to 7 bits per channel with 0 to 8 bits of alpha, as
DXGI_FORMAT_BC7_UNORM or its sRGB form. Both choose one of several coding
modes for each block: 14 for BC6H and 8 for BC7. The mode tables, partitions and
endpoint layouts are in Microsoft’s separate BC6H and BC7 format documents, which are
not summarised on this page.
Sources
- Block Compression (Direct3D 10) – Microsoft Learn: BC1 to BC5
- Texture Block Compression in Direct3D 11 – Microsoft Learn: block sizes, BC6H and BC7