BCPack: read BC7 dictionary indices from the right offset #658
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!658
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/658/head"
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?
@coderanonymus on GitHub · 2026-11-24 06:24 UTC · original
coderanonymus:bcpack-bc7-dictionary-indices→main· +18 −3 · 1 files · 1 commits · closed without mergingWhat
Tables::parsereads each 116-byte BC7 dictionary entry asu16 ctrl, 24 u16, 2 u8 bits, 32 i16. That layout does not match the shippedbcpack-tables.bin. After the two width bytes at 50..52, every entry has two more bytes:04 00in 253 entries, the same as the widths (entry 0 has02 00). The 16 set-0 indices start at byte 54, not 52.So the current parse is off by one index:
ix[1][0]. It is nonzero in 233 entries, even thoughbits[1]is 0 in every entry. Bytes 86..116 are zero in all 255 entries.bc7()adds residuals torx.ix[set][p]from the dictionary when the index reference points past the history. So for those blocks, pixel 0 is built on 4 and pixel p on the dictionary's pixel p-1. Each DirectStorage BCPack request is its own stream, so the first 255 blocks of every stream can reach this. Small BC7 mips sit almost entirely in that range.Change: skip the 2 bytes after the widths, then read 16 i16 for set 0 and 15 for set 1.
TABLES_SIZEis unchanged (2 + 2 + 32 + 30 = 66). The layout doc comment now saysBC7 (u16 control, 24 u16, 2 u8, 2 B, 16 + 15 i16).New test
bcpack::tests::bc7_dictionary_indices_line_upchecks the shipped table: a set with 0 bits holds no indices, and pixel 0 of set 0 fits the anchor range0..1 << (bits - 1).Verification
All with
CARGO_TARGET_DIR=/home/eric/src/VIctory/target.cargo test --target x86_64-unknown-linux-gnu -p victory-formats --lib bc7_dictionary_indices_line_upfails:entry 1: [[3, 1, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, 0, -1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]The leading 3 is entry 1's width, and the 1 in set 1 is set 0's last pixel.
cargo test --target x86_64-unknown-linux-gnu -p victory-formats: 21 passed, 0 failed, 3 ignored (reference_chunksand two xma tests that need outside files).cargo clippy -p victory-formats --tests --target x86_64-pc-windows-msvc -- -D warnings: clean.cargo clippy -p victory-hle --target x86_64-pc-windows-msvcbuilds, with one warning already on main inxmem.rs.rustfmt --edition 2024 --check crates/victory-formats/src/bcpack.rs: clean.Not run:
reference_chunks. It needs BC7 reference chunks from outside the repo (VICTORY_BCPACK_CASES), so decoded texels were not compared with real output. The fix rests on the table's own structure. No game was run.No game data used.
🤖 Generated with Claude Code
@pickles976 on GitHub · 2026-11-24 06:26 UTC · original
Heads-up across the fence: the format knowledge in this PR is exactly what the sibling runtime (ivall/xcl) still refuses to decode — dictionary-backed BC blocks are its next measured wall. I have filed it on their tracker (ivall/xcl#832) as a format note: layout, the two misalignment traps you caught (redundant width u16; 15-slot set 1), your tiling invariant and anchor semantics — described, no code lifted given the GPL-2/GPL-3 mismatch, with attribution here. Your PR quietly just became the format reference for both projects.
@molodayamama on GitHub · 2026-11-24 14:03 UTC · original
Independent Windows check of
0ecaa8cb92ac86e9721f9a0870788fe326b645bd(Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).cargo test -p victory-formats --locked --lib bc7_dictionary_indices_line_up -- --test-threads=1 --nocapture: 1 passed.The focused synthetic test checks alignment of the BC7 dictionary indices, including the lookup offset used by the decoder. No external reference chunks were required.
Only source-built synthetic fixtures were used. AI-assisted verification.
Pull request closed