Skip to content

Equal endpoints - #7

Merged
Geolm merged 2 commits into
mainfrom
equal_endpoints
Nov 9, 2026
Merged

Geolm merged 2 commits into
mainfrom
equal_endpoints

Conversation

@Geolm

@Geolm Geolm commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Flat tiles (equal endpoints) better compression. (no change in the benchmark since test suite is more complex)

Geolm added 2 commits November 8, 2026 17:41
…: a block whose two endpoint

colors match carries a uniform index word (all 16 indices equal). a per-stream (BC1) / per-channel
(BC4/BC5) flat index mode, decided once in the first pass, collapses it: mode 1 is selected when at
least one block has identical endpoints and every such block has uniform indices, else mode 0. in
mode 1 a flat block stores a single index value (2 bits for BC1, 3 bits per channel for BC4/BC5),
expanded to all 16 indices on decode, instead of the top-table reference + mask + differences (BC1)
or the 15 contextual symbols (BC4/BC5). the flag byte is written in the stream header (right after
the top-table size for BC1, after the tile seeds for BC4/BC5) and is never needed for a non-flat
block, so encoder and decoder always pick the same path; an encoder that leaves a non-uniform word
on a flat block forces mode 0 and round-trips unchanged. the gpu decompressor mirrors the cpu;
packed_*_maxsize grow by the alignment quantum to cover the header byte. new synthetic tests
bc45_flat_uniform and bc3_flat_uniform exercise mode 1 (the existing flat tests keep mode 0).
stream format is extended, hence the 1.0.0 version bump
…tead of storing one index value per flat block, the value now lives once in the stream header. the first pass requires every equal-endpoint block to hold the same uniform index value (2-bit for BC1, 3-bit per channel for BC4/BC5); a single shared value selects mode 1, in which a flat block stores no index payload at all and the decoder expands the header value to all 16 indices. an encoder that leaves a non-uniform or a differing word on a flat block forces mode 0, the classic per-block encoding, so the roundtrip stays byte-exact either way. the mode and the value share the existing header byte (mode | value << 1, right after the top-table size for BC1, one per channel after the tile seeds for BC4/BC5), so packed_*_maxsize are unchanged. the gpu decompressor mirrors the cpu. new synthetic tests: identical_colors_uniform_value / _divergent / _garbage / _mixed (BC1) and bc45_flat_uniform_word / _divergent (BC4+BC5); bc45_flat_uniform is re-documented, its 0x33 word is 6,3,1 repeating as 3-bit values (mode 0 all along), and bc45_flat_uniform_word with a truly uniform word is the real mode 1 coverage. 1.0.0 was never published, hence the 1.0.1 patch bump. release and asan builds: 43/43 tests, gpu bit-identical to cpu
@Geolm
Geolm merged commit dfd811f into main Nov 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant