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

Manually merged
github merged 1 commit from github-bot/gh-1408 into main 2026-11-29 08:22:14 +00:00 AGit
Owner

@⁠atk3001 on GitHub · 2026-11-28 19:15 UTC · original
atk3001:pr/bc7-dictionary → main · +10 −8 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

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

**@⁠atk3001** on GitHub · 2026-11-28 19:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1408) `atk3001:pr/bc7-dictionary` → `main` · +10 −8 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC ## 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)
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 19:19:21 +00:00
github manually merged commit 3ecbf1680f into main 2026-11-29 08:22:14 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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