Validate BC7 control-word subset counts #1556
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1557"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by oddmaniv on 2026-11-24T19:10:12Z.
Summary
Validate nonzero BC7 control words while parsing BCPack tables: modes 0–7 must encode subset counts
[3, 2, 3, 2, 1, 1, 1, 2]. Keep the all-zero control word valid as the existing sentinel.The regression test uses synthetic tables and exercises subset counts 0–3 for every mode, accepting each mode's required count and rejecting the other nonzero controls with the parser's specific validation error. It also verifies the zero sentinel. This is defensive validation for malformed/caller-supplied table data; shipped nonzero controls are valid, and no title-data failure or gameplay improvement is demonstrated.
Verification
rustfmt --check --edition 2024 crates/victory-formats/src/bcpack.rscargo test --locked -p victory-formats— 24 passed, 0 failed, 4 ignored.cargo clippy --locked -p victory-formats --all-targets -- -D warningscargo clippy --locked -p victory-formats --all-targets --all-features -- -D warningscargo xtask policy— 154 files accepted.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:20:57Z.
Review: APPROVED
BC7 control-word validation: subset count
(c & 0xff) >> 6must match the mode's partition count[3,2,3,2,1,1,1,2](checked against the BC7 spec), withc == 0kept as the valid sentinel. The test sweeps all 8 modes × 4 subset counts against synthetic tables, including the sentinel.cargo test -p victory-formats --lockedon macOS arm64: 24 passed, 0 failed (+1).Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T19:46:07Z.
Review: APPROVED
Tested
1504ec9on Windows 11, RTX 5070, MSVC: builds,cargo test --workspace --no-fail-fast612 passed, 0 failed (on our fork main). The new test passes.[3, 2, 3, 2, 1, 1, 1, 2]is the BC7 per-mode subset count, and the zero sentinel stays accepted.the_shipped_tables_parse(which loadsbcpack-tables.bin) and the decode tests built onTables::builtin()pass. So this only turns malformed or caller-supplied tables into an error instead of a later wrong decode.Merged into our fork's main.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by tdogghockey on 2026-11-24T19:22:25Z.
I independently verified this PR at head
1504ec9on aarch64 Linux.cargo test --offline -p victory-formats --locked bc7_control_subset_counts— 1 passedcargo test --offline -p victory-formats --locked— 24 passed, 0 failed, 4 ignoredcargo clippy --offline -p victory-formats --all-targets --locked -- -D warnings— cleanrustfmt --edition 2024 --check crates/victory-formats/src/bcpack.rs— cleanI also checked the new validation against the decoder's use of
ctrl7: mode/subset extraction matchesbc7/bc7_precision(ctrl & 7,(ctrl & 0xff) >> 6), so rotation/precision bits above the subset field are not rejected, andthe_shipped_tables_parsestill passes.No correctness issue found in the host-independent code. Scope note: I did not run Windows/GPU tests or CI. No approval implied.
Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:34:19Z.
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
1504ec9applied cleanly onto currentmainccfb029.cargo test --locked -p victory-formats: 24 passed, 0 failed, 4 ignored. The new BC7 control-word validation test passes.cargo clippy -p victory-formats --all-targets --all-features --locked -- -D warnings: clean.Not tested: Windows MSVC build, the title itself. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:18:47Z.
Automated triage for the maintainers.
Proposed close: a guard for a case that does not occur. The new check in
Tables::parse(crates/victory-formats/src/bcpack.rs) rejects control words whose subset count differs from the BC7 mode's. As the description says, the shipped tables have no such word and no failure is shown. The decoder inmaindoes not need the check to stay safe:bc7already refuses a zero control word, readsmodeandsubsetsfrom the word, and only walkstake(subsets)rows of fixed-size arrays. A mismatched word would decode wrongly, but cannot read out of bounds. A table that triggered the check would also make the whole parse fail rather than only the affected blocks.This pull request will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.