BCPack: BC7 dictionary indices read as Microsoft's decoder reads them #1408

Merged
atk3001 merged 1 commit from upstream-pr/1408 into main 2026-11-29 08:16:56 +00:00
atk3001 commented 2026-11-28 19:15:22 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by atk3001 on 2026-11-28T19:15:22Z.


What

Each BC7 dictionary entry in the BCPack tables stores its two index widths and then the indices. Microsoft's decoder (BCPack.dll) does not skip the word after the widths. In every entry but the first, that word is the widths again, and the decoder takes it as pixel 0's index. So the stored indices land one pixel later than we placed them, and the last one spills into set 1, which no entry uses (0 index bits).

Our reader skipped that word and filled 31 slots, so every pixel of a dictionary-coded BC7 block took its neighbour's index.

  • Tables::bc7: all 32 slots are read in order, pixel 0 included.
  • The test bc7_dictionary_indices_line_up now checks the layout the decoder uses: pixel 0 equals the widths word in entries after the first, and set 1 has no index bits.

Tests

  • I checked the fix against BCPack.dll with a local comparison test. I did not include that test: it needs the GDK's DLL.
  • victory-formats lib: 46 passed. Clippy is clean.

Overlap

  • #674 restructures the same reader and keeps the 31-slot skip. The two will conflict, and #674 would keep the bug.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5543693361 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1408). Originally posted by [atk3001](https://github.com/atk3001) on 2026-11-28T19:15:22Z. --- ## What Each BC7 dictionary entry in the BCPack tables stores its two index widths and then the indices. Microsoft's decoder (BCPack.dll) does not skip the word after the widths. In every entry but the first, that word is the widths again, and the decoder takes it as pixel 0's index. So the stored indices land one pixel later than we placed them, and the last one spills into set 1, which no entry uses (0 index bits). Our reader skipped that word and filled 31 slots, so every pixel of a dictionary-coded BC7 block took its neighbour's index. - `Tables::bc7`: all 32 slots are read in order, pixel 0 included. - The test `bc7_dictionary_indices_line_up` now checks the layout the decoder uses: pixel 0 equals the widths word in entries after the first, and set 1 has no index bits. ## Tests - I checked the fix against BCPack.dll with a local comparison test. I did not include that test: it needs the GDK's DLL. - `victory-formats` lib: 46 passed. Clippy is clean. ## Overlap - #674 restructures the same reader and keeps the 31-slot skip. The two will conflict, and #674 would keep the bug. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!1408
No description provided.