bcpack: decode BC7 from packed indices behind VICTORY_BCPACK_FAST_BC7 #56

Manually merged
github merged 1 commit from github-bot/gh-55 into main 2026-12-04 21:41:35 +00:00 AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-04 21:01 UTC · original
SovietBearz0r:pr/bc7-fast → main · +398 −0 · 2 files · 1 commits · merged 2026-12-04 21:39 UTC

BC7 blocks are rebuilt from 16-bit index words, one pixel at a time. This adds a second decoder that keeps the indices packed in 64-bit fields, works out each control word's field layout once, and assembles a block with a pass of shifts and pext — same bytes, less work per pixel.

Opt-in: VICTORY_BCPACK_FAST_BC7=1, x86_64 with BMI2 only; without it the existing lane decoder runs exactly as before. It is not on by default because it has not been measured on the title's texture streams yet.

This is the bc7_fast.rs piece from the closed #14, ported to current main as its own change: the file, a OnceLock of the packed controls and dictionary in Tables, and one branch in decode_with.

Verified

  • cargo test -p victory-formats — 45 passed, 6 ignored; the bcpack subset also passes with VICTORY_BCPACK_FAST_BC7=1.
  • New test packed_bc7_matches_the_lane_decoder: 4,096 varied records decode byte-identically, and both paths refuse the same unused control codes.
  • cargo clippy -p victory-formats --all-targets -- -D warnings: clean.
  • cargo xtask policy: ok.

Not done: an FPS or steady-state measurement on the title's texture streams. The block output is identical by construction; the difference is decode time.

**@⁠SovietBearz0r** on GitHub · 2026-12-04 21:01 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/55) `SovietBearz0r:pr/bc7-fast` → `main` · +398 −0 · 2 files · 1 commits · merged 2026-12-04 21:39 UTC BC7 blocks are rebuilt from 16-bit index words, one pixel at a time. This adds a second decoder that keeps the indices packed in 64-bit fields, works out each control word's field layout once, and assembles a block with a pass of shifts and `pext` — same bytes, less work per pixel. Opt-in: `VICTORY_BCPACK_FAST_BC7=1`, x86_64 with BMI2 only; without it the existing lane decoder runs exactly as before. It is not on by default because it has not been measured on the title's texture streams yet. This is the `bc7_fast.rs` piece from the closed #14, ported to current `main` as its own change: the file, a `OnceLock` of the packed controls and dictionary in `Tables`, and one branch in `decode_with`. **Verified** - `cargo test -p victory-formats` — 45 passed, 6 ignored; the bcpack subset also passes with `VICTORY_BCPACK_FAST_BC7=1`. - New test `packed_bc7_matches_the_lane_decoder`: 4,096 varied records decode byte-identically, and both paths refuse the same unused control codes. - `cargo clippy -p victory-formats --all-targets -- -D warnings`: clean. - `cargo xtask policy`: ok. Not done: an FPS or steady-state measurement on the title's texture streams. The block output is identical by construction; the difference is decode time.
BC7 blocks are rebuilt from 16-bit index words, one pixel at a time.
This adds a decoder that keeps the indices packed in 64-bit fields,
works out each control word's field layout once, and assembles a block
with shifts and pext. The bytes are the same; the work per pixel is not.

Opt in with VICTORY_BCPACK_FAST_BC7=1 on x86_64 with BMI2; without it
the lane decoder runs exactly as before.

The block decoder is checked against the lane decoder over 4,096 varied
records: the same bytes, and the same refusal for the control codes the
tables leave unused.

This is the bc7_fast.rs piece from #14, split out on current main.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 21:04:21 +00:00
github manually merged commit 74ff043414 into main 2026-12-04 21:41:35 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.