GPU: decode packed 16-bit UNORM diagnostic targets #2634

Open
andrewpozdnakov7-jpg wants to merge 2 commits from upstream-pr/2636 into main
andrewpozdnakov7-jpg commented 2026-11-25 17:20:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T17:20:26Z.


Problem

Diagnostic capture skips native B5G6R5_UNORM, B5G5R5A1_UNORM, and B4G4R4A4_UNORM readbacks because the PNG converter has no case for their format IDs.

Change

Decode and normalize each RGB channel by its own bit width before the existing diagnostic scaling. Alpha stays outside RGB scaling, including alpha-only pixels. The bit layouts match Microsoft's DirectXTex loader.

Verification

  • The same two pitched rows per format return [None, None, None] on main 13f91ca. With this change, all three return the expected opaque RGBA bytes. Full white catches the different green width in B5G6R5, and the fixtures cover channel order, half green, nonzero row padding, and alpha-only pixels.
  • All three focused diagnostic capture tests, strict victory-gpu Clippy, and the staged policy passed on Windows.

Coordination claim

AI-assisted (Codex 2). Please retain the Git author on cherry-pick or rebase. If folding this change into another commit, please retain Co-authored-by: andrewpozdnakov7-jpg [email protected].

<!-- greyfinch-sync:Marvisak/VIctory:issue:6609870845 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2636). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T17:20:26Z. --- ## Problem Diagnostic capture skips native B5G6R5_UNORM, B5G5R5A1_UNORM, and B4G4R4A4_UNORM readbacks because the PNG converter has no case for their format IDs. ## Change Decode and normalize each RGB channel by its own bit width before the existing diagnostic scaling. Alpha stays outside RGB scaling, including alpha-only pixels. The bit layouts match [Microsoft's DirectXTex loader](https://github.com/microsoft/DirectXTex/blob/main/DDSTextureLoader/DDSTextureLoader12.cpp#L713-L728). ## Verification - The same two pitched rows per format return [None, None, None] on main 13f91ca. With this change, all three return the expected opaque RGBA bytes. Full white catches the different green width in B5G6R5, and the fixtures cover channel order, half green, nonzero row padding, and alpha-only pixels. - All three focused diagnostic capture tests, strict victory-gpu Clippy, and the staged policy passed on Windows. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7169227340) AI-assisted (Codex 2). Please retain the Git author on cherry-pick or rebase. If folding this change into another commit, please retain Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.
Bj0rnis commented 2026-11-25 18:02:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bj0rnis on 2026-11-25T17:33:48Z.


Independent Windows 11 hardware + WARP verification of #2636 at 1ef6c9b1 (clean git merge-tree with origin/main 13f91cae, Rust 1.98.1 MSVC):

  • NVIDIA GeForce RTX 5070 Ti (real hardware): cargo test -p victory-gpu --features diagnostics --lib --locked -- --test-threads=1 -> 197 passed, 2 failed, 1 ignored (2.86s; includes the new test, only the 2 pre-existing #1744 NVIDIA 1M view-heap baseline failures also present on main 13f91cae).
  • WARP (VICTORY_D3D12_WARP=1): 199 passed, 0 failed, 1 ignored (1.73s).
  • Clippy: cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings -> 0 warnings.
  • Asset policy: cargo xtask policy -> 184 files ok.

Not tested: live game capture/target dump.

AI-assisted test run and summary.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169681774 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2636#issuecomment-7169681774). Originally posted by [Bj0rnis](https://github.com/Bj0rnis) on 2026-11-25T17:33:48Z. --- Independent Windows 11 hardware + WARP verification of #2636 at `1ef6c9b1` (clean `git merge-tree` with `origin/main` `13f91cae`, Rust 1.98.1 MSVC): - **NVIDIA GeForce RTX 5070 Ti (real hardware):** `cargo test -p victory-gpu --features diagnostics --lib --locked -- --test-threads=1` -> **197 passed, 2 failed, 1 ignored** (2.86s; includes the new test, only the 2 pre-existing #1744 NVIDIA 1M view-heap baseline failures also present on `main` `13f91cae`). - **WARP (`VICTORY_D3D12_WARP=1`):** **199 passed, 0 failed, 1 ignored** (1.73s). - **Clippy:** `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` -> **0 warnings**. - **Asset policy:** `cargo xtask policy` -> **184 files ok**. Not tested: live game capture/target dump. AI-assisted test run and summary.
kotekompotek commented 2026-11-25 18:02:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:47:55Z.


Reviewed: ids and bit layouts check out — 85 B5G6R5 (R 11:5, G 5:6, B 0:5), 86 B5G5R5A1 (5 bits each from bit 10, alpha dropped per the comment), 115 B4G4R4A4 (4 bits each). Test covers all three plus row padding. CI green.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170014507 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2636#issuecomment-7170014507). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:47:55Z. --- Reviewed: ids and bit layouts check out — 85 B5G6R5 (R 11:5, G 5:6, B 0:5), 86 B5G5R5A1 (5 bits each from bit 10, alpha dropped per the comment), 115 B4G4R4A4 (4 bits each). Test covers all three plus row padding. CI green.
Marvisak commented 2026-11-25 23:06:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:22:25Z.


Automated triage for the maintainers.

Recommended for a maintainer's look. Diagnostic captures (to_rgba in crates/victory-gpu/src/capture.rs) returned nothing for the packed 16-bit formats 85 (B5G6R5), 86 (B5G5R5A1) and 115 (B4G4R4A4); they now decode each channel by its own width. I checked the shifts against the DXGI bit layouts (R at 11/10/8, G at 5/5/4, B at 0), and the green width of B5G6R5 is handled separately. Diagnostics-only, 12 lines plus a test that covers row padding. Merges cleanly into current main, CI check passing on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176280728 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2636#issuecomment-7176280728). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:22:25Z. --- <!-- victory-triage v1 head=e91de8a62b2ff4623dbadfdd532e59b18e4dde1d verdict=merge-candidate at=2026-11-25T22:22:45Z --> Automated triage for the maintainers. Recommended for a maintainer's look. Diagnostic captures (`to_rgba` in `crates/victory-gpu/src/capture.rs`) returned nothing for the packed 16-bit formats 85 (B5G6R5), 86 (B5G5R5A1) and 115 (B4G4R4A4); they now decode each channel by its own width. I checked the shifts against the DXGI bit layouts (R at 11/10/8, G at 5/5/4, B at 0), and the green width of B5G6R5 is handled separately. Diagnostics-only, 12 lines plus a test that covers row padding. Merges cleanly into current `main`, CI `check` passing on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 05:08:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:08:12Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-gpu --features diagnostics --lib capture::: 12 passed, 0 failed (including new packed_unorm_captures_decode_each_rgb_width).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068839407 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2636#pullrequestreview-6068839407). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T05:08:12Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-gpu --features diagnostics --lib capture::`: **12 passed, 0 failed** (including new `packed_unorm_captures_decode_each_rgb_width`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 16:52:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T16:52:35Z.

Review: APPROVED


Verified e91de8a62b2ff4623dbadfdd532e59b18e4dde1d merged cleanly onto 63bcca43 on Windows 11 with both an RTX 5090 and WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1).

Code review

  • The DXGI LSB-first bit masks and shifts in to_rgba (crates/victory-gpu/src/capture.rs:659-670) match all three 16-bit packed UNORM layouts:
    • 85 (DXGI_FORMAT_B5G6R5_UNORM): R bits 11..15 (/ 31), G bits 5..10 (/ 63), B bits 0..4 (/ 31).
    • 86 (DXGI_FORMAT_B5G5R5A1_UNORM): R bits 10..14, G bits 5..9, B bits 0..4 (/ 31), alpha bit 15 ignored.
    • 115 (DXGI_FORMAT_B4G4R4A4_UNORM): R bits 8..11, G bits 4..7, B bits 0..3 (/ 15), alpha bits 12..15 ignored.
  • Normalizing each channel by its own mask keeps white/grey balanced across B5G6R5's wider green channel before the existing p99 scaling path, and also merges cleanly alongside #2607 with no textual conflict in capture.rs.

Verification

  • cargo xtask policy: 191 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
  • RTX 5090 & WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1): capture:: 12 passed, 0 failed on both adapters (including packed_unorm_captures_decode_each_rgb_width at capture.rs:965).
  • Co-merged with #2607 plus an extra pixel probe covering pure R/G/B primaries and all-alpha-only images (0x8000 for 86, 0xF000 for 115, verifying opaque black output with no scaling distortion or division by zero): 14 passed, 0 failed on both RTX 5090 and WARP.
<!-- greyfinch-sync:Marvisak/VIctory:review:6077867896 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2636#pullrequestreview-6077867896). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T16:52:35Z. **Review:** APPROVED --- Verified `e91de8a62b2ff4623dbadfdd532e59b18e4dde1d` merged cleanly onto `63bcca43` on Windows 11 with both an RTX 5090 and WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`). ### Code review - The DXGI LSB-first bit masks and shifts in `to_rgba` (`crates/victory-gpu/src/capture.rs:659-670`) match all three 16-bit packed UNORM layouts: - `85` (`DXGI_FORMAT_B5G6R5_UNORM`): `R` bits `11..15` (`/ 31`), `G` bits `5..10` (`/ 63`), `B` bits `0..4` (`/ 31`). - `86` (`DXGI_FORMAT_B5G5R5A1_UNORM`): `R` bits `10..14`, `G` bits `5..9`, `B` bits `0..4` (`/ 31`), alpha bit `15` ignored. - `115` (`DXGI_FORMAT_B4G4R4A4_UNORM`): `R` bits `8..11`, `G` bits `4..7`, `B` bits `0..3` (`/ 15`), alpha bits `12..15` ignored. - Normalizing each channel by its own mask keeps white/grey balanced across `B5G6R5`'s wider green channel before the existing p99 scaling path, and also merges cleanly alongside `#2607` with no textual conflict in `capture.rs`. ### Verification - `cargo xtask policy`: `191 files ok`. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - RTX 5090 & WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`): `capture::` **12 passed, 0 failed** on both adapters (including `packed_unorm_captures_decode_each_rgb_width` at `capture.rs:965`). - Co-merged with `#2607` plus an extra pixel probe covering pure R/G/B primaries and all-alpha-only images (`0x8000` for `86`, `0xF000` for `115`, verifying opaque black output with no scaling distortion or division by zero): **14 passed, 0 failed** on both RTX 5090 and WARP.
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/2636:upstream-pr/2636'
git switch 'upstream-pr/2636'

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/2636'
git switch 'upstream-pr/2636'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2636'
git switch 'upstream-pr/2636'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2636'
git switch 'main'
git merge --squash 'upstream-pr/2636'
git switch 'main'
git merge --ff-only 'upstream-pr/2636'
git switch 'main'
git merge 'upstream-pr/2636'
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
Marvisak/VIctory!2634
No description provided.