GPU capture: decode XR-biased RGB before image scaling #2514

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/2516 into main
andrewpozdnakov7-jpg commented 2026-11-25 15:10:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T15:10:41Z.


Capture diagnostics already unpack R10G10B10_XR_BIAS_A2_UNORM as 10:10:10:2 after #372. They still use the raw RGB codes when scaling the image, so the code for black is interpreted as a positive color.

Decode RGB with the XR conversion (channel - 384) / 510 before the existing capture scaling. The other 10:10:10:2 formats keep their original interpretation.

The same synthetic format-89 pixel with all three channels at code 384 produced white on 940d32f and black with the fix. The [894, 639, 384] control produces [255, 127, 0] in the diagnostic image. All three capture tests, strict GPU diagnostics Clippy, and staged asset policy passed on Windows.

Microsoft XR conversion rules · Coordination claim

Please retain the Git author when cherry-picking or rebasing. If you fold the change into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5493992740 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2516). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T15:10:41Z. --- Capture diagnostics already unpack `R10G10B10_XR_BIAS_A2_UNORM` as 10:10:10:2 after #372. They still use the raw RGB codes when scaling the image, so the code for black is interpreted as a positive color. Decode RGB with the XR conversion `(channel - 384) / 510` before the existing capture scaling. The other 10:10:10:2 formats keep their original interpretation. The same synthetic format-89 pixel with all three channels at code `384` produced white on `940d32f` and black with the fix. The `[894, 639, 384]` control produces `[255, 127, 0]` in the diagnostic image. All three capture tests, strict GPU diagnostics Clippy, and staged asset policy passed on Windows. [Microsoft XR conversion rules](https://learn.microsoft.com/en-us/windows-hardware/drivers/display/xr-bias-color-channel-conversion-rules) · [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7166345407) Please retain the Git author when cherry-picking or rebasing. If you fold the change into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex.
Marvisak commented 2026-11-25 16:09:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:56:30Z.


Automated triage for the maintainers. Merge candidate: in crates/victory-gpu/src/capture.rs, to_rgba now decodes R10G10B10_XR_BIAS_A2 (format 89) channels as (code - 384) / 510 before scaling, and leaves the other 10:10:10:2 formats alone. On main, colour formats scale from low = 0, so the raw code 384 that means black showed up as a bright colour. The conversion matches the public XR-bias rules linked in the PR, and the change only touches diagnostic captures. CI (check) passes.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167449335 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2516#issuecomment-7167449335). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:56:30Z. --- <!-- victory-triage v1 head=c9f7f75ac70fd774c78426e95cd399b743e8590e verdict=merge-candidate at=2026-11-25T15:56:23Z --> Automated triage for the maintainers. Merge candidate: in `crates/victory-gpu/src/capture.rs`, `to_rgba` now decodes `R10G10B10_XR_BIAS_A2` (format 89) channels as `(code - 384) / 510` before scaling, and leaves the other 10:10:10:2 formats alone. On main, colour formats scale from `low = 0`, so the raw code 384 that means black showed up as a bright colour. The conversion matches the public XR-bias rules linked in the PR, and the change only touches diagnostic captures. CI (`check`) passes. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 01:04:17 +00:00 (Migrated from github.com)

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


Code review and RTX 5090 + WARP verification at head c9f7f75ac70f merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-gpu/src/capture.rs:659-668, 699-725):
    • Decoding format 89 (DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM) via (channel - 384.0) / 510.0 before scaling matches the DXGI spec (384 -> 0.0, 894 -> 1.0, [-0.752941, +1.252941]) while leaving 23..=25 untouched.
    • Downstream scaling (low = 0.0, high = p99 of non-zero abs, .clamp(0.0, 1.0)) cleanly clamps negative extended values < 384 to 0 and avoids division by zero on all-negative images; verified the updated green-channel expectation (50) matches ((511-384)/510) / ((1023-384)/510) * 255.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): 0 warnings
    • victory-gpu --lib --features diagnostics capture: 12/12 passed on both RTX 5090 and WARP (including xr_bias_targets_decode_black_and_extended_range_channels).

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179204876 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2516#issuecomment-7179204876). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:52:44Z. --- Code review and RTX 5090 + WARP verification at head `c9f7f75ac70f` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-gpu/src/capture.rs:659-668, 699-725`)**: - Decoding format `89` (`DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM`) via `(channel - 384.0) / 510.0` before scaling matches the DXGI spec (`384 -> 0.0`, `894 -> 1.0`, `[-0.752941, +1.252941]`) while leaving `23..=25` untouched. - Downstream scaling (`low = 0.0`, `high = p99` of non-zero `abs`, `.clamp(0.0, 1.0)`) cleanly clamps negative extended values `< 384` to `0` and avoids division by zero on all-negative images; verified the updated green-channel expectation (`50`) matches `((511-384)/510) / ((1023-384)/510) * 255`. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): 0 warnings - `victory-gpu --lib --features diagnostics capture`: **12/12 passed** on both RTX 5090 and WARP (including `xr_bias_targets_decode_black_and_extended_range_channels`). LGTM.
cloph-dsp commented 2026-11-27 00:58:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T00:58:35Z.


Independent local verification of PR #2516 (GPU: decode XR-biased RGB before scaling diagnostic captures).

Windows, rustc/cargo 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR=D:\Victory-Contrib\target-2516-watch, CARGO_BUILD_JOBS=2, cargo test --locked, synthetic pixel only, no game data.

  • Command: cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::xr_bias_targets_decode_black_and_extended_range_channels --exact --test-threads=1 --quiet -> test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 148 filtered out, exit 0. --features diagnostics is required because mod capture is gated by #[cfg(all(windows, feature = "diagnostics"))] in crates/victory-gpu/src/lib.rs:21-22.
  • git diff --check 940d32f HEAD (merge base) clean; diff is 1 file (+22/-2), crates/victory-gpu/src/capture.rs.
  • Negative control: xr_bias_targets_decode_black_and_extended_range_channels is absent from merge base 940d32f via git grep.
  • Note: diffing against current tip origin/main (63bcca4) flags an unrelated blank line at EOF in crates/victory-formats/src/xma/tables.rs; this is not from this PR.
  • GPU/driver: N/A for this CPU-only synthetic pixel test. AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7206906843 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2516#issuecomment-7206906843). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T00:58:35Z. --- Independent local verification of PR #2516 (GPU: decode XR-biased RGB before scaling diagnostic captures). Windows, rustc/cargo 1.100.0/MSVC, worktree-local `CARGO_TARGET_DIR=D:\Victory-Contrib\target-2516-watch`, `CARGO_BUILD_JOBS=2`, `cargo test --locked`, synthetic pixel only, no game data. - Command: `cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::xr_bias_targets_decode_black_and_extended_range_channels --exact --test-threads=1 --quiet` -> `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 148 filtered out`, exit 0. `--features diagnostics` is required because `mod capture` is gated by `#[cfg(all(windows, feature = "diagnostics"))]` in `crates/victory-gpu/src/lib.rs:21-22`. - `git diff --check 940d32f HEAD` (merge base) clean; diff is 1 file (+22/-2), `crates/victory-gpu/src/capture.rs`. - Negative control: `xr_bias_targets_decode_black_and_extended_range_channels` is absent from merge base 940d32f via `git grep`. - Note: diffing against current tip `origin/main` (63bcca4) flags an unrelated blank line at EOF in `crates/victory-formats/src/xma/tables.rs`; this is not from this PR. - GPU/driver: N/A for this CPU-only synthetic pixel test. AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
andrewpozdnakov7-jpg commented 2026-11-28 01:39:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:39:13Z.


I checked this exact head c9f7f75ac70fd774c78426e95cd399b743e8590e with #3639 at e0b5e8f7fbbea890f9a41ec95242305444e6c6e1 on 63bcca43. Git merged the two changes cleanly into tree 6416920c75ab2ed8c8636a98b95df57d133700a4.

I compiled the capture conversion and its tests directly from that tree using the cached tracing and Windows crates. All 14 tests passed, covering XR black, nominal white and midtone, as well as the four signed R8/R16 capture formats. This verifies the CPU conversion with generated rows. The current PR already contains the XR fix and regression.

Please preserve the Git author on cherry-pick or rebase, or include this trailer if folding the change into another commit.

Co-authored-by: andrewpozdnakov7-jpg <[email protected]>

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231821880 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2516#issuecomment-7231821880). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:39:13Z. --- I checked this exact head `c9f7f75ac70fd774c78426e95cd399b743e8590e` with #3639 at `e0b5e8f7fbbea890f9a41ec95242305444e6c6e1` on `63bcca43`. Git merged the two changes cleanly into tree `6416920c75ab2ed8c8636a98b95df57d133700a4`. I compiled the capture conversion and its tests directly from that tree using the cached `tracing` and Windows crates. All 14 tests passed, covering XR black, nominal white and midtone, as well as the four signed R8/R16 capture formats. This verifies the CPU conversion with generated rows. The current PR already contains the XR fix and regression. Please preserve the Git author on cherry-pick or rebase, or include this trailer if folding the change into another commit. `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`
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/2516:upstream-pr/2516'
git switch 'upstream-pr/2516'

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