formats/bcpack: strip-streaming, branchless rANS, and fast BC1-BC7 reconstruction #674

Manually merged
github merged 1 commit from github-bot/gh-674 into main 2026-11-29 08:22:13 +00:00 AGit
Owner

@⁠mint17 on GitHub · 2026-11-28 03:22 UTC · original
mint17:perf/bcpack-strip-streaming → main · +2697 −693 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

Optimizes BCPack texture decoding in crates/victory-formats/src/bcpack.rs with zero unsafe code and bit-exact parity across all 6 BC formats (clean standalone port of our merged TaynanGT/Vice-Tay#233, preserving VIctory-NVIDIA's baseline BC7 dictionary parsing verbatim).

Changes

  • Strip-streaming (STRIP = 256): Decodes 256 blocks per strip so intermediate symbol streams stay resident in L1 cache instead of allocating multi-megabyte full-texture scratch vectors.
  • Branchless rANS & cache-line-aligned ModelTable: Replaces branching symbol lookup / renormalization with branchless rANS over 64-byte-aligned tables, heap-allocating large decode arrays via alloc_boxed_array to avoid stack-frame bloat.
  • Fast BC1–BC7 reconstruction: Uses SWAR/LUT bit-packing across all BC formats with zero unsafe.
  • Preserves baseline semantics: Keeps VIctory-NVIDIA's exact baseline BC7 dictionary parsing and pure LF line endings.

Release Throughput Benchmark (cargo test --release --locked -p victory-formats bcpack_throughput -- --ignored --nocapture, 16,384 blocks × 40 runs)

Format Throughput Time / Block Speedup vs. Baseline
BC1 89.1 MB out/s 89.8 ns/block ~1.86×
BC4 86.1 MB out/s 92.9 ns/block ~1.82×
BC7 50.9 MB out/s 314.4 ns/block ~1.86×

Verification

  • cargo test --locked -p victory-formats (50 passed, 0 failed — includes bit-exact reference-oracle parity across BC1–BC7 and strip-boundary tests).
  • cargo clippy -p victory-formats --all-targets --locked -- -D warnings (default + --all-features), rustfmt --check --edition 2024, and cargo test --locked -p xtask (6 passed, 0 failed, including asset policy).
  • Verified with synthetic tests, reference-oracle checks, and benchmarks only (no game files).
**@⁠mint17** on GitHub · 2026-11-28 03:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/674) `mint17:perf/bcpack-strip-streaming` → `main` · +2697 −693 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC Optimizes BCPack texture decoding in `crates/victory-formats/src/bcpack.rs` with **zero `unsafe` code** and bit-exact parity across all 6 BC formats (clean standalone port of our merged `TaynanGT/Vice-Tay#233`, preserving `VIctory-NVIDIA`'s baseline BC7 dictionary parsing verbatim). ### Changes - **Strip-streaming (`STRIP = 256`):** Decodes 256 blocks per strip so intermediate symbol streams stay resident in L1 cache instead of allocating multi-megabyte full-texture scratch vectors. - **Branchless rANS & cache-line-aligned `ModelTable`:** Replaces branching symbol lookup / renormalization with branchless rANS over 64-byte-aligned tables, heap-allocating large decode arrays via `alloc_boxed_array` to avoid stack-frame bloat. - **Fast BC1–BC7 reconstruction:** Uses SWAR/LUT bit-packing across all BC formats with zero `unsafe`. - **Preserves baseline semantics:** Keeps `VIctory-NVIDIA`'s exact baseline BC7 dictionary parsing and pure LF line endings. ### Release Throughput Benchmark (`cargo test --release --locked -p victory-formats bcpack_throughput -- --ignored --nocapture`, 16,384 blocks × 40 runs) | Format | Throughput | Time / Block | Speedup vs. Baseline | | --- | ---: | ---: | ---: | | **BC1** | **89.1 MB out/s** | 89.8 ns/block | **~1.86×** | | **BC4** | **86.1 MB out/s** | 92.9 ns/block | **~1.82×** | | **BC7** | **50.9 MB out/s** | 314.4 ns/block | **~1.86×** | ### Verification - `cargo test --locked -p victory-formats` (50 passed, 0 failed — includes bit-exact reference-oracle parity across BC1–BC7 and strip-boundary tests). - `cargo clippy -p victory-formats --all-targets --locked -- -D warnings` (default + `--all-features`), `rustfmt --check --edition 2024`, and `cargo test --locked -p xtask` (6 passed, 0 failed, including asset policy). - Verified with synthetic tests, reference-oracle checks, and benchmarks only (no game files).
Optimize BCPack texture decoding in crates/victory-formats/src/bcpack.rs
with zero unsafe code and bit-exact parity across all 6 BC formats
(ported cleanly from Vice-Tay #233 while preserving VIctory-NVIDIA's
baseline BC7 dictionary parsing):

- Strip-streaming (STRIP = 256): decode 256 blocks at a time so
  intermediate symbol buffers stay in L1 cache instead of allocating
  multi-megabyte per-stream vectors.
- Branchless rANS with 64-byte cache-line-aligned ModelTable and
  heap-allocated large table arrays (avoiding stack-frame bloat).
- Fast SWAR/LUT BC1-BC7 block reconstruction.
- Preserve VIctory-NVIDIA's baseline BC7 dictionary parsing verbatim and
  include bit-exact reference-oracle and strip-boundary regression tests.
- Release throughput (16,384 blocks x 40 runs): BC1 89.1 MB/s, BC4
  86.1 MB/s, BC7 50.9 MB/s (~1.82x-1.86x over baseline).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 03:25:21 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 05:34 UTC · original · approved these changes

LGTM — verified on Windows:

  • cargo test -p victory-formats --lib bcpack:: passed (15/15, including all 4 new oracle_parity_* tests across BC1–BC7 modes, rotations, subsets, strip boundaries, and malformed inputs)
  • cargo clippy -p victory-formats --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (294 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-28 05:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/674#pullrequestreview-6096062862) · **approved these changes** LGTM — verified on Windows: - `cargo test -p victory-formats --lib bcpack::` passed (15/15, including all 4 new `oracle_parity_*` tests across BC1–BC7 modes, rotations, subsets, strip boundaries, and malformed inputs) - `cargo clippy -p victory-formats --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`294 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github manually merged commit 5347fb7f8a into main 2026-11-29 08:22:13 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!674
No description provided.