bcpack: read 32 BC7 dictionary indices per entry, as BCPack.dll (fixes wrong BC7 textures) #182
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/vktory6--VKtory!182
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-182"
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?
@lordra9-svg on GitHub · 2026-12-02 00:53 UTC · original
lordra9-svg:fix/bc7-dictionary→main· +89 −10 · 1 files · 2 commits · openWhat
Fixes BC7 texture decoding: read 32 indices for every BC7 dictionary entry, as BCPack.dll does. Ported from lobomfz/VIctory-xmem b73c5c5 (verified there against BCPack.dll: 2,101,646 of 2,866,176 of the title's BC7 blocks differ before, 0 after).
Bug
Our
Tables::parseskipped the repeated-widths word after a BC7 entry's two width bytes and read 31 indices. BCPack.dll reads 32: in entries 1-254 the first of them IS the widths word (pixel 0's index). So every index of those entries landed one pixel early, and every block predicted from them, i.e. the decoded texture is wrong for ~73% of BC7 blocks.Change
crates/victory-formats/src/bcpack.rs:Tables::parse->parse_with(bytes, bc7_dictionary());n = if k == 0 || all { 32 } else { r.u16(); 31 }.VICTORY_BC7_DICTIONARY(default on;=0restores the old 31-after-the-repeated-widths read) with owner/reason/removal documented.BC7_ENTRY = 50 + 66keeps the same byte size).Verified
bc7_dictionary_entries_read_as_bcpack_dll_reads_them: entry 0 identical; entries 1.. pixel 0 = widths, oldix[0][..15]->ix[0][1..], oldix[0][15]->ix[1][0], endpoints/control/ctrl7 unchanged.cargo test -p victory-formats: 50 passed (baseline 49 + new);VICTORY_BC7_DICTIONARY=0 cargo test ... bc7: 4 passed.cargo test -p victory-core -p xtaskand vkback policy: pass;clippy -D warningsclean;tools/build.shexit 0.Note: verified against the reference's BCPack.dll comparison and a synthetic-table unit test; a local on-screen A/B is pending (the table-parity
reference_chunkstest still needs the shippedbcpack-tables.bin+ cases).@TheRifai on GitHub · 2026-12-02 12:11 UTC · original
Tried the on-screen A/B you noted is pending, but the result is not usable as evidence, so I'm not claiming a visual win from it.
Setup: your branch at
8e1f12d,VICTORY_BC7_DICTIONARY=1vs=0, RX 9070 XT / RADV 26.3.1, GE-Proton11-16, Series X 3840x2160,VKB_LIVE_SHOT=<base>with<base>.req=3at 45-50 s, city70 and house savert3. Three frames each.So this is a timing confound, not a refutation of the fix — the unit test and the BCPack.dll comparison remain the evidence. I'd rather record the negative result than attach misleading screenshots. Evidence kept at
/home/shlong/Documents/VKtory-capture/bc7-{shot,static}-{on,off}/.@vktory6 on GitHub · 2026-12-02 15:28 UTC · original
Thanks, this looks like a real fix: 2.1M of 2.87M BC7 blocks differ before it and none after. Three things before it can merge:
VICTORY_BC7_DICTIONARY.=0restores a read we know is wrong, so the switch has only one working setting (rules 2 and 33).bc7_dictionary_indices_line_upwithVICTORY_BCPACK_TABLESset (the PR changes that test's assertion), plus before/after screenshots of a BC7 texture that uses the tables, no game content beyond a plain description. We don't have the tables on this machine, so we can't produce that evidence ourselves.@firefloc on GitHub · 2026-12-02 17:29 UTC · original
I ran
bc7_dictionary_indices_line_upagainst PR head8e1f12dewith local BCPack tables: 1 passed, 0 failed, 0 ignored. To rule out the test's silent early return when table loading fails, I changed only that return toTables::load().expect(...)in an isolated source copy. A nonexistent table path made the test fail, and the same test passed with the local tables andVICTORY_BC7_DICTIONARYunset. The test ran offline without Proton or the GPU.This confirms the dictionary-index assertions for these tables. The requested visual before/after check remains open. When removing the toggle and the legacy branch, please also update the
Tables::parselayout description, which still says 31 indices even though the revised path reads 32 words for every entry.@firefloc on GitHub · 2026-12-02 18:50 UTC · original
Rechecked the unconditional 32-word parser on
55369b31.bc7_dictionary_indices_line_uppassed with local tables (1 passed, 0 failed, 0 ignored). In an isolated test copy, requiring table load explicitly made the same test fail with a missing table path. The current head also removes the toggle and updates the format description.As a separate synthetic test, the same tables and 64 synthetic records produced different BC7 output blocks in all 64 cases when comparing the current parser with a simulation of the old index interpretation. This establishes that the index change affects decoded blocks in that fixture. The BCPack.dll comparison and the requested matched visual evidence are separate checks.
@lordra9-svg on GitHub · 2026-12-02 19:14 UTC · original
Ran the dictionary tests with the real tables on the current head (
55369b3, after dropping the switch):The three review items are in that head:
VICTORY_BC7_DICTIONARYis gone (32 readings unconditional), the parse-site comment states what BCPack.dll's decoder does (32 words, pixel 0 first) with the 31-vs-32 block differential, andTables::parse's layout says 32 index words.On the visual pair: I can't produce an honest one from this machine. My F9 capture path is not writing frames here, and the save I have is an animated cutscene — TheRifai's A/B already showed that timing confound. Rather than post a misleading pair, I can render a synthetic BC7 texture (a known block encoded with the title's tables, decoded by the old 31-word and the new 32-word path, side by side) so the difference is real and there is no game content; or use a static save if you have one in mind. Which would you prefer?
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.