The encoder

texconv.comp built a second time with SNX_TC_ETC2, its own pipeline (vk/texconv.c), runs a block an invocation: texconv.glsl's BCn decoders, then gpu/texture/etc2_encode.glsl. The texels go through texture.c's uploads as the decoded ones did: the dispatch writes rows of blocks, and the copy into the image counts them as rows of texels four times as wide.

A submission holds 16384 blocks of it at most (TC_ENCODE_SUBMIT_BLOCKS in vk/texconv.c): a level's conversion goes in pieces of whole rows of blocks, and a piece that would take the submission past that goes in the next one (encode_rows in vk/texture.c, vk_submit_split). A phone's kernel driver ends a submission that runs past its timeout, 2 s in kgsl, and its fence then never signals. An Adreno 610 (stock driver 512.502.0) takes 27 us a block: a 2048x2048 level is 7.1 s of it, which the kernel ended as one dispatch and as 16 dispatches in one submission, and which came out whole in 16 submissions of 0.44 to 0.48 s each.

ETC2 RGB tries the modes that suit the block and keeps the one nearest it (squared error, as the decoder decodes, clamping and all):

A block with transparent texels clears its opaque bit, so index 2 is transparent: only the differential, T and H modes are tried, and every transparent texel takes index 2 and no opaque one. EAC tries the sixteen tables with the two multipliers around the one that spans the block's values, the base that centres each, and the best base a step either way; an alpha the same throughout is written at once. Integer arithmetic only, so the tests run the same file on the CPU (tests/glsl/glsl.hpp) and get the GPU's bytes.

What a texel costs

The formats are Strom and Akenine-Moller's iPACKMAN, ETC1 ("iPACKMAN: High-Quality, Low-Complexity Texture Compression for Mobile Phones", Graphics Hardware 2005), and Strom and Pettersson's ETC2 ("ETC2: Texture Compression using Invalid Combinations", Graphics Hardware 2007), whose T and H blocks start from the block's two colour clusters, as et_cluster's do.

The candidates are searched as above, and each step below writes the same blocks, byte for byte, as the search written out plainly did (a checksum of 20000 blocks of every candidate and of the encoder's choice holds them to it):

What was measured and not kept: the early compression-mode decision of Nah's QuickETC2 ("QuickETC2: Fast ETC2 Texture Compression using Luma Differences", ACM Transactions on Graphics 39, 6, 2020, doi:10.1145/3414685.3417787), which tries T and H only where a block's texels spread widely and the planar search only where its fit is good, makes the encoder slower on a GPU. Four Kodak crops made BC7 took 93 to 128 ms on a GT 1030 with it and 85 to 106 without (before the dot build), for 0.02 to 0.18 dB less. A subgroup runs the candidates any of its invocations takes, and a picture's 32 neighbouring blocks seldom all skip one.


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