BCPack: the test oracle reads BC7 dictionary entries as Tables::parse does #2236

Open
github-bot wants to merge 1 commit from github-bot/gh-2236 into main AGit
Owner

@⁠domx4q on GitHub · 2026-11-29 10:52 UTC · original
domx4q:fix/bcpack-oracle-layout → main · +3 −2 · 1 files · 1 commits · open

What it changes

On current main, three tests in victory-formats fail:

  • bcpack::tests::oracle_parity_all_formats_and_strip_boundaries
  • bcpack::tests::oracle_parity_all_bc7_modes_rotations_subsets
  • bcpack::tests::oracle_parity_errors_and_noise

f9de61c5 ("BC7 dictionary indices read as Microsoft's decoder reads them") changed how Tables::parse reads a BC7 dictionary entry: the word after the index widths is now pixel 0's index, and all 32 slots are read. The test oracle in tests::ref_oracle keeps its own copy of the parser (RefTables::parse). That copy still skips that word and reads only 31 slots. The fast decoder and the oracle therefore disagree in the index bytes of every BC7 block that comes from the dictionary, and that is where the tests fail.

This changes only the oracle's parser, so that it reads entries the way Tables::parse now does. The decoder is unchanged.

How it was tested

  • cargo test -p victory-formats --lib, on Linux:
    • before, on main 829188e9: 80 passed, 3 failed
    • after: 83 passed, 0 failed
  • Not a shader change. Nothing changes at run time.

Checked for overlap

  • I searched the open pull requests and issues for oracle_parity and bcpack. None touches the oracle.
**@⁠domx4q** on GitHub · 2026-11-29 10:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236) `domx4q:fix/bcpack-oracle-layout` → `main` · +3 −2 · 1 files · 1 commits · open ## What it changes On current main, three tests in `victory-formats` fail: - `bcpack::tests::oracle_parity_all_formats_and_strip_boundaries` - `bcpack::tests::oracle_parity_all_bc7_modes_rotations_subsets` - `bcpack::tests::oracle_parity_errors_and_noise` f9de61c5 ("BC7 dictionary indices read as Microsoft's decoder reads them") changed how `Tables::parse` reads a BC7 dictionary entry: the word after the index widths is now pixel 0's index, and all 32 slots are read. The test oracle in `tests::ref_oracle` keeps its own copy of the parser (`RefTables::parse`). That copy still skips that word and reads only 31 slots. The fast decoder and the oracle therefore disagree in the index bytes of every BC7 block that comes from the dictionary, and that is where the tests fail. This changes only the oracle's parser, so that it reads entries the way `Tables::parse` now does. The decoder is unchanged. ## How it was tested - `cargo test -p victory-formats --lib`, on Linux: - before, on main 829188e9: 80 passed, 3 failed - after: 83 passed, 0 failed - Not a shader change. Nothing changes at run time. ## Checked for overlap - [x] I searched the open pull requests and issues for `oracle_parity` and `bcpack`. None touches the oracle.
f9de61c5 moved Tables::parse to BCPack.dll's layout (the word after an
entry's widths is pixel 0's index) but left the test oracle's copy of
the parser on the old one, so the three oracle_parity tests failed on
main. The oracle now reads all 32 slots the same way.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 10:55:28 +00:00
Author
Owner

@⁠Halfect on GitHub · 2026-11-29 11:11 UTC · original · approved these changes

LGTM. The reference parser now consumes the same 32 BC7 index words as Tables::parse, including the word after the widths as pixel 0's index. This corrects the independent test oracle without changing the runtime decoder.

I reproduced the before/after locally with cargo test --locked -p victory-formats --lib:

  • Base 829188e969ffd2907e5867c5d9aca29bd91cb1b6: 80 passed, 3 failed, 7 ignored. The failures are exactly oracle_parity_all_bc7_modes_rotations_subsets, oracle_parity_all_formats_and_strip_boundaries, and oracle_parity_errors_and_noise.
  • PR head 18eaf9476cdeb19a47a8ec9c43cfbeb8446a8fe6: 83 passed, 0 failed, 7 ignored.
  • git diff --check origin/main..HEAD: clean.

No game data was used.

**@⁠Halfect** on GitHub · 2026-11-29 11:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#pullrequestreview-6102611652) · **approved these changes** LGTM. The reference parser now consumes the same 32 BC7 index words as `Tables::parse`, including the word after the widths as pixel 0's index. This corrects the independent test oracle without changing the runtime decoder. I reproduced the before/after locally with `cargo test --locked -p victory-formats --lib`: - Base `829188e969ffd2907e5867c5d9aca29bd91cb1b6`: **80 passed, 3 failed, 7 ignored**. The failures are exactly `oracle_parity_all_bc7_modes_rotations_subsets`, `oracle_parity_all_formats_and_strip_boundaries`, and `oracle_parity_errors_and_noise`. - PR head `18eaf9476cdeb19a47a8ec9c43cfbeb8446a8fe6`: **83 passed, 0 failed, 7 ignored**. - `git diff --check origin/main..HEAD`: clean. No game data was used.
Author
Owner

@⁠Yuanzer on GitHub · 2026-11-29 12:08 UTC · original

Independent integration check on the reporter's Windows 11 machine (AI-assisted):

  • Parent: 0b8225e3 on the current #2244 branch.
  • Applied this PR's head 18eaf947 cleanly as local commit 4f09c9bb.
  • Toolchain: Rust 1.98.1 x86_64-pc-windows-msvc; i7-14700KF, RTX 5060 Ti 8 GB.

Results:

  • cargo test --locked -p victory-formats oracle_parity -- --test-threads=1: 4 passed, 0 failed, including all three previously failing oracle_parity_* tests.
  • cargo test --workspace --locked --quiet -- --test-threads=1: every crate and application suite passed, including victory-gpu with 919 passed / 57 ignored and victory-shader with 462 passed / 9 ignored.
  • The only workspace failure was the pre-existing, untouched xtask::policy::tests::repository_passes_policy on crates/victory-loader/src/heap_sites/frame_users.rs (2,022 hex digits in one run). #2244 already documents this separately.
  • Both cargo clippy --workspace --all-targets configurations with -D warnings pass on parent 0b8225e3.

So this BCPack fix cleanly clears the three failures seen in #2244. It is currently blocked only because current main's pre-existing Clippy errors stop the check before it reaches tests; once #2019/#2048 or the warning-cleanup commit from #2244 lands, this can be rerun.

Tested locally on behalf of the reporter.

**@⁠Yuanzer** on GitHub · 2026-11-29 12:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#issuecomment-7255595552) Independent integration check on the reporter's Windows 11 machine (AI-assisted): - Parent: `0b8225e3` on the current #2244 branch. - Applied this PR's head `18eaf947` cleanly as local commit `4f09c9bb`. - Toolchain: Rust 1.98.1 x86_64-pc-windows-msvc; i7-14700KF, RTX 5060 Ti 8 GB. Results: - `cargo test --locked -p victory-formats oracle_parity -- --test-threads=1`: **4 passed, 0 failed**, including all three previously failing `oracle_parity_*` tests. - `cargo test --workspace --locked --quiet -- --test-threads=1`: every crate and application suite passed, including `victory-gpu` with **919 passed / 57 ignored** and `victory-shader` with **462 passed / 9 ignored**. - The only workspace failure was the pre-existing, untouched `xtask::policy::tests::repository_passes_policy` on `crates/victory-loader/src/heap_sites/frame_users.rs` (2,022 hex digits in one run). #2244 already documents this separately. - Both `cargo clippy --workspace --all-targets` configurations with `-D warnings` pass on parent `0b8225e3`. So this BCPack fix cleanly clears the three failures seen in #2244. It is currently blocked only because current `main`'s pre-existing Clippy errors stop the check before it reaches tests; once #2019/#2048 or the warning-cleanup commit from #2244 lands, this can be rerun. *Tested locally on behalf of the reporter.*
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 12:32 UTC · original

Same finding here, independently: on 829188e9, cargo test -p victory-formats --locked fails oracle_parity_all_bc7_modes_rotations_subsets, oracle_parity_errors_and_noise and oracle_parity_all_formats_and_strip_boundaries; reading all 32 index words after the two width bytes in the oracle (as Tables::parse does since f9de61c5) makes the crate 83 passed, 0 failed. We had reached the same reading of the dictionary entries on our tree earlier (the word after the widths is pixel 0's index, there is no repeated widths word), and a run on an RTX 4090 with it showed no picture regression. +1 for merging.

**@⁠dyshay** on GitHub · 2026-11-29 12:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#issuecomment-7255885105) Same finding here, independently: on 829188e9, `cargo test -p victory-formats --locked` fails `oracle_parity_all_bc7_modes_rotations_subsets`, `oracle_parity_errors_and_noise` and `oracle_parity_all_formats_and_strip_boundaries`; reading all 32 index words after the two width bytes in the oracle (as `Tables::parse` does since f9de61c5) makes the crate 83 passed, 0 failed. We had reached the same reading of the dictionary entries on our tree earlier (the word after the widths is pixel 0's index, there is no repeated widths word), and a run on an RTX 4090 with it showed no picture regression. +1 for merging.
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 13:05 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs, on top of 829188e9 plus a couple of local fixes). Read the full diff first: no network, process spawning, binaries, build/CI/dependency changes or game data. Builds with --profile diag --features diagnostics; victory-formats tests: 83 passed, 0 failed (3 parity failures before). In-game runs on an RTX 4090 are queued; I'll report back here.

**@⁠dyshay** on GitHub · 2026-11-29 13:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#issuecomment-7256277753) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA), branch `janus-prs`, on top of 829188e9 plus a couple of local fixes). Read the full diff first: no network, process spawning, binaries, build/CI/dependency changes or game data. Builds with `--profile diag --features diagnostics`; victory-formats tests: 83 passed, 0 failed (3 parity failures before). In-game runs on an RTX 4090 are queued; I'll report back here.
Author
Owner

@⁠Andreww2009 on GitHub · 2026-11-29 22:30 UTC · original

I applied 18eaf947 to 716a0c99 on Windows x86-64 with Rust 1.98.1 and compared all 334 synthetic BC7 cases byte-for-byte against the published outputs from Microsoft’s BCPackDecompress. The old reference reader matched 14/334 and returned different bytes for the other 320. With this patch it matched 334/334. The production decoder matched 334/334 on both revisions. Pinned inputs and expected blocks

Would you include a one-block mode 5 regression test that checks each reader against an independently calculated block? I tried this fixture locally:

  • Give the last synthetic dictionary entry index widths [2, 2]. Set slots 0, 15, 16, 31 to 1, 3, 1, 2 respectively. Leave the other slots and endpoints zero.
  • Decode block 0 with dictionary reference 255, zero residuals, one subset and rotation 0. Mode 5 puts the two index sets at bit offsets 66 and 97. Reading the output as a little-endian u128, the expected value is 0x20u128 | (1 << 66) | (3 << 95) | (1 << 97) | (2 << 126). Mode 5 layout

With the old reader, the production assertion passed and the reference assertion failed. With this PR and the extra test, victory-formats passed in debug and release (84 passed, 7 ignored in each).

**@⁠Andreww2009** on GitHub · 2026-11-29 22:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#issuecomment-7263724506) I applied `18eaf947` to `716a0c99` on Windows x86-64 with Rust 1.98.1 and compared all 334 synthetic BC7 cases byte-for-byte against the published outputs from Microsoft’s `BCPackDecompress`. The old reference reader matched **14/334** and returned different bytes for the other 320. With this patch it matched **334/334**. The production decoder matched **334/334** on both revisions. [Pinned inputs and expected blocks](https://github.com/ProjectLeonida/mandy/blob/cb947eac0d1b46ac8a5938d06a17fe7bd95cfe12/tests/fixtures/bcpack-standalone.txt) Would you include a one-block mode 5 regression test that checks each reader against an independently calculated block? I tried this fixture locally: - Give the last synthetic dictionary entry index widths `[2, 2]`. Set slots `0, 15, 16, 31` to `1, 3, 1, 2` respectively. Leave the other slots and endpoints zero. - Decode block 0 with dictionary reference 255, zero residuals, one subset and rotation 0. Mode 5 puts the two index sets at bit offsets 66 and 97. Reading the output as a little-endian `u128`, the expected value is `0x20u128 | (1 << 66) | (3 << 95) | (1 << 97) | (2 << 126)`. [Mode 5 layout](https://learn.microsoft.com/en-us/windows/win32/direct3d11/bc7-format-mode-reference#mode-5) With the old reader, the production assertion passed and the reference assertion failed. With this PR and the extra test, `victory-formats` passed in debug and release (**84 passed, 7 ignored** in each).
Author
Owner

@⁠danielsteman on GitHub · 2026-11-30 14:14 UTC · original

I confirmed this on current main (41adb551).

  • Without this PR, on a clean checkout: cargo test --locked -p victory-formats --lib bcpack::tests::oracle_parity gives 1 passed and 3 failed. The failing tests are the same three listed above, and they fail on macOS (aarch64) as well, so the cause does not depend on the CPU architecture.
  • With this PR's diff applied, it applies cleanly and cargo test --locked -p victory-formats --lib gives 83 passed, 0 failed, 7 ignored.

These same three tests stop cargo test --workspace on other PRs too (for example #3962's Windows run), so merging this unblocks that step for them.

**@⁠danielsteman** on GitHub · 2026-11-30 14:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#issuecomment-7281071157) I confirmed this on current `main` (`41adb551`). - Without this PR, on a clean checkout: `cargo test --locked -p victory-formats --lib bcpack::tests::oracle_parity` gives 1 passed and 3 failed. The failing tests are the same three listed above, and they fail on macOS (aarch64) as well, so the cause does not depend on the CPU architecture. - With this PR's diff applied, it applies cleanly and `cargo test --locked -p victory-formats --lib` gives 83 passed, 0 failed, 7 ignored. These same three tests stop `cargo test --workspace` on other PRs too (for example #3962's Windows run), so merging this unblocks that step for them.
Author
Owner

@⁠RochDawid on GitHub · 2026-12-01 01:32 UTC · original

main already has this change. be0ba3b7 ("bcpack: the BC7 oracle reads the dictionary as Microsoft's decoder does") makes the same edit to RefTables::parse: no skipped word after the widths, and all 32 index slots read. It reached main with the merge of #2565 (ac6b767d, 2026-11-29) and is in every release since v2026.11.30.01.

On main at f5c3d243, cargo test --locked -p victory-formats --lib oracle_parity gives 4 passed, 0 failed (oracle_parity_all_bc7_modes_rotations_subsets, oracle_parity_errors_and_noise, oracle_parity_all_formats_and_strip_boundaries, oracle_parity_all_bc6_modes). I ran it on a macOS host with Rust 1.98.1, not on Windows.

This pull request now conflicts with main and has nothing left to add, so it can probably be closed. #2236, #2419 and #3263 all make this same change.

**@⁠RochDawid** on GitHub · 2026-12-01 01:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2236#issuecomment-7297622023) `main` already has this change. be0ba3b7 ("bcpack: the BC7 oracle reads the dictionary as Microsoft's decoder does") makes the same edit to `RefTables::parse`: no skipped word after the widths, and all 32 index slots read. It reached `main` with the merge of #2565 (ac6b767d, 2026-11-29) and is in every release since v2026.11.30.01. On `main` at f5c3d243, `cargo test --locked -p victory-formats --lib oracle_parity` gives 4 passed, 0 failed (`oracle_parity_all_bc7_modes_rotations_subsets`, `oracle_parity_errors_and_noise`, `oracle_parity_all_formats_and_strip_boundaries`, `oracle_parity_all_bc6_modes`). I ran it on a macOS host with Rust 1.98.1, not on Windows. This pull request now conflicts with `main` and has nothing left to add, so it can probably be closed. #2236, #2419 and #3263 all make this same change.
This pull request has changes conflicting with the target branch.
  • crates/victory-formats/src/bcpack.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2236/head:github-bot/gh-2236'
git switch 'github-bot/gh-2236'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2236'
git switch 'github-bot/gh-2236'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2236'
git switch 'github-bot/gh-2236'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2236'
git switch 'main'
git merge --squash 'github-bot/gh-2236'
git switch 'main'
git merge --ff-only 'github-bot/gh-2236'
git switch 'main'
git merge 'github-bot/gh-2236'
git push origin 'main'
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!2236
No description provided.