formats: read the first BC7 dictionary entry's 32 indices #181
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!181
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-181"
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?
@davutsimsekk on GitHub · 2026-11-25 19:35 UTC · original
davutsimsekk:fix/bc7-dictionary-entry→main· +21 −3 · 1 files · 1 commits · openThe BC7 dictionary reader consumed 32 index words for every entry. The first entry does store all 32 right after its width bytes, but every later entry repeats the width bytes first and then stores 31 indices. The old parser kept the entry size at 116 bytes, but put the repeated width in
ix[0][0], so every later index moved one slot and the last slot was read from the zero-filled set 1.This keeps the 32-index form for entry 0 and skips the repeated width for entries 1-254.
Tested
cargo test -p victory-formats --lib --locked bc7_dictionary_entries_keep_their_indices: 1 passed.bcpack-tables.bin: entry 0 starts2,1,0; entry 1 starts1,0,0after its repeated width.Not tested
AI use
@KernelSmoker on GitHub · 2026-11-25 20:00 UTC · original
Independent verification on PR head
6281cbb(Bazzite Linux 45 x86_64, Rust 1.98.1):cargo test --offline --locked -p victory-formats: 25 passed, 0 failed, 4 ignored (includingbc7_dictionary_entries_keep_their_indices).cargo clippy --offline --locked -p victory-formats --all-targets: 0 warnings.crates/victory-formats/src/bcpack-tables.bin(last255 * 116bytes):0:bits=(4, 0), firstu16afterbitsis2(no repeated width word), followed by 32 index words (words[16..32]all zero).1..255: 254/254 have firstu16afterbitsequal tobits[0] | (bits[1] << 8)(0 mismatches), 0/255 havebits[1] != 0, and 0/255 have any non-zero slot in set 1 (words[17..32]for entries1..255).50 + 2 + 64), so stream alignment is preserved.@lcg007xd-c on GitHub · 2026-11-25 21:10 UTC · original · approved these changes
Verified on Linux (Rust 1.98.1)
cargo test -p victory-formats --libon6281cbb: 25 passed, 0 failed, 4 ignored (main: 24 passed).Tables::parseand kept the new test.bc7_dictionary_entries_keep_their_indicesthen fails withleft: [3, 1, 0],right: [1, 0, 0]. The test does catch the bug.cargo clippy -p victory-formats --target x86_64-pc-windows-msvc: 0 warnings, same as main.git merge --no-commit --no-ffinto current main: merges cleanly.255 * 116bytes ofbcpack-tables.binmyself. For entries 1..254, the first word afterbitsequalsbits[0] | bits[1] << 8every time. After that come 16 index words and 15 zero words. Each entry still takes 116 bytes, so the stream stays aligned.Notes
bcpack.rs:225). Entry 0 hasbits = (4, 0)and words2, 1, 0, 0, .... The PR reads that as "no repeated width". It could also be a leading field that equals the width in 254 entries but not here. In that reading, entry 0's indices would be[1, 0, 0, ...]instead of[2, 1, 0, ...]. The new test checks that entry 0 is parsed the way main already parsed it, so it doesn't decide between the two. If you have BC7 reference chunks, running the ignoredreference_chunkstest (VICTORY_BCPACK_TABLES/VICTORY_BCPACK_CASES) on a block that uses dictionary entry 0 would settle it. I'm approving because entries 1..254 are clearly fixed and entry 0 behaves as before.ix[0][0], so every index moved one slot and the 16th index landed inix[1][0].Not verified
Reviewed with Claude Code.
@adrianmjim on GitHub · 2026-11-26 19:41 UTC · original
Tested natively on Windows 11 (Rust 1.98.1) at
6281cbb, and also with the PR merged onto current main4f62c2a. The author ran only the new test, so this is the full lib test run on Windows. The tests are CPU-only.cargo test -p victory-formats --lib --locked: 25 passed, 0 failed, 4 ignored on the PR head and on the merge.4f62c2aalone: 24 passed. Main has no other changes in victory-formats since000ffdd.One small thing not mentioned yet:
Tables::parse(bcpack.rs:132) still gives the BC7 entry layout asu16 control, 24 u16, 2 u8, 32 i16. With this change, that only matches entry 0. Entries 1-254 are now read asu16 control, 24 u16, 2 u8, u16 (repeated width), 31 i16. It may be worth updating so the layout note matches the parser.Not tested: no in-game texture decode and no reference-chunk comparison. The entry 0 question from the review is still open.
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.