Formats/BCPack: BC7 channel rotation only in modes 4 and 5 (port of Marvisak/VIctory#3111) #412

Open
Jesper-Andersson wants to merge 1 commit from upstream-pr/412 into main
Jesper-Andersson commented 2026-11-27 01:14:46 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Jesper-Andersson on 2026-11-27T01:14:46Z.


Fixes #411.

crates/victory-formats/src/bcpack.rs: bc7_precision() and bc7_pack() read ctrl >> 3 & 3 as a channel rotation for every BC7 mode, but only modes 4 and 5 have a rotation field. Modes 0/1/3 with rotation 1 panic on a shift, modes 0-3 with rotation 2/3 drop a colour channel, and modes 6/7 skip red's p-bit and pack the endpoints out of order. In game this shows as a mosaic of wrong-coloured 4x4 blocks on textures (clothing, on an RTX 2070 SUPER, Series S).

This is Marvisak/VIctory#3111 by RVZO6, applied unchanged.

Change

  • rotation(ctrl) returns the rotation bits only for modes 4 and 5, and 0 otherwise; bc7_precision and bc7_pack use it.
  • No switch.

Where it does nothing

Modes 4 and 5 rotate exactly as before; the test checks their precisions and a packed mode 4/5 block with rotation 1.

Measured

RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB, Windows 11, main @ 014d52d + #203 (DLSS) + pr0vId3nce's own-bytes pool, diag build, Series S + DLSS, play.ps1 settings plus VICTORY_CARD_BUFFERS_MIN_KB=64, CARD_BUFFERS_MB=1024, RESIDENCY=1, WIDE_MERGE=1, WINDOW_KB=1024, SUBMIT_FRAMES=2, CARD_ROOM_FOR_TARGETS_MB=1280. One run each, in the world:

before after
clothing mosaic of wrong-coloured blocks normal
median frame 121 ms 128 ms

It's a picture fix: no frame-time change is expected or claimed (the runs were in different spots).

Checks

  • cargo test -p victory-formats --lib --locked: 42 passed, 5 ignored (new: bc7_rotation_applies_only_to_modes_4_and_5)
  • The new test on main without the fix: fails with "attempt to shift right with overflow" at bc7_pack
  • cargo clippy -p victory-formats --all-targets --locked -- -D warnings: clean
  • cargo fmt -p victory-formats --check: no change in bcpack.rs (one existing difference in texture.rs, untouched here)
  • cargo xtask policy: 1 file ok
  • In game: the same two-line fix (without the test) on the build above; the clothing mosaic is gone

Not checked

AMD; Series X; in game on plain main without the pool.

Marvisak/VIctory#3111 (this fix) and #3386 (the same rotation guard plus a fix to the first BC7 dictionary entry, for that fork's faster decoder, which main doesn't have). fxceless/victory-fork 06702fe, ExoCalibra/victory-exo c1ce2fad and pr0vId3nce/VIctory-NVIDIA 41791231 carry it. No open upstream PR touches bcpack.rs for this.

This change was made with AI assistance (Claude Code).

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5519483177 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/412). Originally posted by [Jesper-Andersson](https://github.com/Jesper-Andersson) on 2026-11-27T01:14:46Z. --- Fixes #411. `crates/victory-formats/src/bcpack.rs`: `bc7_precision()` and `bc7_pack()` read `ctrl >> 3 & 3` as a channel rotation for every BC7 mode, but only modes 4 and 5 have a rotation field. Modes 0/1/3 with rotation 1 panic on a shift, modes 0-3 with rotation 2/3 drop a colour channel, and modes 6/7 skip red's p-bit and pack the endpoints out of order. In game this shows as a mosaic of wrong-coloured 4x4 blocks on textures (clothing, on an RTX 2070 SUPER, Series S). This is Marvisak/VIctory#3111 by RVZO6, applied unchanged. ## Change - `rotation(ctrl)` returns the rotation bits only for modes 4 and 5, and 0 otherwise; `bc7_precision` and `bc7_pack` use it. - No switch. ## Where it does nothing Modes 4 and 5 rotate exactly as before; the test checks their precisions and a packed mode 4/5 block with rotation 1. ## Measured RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB, Windows 11, main @ `014d52d` + #203 (DLSS) + pr0vId3nce's own-bytes pool, diag build, Series S + DLSS, `play.ps1` settings plus `VICTORY_CARD_BUFFERS_MIN_KB=64`, `CARD_BUFFERS_MB=1024`, `RESIDENCY=1`, `WIDE_MERGE=1`, `WINDOW_KB=1024`, `SUBMIT_FRAMES=2`, `CARD_ROOM_FOR_TARGETS_MB=1280`. One run each, in the world: | | before | after | |---|---|---| | clothing | mosaic of wrong-coloured blocks | normal | | median frame | 121 ms | 128 ms | It's a picture fix: no frame-time change is expected or claimed (the runs were in different spots). ## Checks - `cargo test -p victory-formats --lib --locked`: 42 passed, 5 ignored (new: `bc7_rotation_applies_only_to_modes_4_and_5`) - The new test on main without the fix: fails with "attempt to shift right with overflow" at `bc7_pack` - `cargo clippy -p victory-formats --all-targets --locked -- -D warnings`: clean - `cargo fmt -p victory-formats --check`: no change in `bcpack.rs` (one existing difference in `texture.rs`, untouched here) - `cargo xtask policy`: 1 file ok - In game: the same two-line fix (without the test) on the build above; the clothing mosaic is gone ## Not checked AMD; Series X; in game on plain main without the pool. ## Related Marvisak/VIctory#3111 (this fix) and #3386 (the same rotation guard plus a fix to the first BC7 dictionary entry, for that fork's faster decoder, which main doesn't have). fxceless/victory-fork `06702fe`, ExoCalibra/victory-exo `c1ce2fad` and pr0vId3nce/VIctory-NVIDIA `41791231` carry it. No open upstream PR touches `bcpack.rs` for this. This change was made with AI assistance (Claude Code).
UwUCammie commented 2026-11-27 01:27:41 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by UwUCammie on 2026-11-27T01:27:41Z.


I carried this to the AMD branch. The native formats suite passed all 42 active tests, including the generated BC7 rotation cases in every mode. I haven't checked the clothing artifact in game on this branch. AMD backport

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7207306075 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/412#issuecomment-7207306075). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-27T01:27:41Z. --- I carried this to the AMD branch. The native formats suite passed all 42 active tests, including the generated BC7 rotation cases in every mode. I haven't checked the clothing artifact in game on this branch. [AMD backport](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/44)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/412:upstream-pr/412'
git switch 'upstream-pr/412'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/412'
git switch 'upstream-pr/412'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/412'
git switch 'upstream-pr/412'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/412'
git switch 'main'
git merge --squash 'upstream-pr/412'
git switch 'main'
git merge --ff-only 'upstream-pr/412'
git switch 'main'
git merge 'upstream-pr/412'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!412
No description provided.