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.
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):
et1_setup) or
the distance (et_th_word), not once a texel and index. A texel p's squared distance from a colour c is |p|^2 +
|c|^2 - 2 p.c, and |p|^2 is the same for the four, so the nearest is the least of |c|^2 - 2 p.c: three multiply-adds
a colour, with no branch (et_near4). An index and its error share a word, error above, so the first of the least is
the minimum of four words.g_vk.bc7_dot: Pascal's DP4A, Valhall's and
Adreno's from a6xx's third generation) the build texconv_etc2_dot_spv makes each p.c one instruction.simplify on the build's SPIR-V found these, and ucas's tests etc2planar.ucas and
etc1index.ucas hold the proofs.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.