The fast build

A level of VK_BC7_FAST_TEXELS or more takes the encoder's fast build, bc7_fast_spv (SNX_BC7_FAST 1): a block whose mode 6 error is 256 or less (squared, summed over its 16 texels and 4 channels: 2 a channel as a root mean square) keeps mode 6, and only the others try every mode, stopping at SNX_BC7_GOOD_ENOUGH as the full build does. A level of VK_BC7_MODE6_TEXELS (8192x8192) or more takes mode 6 alone, bc7_mode6_spv (SNX_BC7_FAST 2): a game's sparse texture of seven mapped 8192x8192 layers took the full encoder 14 seconds on a GeForce RTX 2080, which mode 6 alone encodes at 1200 megatexels a second. The build goes by the level's size, not the region's (vk_bc7_build), so a level loaded in pieces, or made BC7 between frames, encodes each block as its whole upload does. Each build's pipeline is made the first time a level asks for it. Both rules count a layer, as a sparse texture's layers are loaded one at a time. A level held as BC7 at load that is not sparse and has astc_quick_mtexels megatexels or more, all its layers counted, takes the quick build instead and the fast build later (Very large levels).

Mode 6 alone holds gradients but not edges, a second plane or luminance apart from alpha; the threshold keeps most of the full build's quality. PSNR over RGBA and the worst channel error:

ContentFullFast buildMode 6 alone
The picture below: gradients, edges, noise, alpha (bc7_glsl)51.1, 49.0, 29.0, 48.043.4, 46.8, 29.0, 47.743.2, 26.2, 25.2, 40.0
Random ASTC 4x4, 6x6, 8x8, 12x12 blocks, 256x256 decoded (CPU model)48.58, 42.96, 46.23, 44.4548.56, 42.92, 46.19, 44.39not measured
One game's ASTC 6x6 textures, 25 (fuddlesworth, RTX 2080)53.8 dB / 5050.7 dB / 5046.5 dB / 147
astcenc's 4x4, 8x8, 12x12 encodings of 7 of them (same)46.6, 47.6, 46.445.9, 46.7, 45.732.9, 36.2, 38.0

On the random blocks 1.3 to 5.9% of the fast build's blocks differ from the full build's, and 90 to 98% of them are mode 6.

VK_BC7_FAST_TEXELS is 0: every level takes the fast build. The full build had most of a game's textures, those under 2048x2048, and a batch of them held a frame for seconds. On an RX 6700 XT (RADV), a level of random 8x8 blocks decoded and encoded (snx-test-astc-vulkan --bench, two interleaved rounds of four runs after the first; a -O0 test build, the time the GPU's):

LevelFull buildFast build
4096x4096103 to 107 ms, 9.8 to 10.2 million BC7 blocks a second76 to 80 ms, 13.1 to 13.8 million
2040x204023.5 to 24.3 ms, 10.7 to 11.1 million17.5 to 18.2 ms, 14.3 to 14.8 million

Random blocks are the fast build's worst case: the blocks that try every mode hold up the invocations beside them. On a GeForce RTX 2080 an 8192x8192 level of random 8x8 blocks decoded in 15 ms and encoded in 860 ms with every mode and in 48 ms with mode 6 alone. Beside a running game, a 4096x4096 level took (decoding included):

ContentMode 6 aloneFast buildFull build (2040x2040, scaled)
One game's ASTC 6x6 albedo7 to 11 ms12 to 14 ms190 ms
One game's ASTC 6x6 packed masks (the worst of its textures tried)7 to 8 ms85 to 88 ms250 ms
astcenc 8x8 normal mapnot measured256 to 267 msnot measured
Random 8x8 blocks21 to 29 ms189 to 196 ms260 ms

The BC7 cache

The same ASTC bytes always become the same BC7 blocks, and the memory budget's trim evicts textures a game uses again: each came back through the decoder and the encoder (one game encoded 6,000 to 14,000 levels in a 150 second run, each 3 to 5 ms of an RTX 2080). So the blocks of whole levels encoded are kept in memory while the game runs (gpu/vk/bc7_cache.c): the levels it uses most, up to a bound. Nothing of it is on disk, and every run starts with it empty. pipeline.c starts it where ASTC textures are held as BC7 (vk_astc_bc7).

RGBA8 levels are not cached: their decode is the cheap part (about 1 ms a 4096x4096 level on the RTX 2080), and a cached one would be four times the bytes to hold and copy.


Made from docs/layers/gpu/astc.md at 69237645142c. GPL-3.0-or-later.