Skip to content

[pr-fix] BCPack: BC7 dictionary indices read as Microsoft's decoder reads them - #13

Merged
KyleS98 merged 1 commit into
KyleS98:mainfrom
Melow-code:fix/bcpack-bc7
Nov 29, 2026
Merged

KyleS98 merged 1 commit into
KyleS98:mainfrom
Melow-code:fix/bcpack-bc7

Conversation

@Melow-code

Copy link
Copy Markdown
Contributor

Backport of trustno1-coder/VIctory-NVIDIA#1408 (atk3001; merged there after Neo's merge of 29 November), cherry-picked as it is.

What it changes

The BC7 dictionary of bcpack-tables.bin is read with all 32 index slots in order. Without it, every stored index sits one pixel early, so a block that uses the dictionary is decoded wrong, and so is every block predicted from it. It concerns BC7 textures from DirectStorage.

Evidence

  • ProjectLeonida/mandy compared 381 of the title's BC7 streams with the GDK's BCPack.dll: 2,101,646 of 2,866,176 blocks were unlike the DLL's before, none after (their commit b589e0fe0, after the same fix). Not checked here.
  • My own check was of the table only, against the dictionary of bcpack-rs (c23cf5ce): the 16 set-0 indices agree for 255 of 255 entries with this reading, 0 of 255 without it. bcpack-rs does not name its reference decoder.
  • BCPack: read BC7 dictionary indices from the right offset Marvisak/VIctory#658 (closed) argued for the old reading from how the table looks, without comparing decoded blocks.

How it was tested

  • Linux, Rust 1.98.1, on ab89c8d: cargo test -p victory-formats --lib: 57 passed, 0 failed (5 ignored).
  • Not run: the game, BCPack.dll, Windows.

Checked for overlap

  • No open pull request here touches bcpack.rs.

🤖 Generated with Claude Code

The decoder takes the word after an entry's index widths (the widths
again in all entries but the first) as pixel 0's index, so the stored
indices land one pixel later than we placed them. Read all 32 slots in
order; the test checks the layout BCPack.dll uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f9de61c52e59ca1ddc6b9b088c7648021b52b9a2)
@KyleS98
KyleS98 merged commit 89b12bc into KyleS98:main Nov 29, 2026
1 of 2 checks passed
@KyleS98

KyleS98 commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Merged (89b12bc, in main at 147473d), thank you. The diff is line for line upstream's f9de61c5, which its main has, so Neo would have had it at the next merge; it is in now. It stays out of the shader crate, so it needed no preload of its own; it went through the same runs as #12 and #14 (the opening, the cell, the first house, the deck on an RTX 3090 Ti): no error, and nothing in the textures I could tell from before. I have no decoded-block comparison against the console's decoder to offer, only that.

AI-assisted (Claude Code, Claude Fable 5.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants