BCPack: BC7 secondary-index reset rule and alpha fit, BC6H refit with exact rules #58

Manually merged
github merged 2 commits from gh-pr/58/head into gh-pr/58/base 2026-11-26 20:06:28 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-23 16:42 UTC · original
holdmysocks:claude/bcpack-rules → master · +359 −358 · 2 files · 2 commits · merged 2026-11-23 18:09 UTC

Changes to the BCPack BC7 and BC6H decoders. One decoder rule changes; the rest is preset tables.

BC7: decoder rule fix. A block that has no secondary index set (every mode except 4 and 5) now resets that set to zero instead of carrying the previous one forward. Evidence: a valid BC7 block never has an anchor index with its top bit set. With the reset, that holds for all 24,316,547 anchor reads on chains that do not touch the preset tables (all 5,167 BC7 chunks); the old rule broke it for 29% of chained mode 4/5 blocks.

BC7: tables. Index presets made consistent with the anchor rule, all presets refitted under the new rule, and alpha added to the fit (it scored only red, green and blue before, so alpha presets were never fitted).

Whole-install mip check (mip 0 downsampled against mip 1), 1,433 BC7 textures:

before after
colour mean 35.1 dB 39.2 dB
colour median 33.5 dB 38.1 dB
colour under 30 dB 27.1% 4.6%
colour under 20 dB 2.0% 1.2%
alpha mean 39.8 dB (after the rule fix) 49.2 dB
alpha under 30 dB 40.8% (after the rule fix) 13.2%

BC6H: tables only. Every preset slot is fitted on real-reference and bootstrap chunks together, with two exact rules enforced: an anchor index never has its top bit set, and in a transformed mode an endpoint (w plus signed delta) never wraps. Both hold without exception on table-independent chains (2,433,955 anchor reads, 1,606,398 endpoints). Anchor violations in the tables: 0 left. Wraps: 23,162 before, 599 after.

before after
mip check mean (BCPack-only textures) 18.7 dB 24.7 dB
mip check median 19.6 dB 24.0 dB
under 20 dB 51.7% 23.6%
real references, parent mip: blocks within tolerance 87.7% 87.7%
real references, child mip: blocks within tolerance 86.1% 88.4%

Plain BC6H scores 29.1 dB on the same mip check, so BC6H is still not exact.

Tests: cargo test --release -p sixng-core bc passes (18 tests).

**@⁠holdmysocks** on GitHub · 2026-11-23 16:42 UTC · [original](https://github.com/holdmysocks/SixNG/pull/58) `holdmysocks:claude/bcpack-rules` → `master` · +359 −358 · 2 files · 2 commits · merged 2026-11-23 18:09 UTC Changes to the BCPack BC7 and BC6H decoders. One decoder rule changes; the rest is preset tables. **BC7: decoder rule fix.** A block that has no secondary index set (every mode except 4 and 5) now resets that set to zero instead of carrying the previous one forward. Evidence: a valid BC7 block never has an anchor index with its top bit set. With the reset, that holds for all 24,316,547 anchor reads on chains that do not touch the preset tables (all 5,167 BC7 chunks); the old rule broke it for 29% of chained mode 4/5 blocks. **BC7: tables.** Index presets made consistent with the anchor rule, all presets refitted under the new rule, and alpha added to the fit (it scored only red, green and blue before, so alpha presets were never fitted). Whole-install mip check (mip 0 downsampled against mip 1), 1,433 BC7 textures: | | before | after | |---|---|---| | colour mean | 35.1 dB | 39.2 dB | | colour median | 33.5 dB | 38.1 dB | | colour under 30 dB | 27.1% | 4.6% | | colour under 20 dB | 2.0% | 1.2% | | alpha mean | 39.8 dB (after the rule fix) | 49.2 dB | | alpha under 30 dB | 40.8% (after the rule fix) | 13.2% | **BC6H: tables only.** Every preset slot is fitted on real-reference and bootstrap chunks together, with two exact rules enforced: an anchor index never has its top bit set, and in a transformed mode an endpoint (w plus signed delta) never wraps. Both hold without exception on table-independent chains (2,433,955 anchor reads, 1,606,398 endpoints). Anchor violations in the tables: 0 left. Wraps: 23,162 before, 599 after. | | before | after | |---|---|---| | mip check mean (BCPack-only textures) | 18.7 dB | 24.7 dB | | mip check median | 19.6 dB | 24.0 dB | | under 20 dB | 51.7% | 23.6% | | real references, parent mip: blocks within tolerance | 87.7% | 87.7% | | real references, child mip: blocks within tolerance | 86.1% | 88.4% | Plain BC6H scores 29.1 dB on the same mip check, so BC6H is still not exact. Tests: `cargo test --release -p sixng-core bc` passes (18 tests).
Blocks of modes other than 4 and 5 carried the previous secondary index
state forward. With the reset, the anchor rule (an anchor index never has
its top bit set) holds on every table-independent chain; before, 29% of
chained mode 4/5 blocks broke it. Whole-install mip check on 1,433 BC7
textures: mean 35.1 -> 38.7 dB, median 33.5 -> 37.9 dB, under 30 dB
27.1% -> 6.8%; 917 textures gain more than 1 dB, none lose more than 1 dB.
Fit every slot on the real-reference and bootstrap chunks together
(real references weighted 20x) instead of freezing the slots that have
real references, whose unread fields could be wrong. Then make the index
presets obey the anchor rule: 992 slot/anchor entries, 720 pinned to a
single value, no violations left. Mip check on BCPack-only textures:
median 19.6 -> 22.1 dB, under 20 dB 51.7% -> 36.0%; real-reference
check 87.7% of blocks within tolerance, 28.6 dB.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:06:26 +00:00
github manually merged commit bca2da3ec4 into gh-pr/58/base 2026-11-26 20:06:28 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.