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

Open
github-bot wants to merge 1 commit from github-bot/gh-412 into main AGit
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-27 01:14 UTC · original
Jesper-Andersson:bc7-rotation → main · +107 −2 · 1 files · 1 commits · open

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).

**@⁠Jesper-Andersson** on GitHub · 2026-11-27 01:14 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/412) `Jesper-Andersson:bc7-rotation` → `main` · +107 −2 · 1 files · 1 commits · open 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).
Only BC7 modes 4 and 5 have a 2-bit rotation field. bc7_precision and
bc7_pack read ctrl bits 4:3 as a rotation for every mode: modes 0/1/3
with rot 1 panicked on a shift (red's precision 0), modes 0-3 with rot
2/3 dropped a colour channel, and modes 6/7 skipped red's p-bit and
packed the endpoints out of order. rotation(ctrl) gives 0 outside modes
4 and 5; both sites use it.

The fix and its test are Marvisak/VIctory PR #3111 by RVZO6, applied
unchanged. The test panics ("attempt to shift right with overflow") on
main without the fix and passes with it.

This change was made with AI assistance (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:32:58 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 01:27 UTC · original

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

**@⁠UwUCammie** on GitHub · 2026-11-27 01:27 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/412#issuecomment-7207306075) 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 can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/412/head:github-bot/gh-412'
git switch 'github-bot/gh-412'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-412'
git switch 'github-bot/gh-412'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-412'
git switch 'github-bot/gh-412'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-412'
git switch 'main'
git merge --squash 'github-bot/gh-412'
git switch 'main'
git merge --ff-only 'github-bot/gh-412'
git switch 'main'
git merge 'github-bot/gh-412'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.