Decode signed and integer render targets correctly in diagnostic captures #2699

Open
VlREX wants to merge 4 commits from upstream-pr/2701 into main
VlREX commented 2026-11-25 18:28:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-25T18:28:10Z.


Fix signed RGBA/RG/R channel decoding, R32_UINT and R32_SINT scalar decoding, and grayscale normalization for tiny or very wide finite float ranges. These affect diagnostic PNGs used to investigate rendering. Three new regression tests failed before the patch and pass afterward in an isolated Windows GNU run of the conversion code, alongside the existing format test. No game data or GPU required.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6611034987 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2701). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-25T18:28:10Z. --- Fix signed RGBA/RG/R channel decoding, R32_UINT and R32_SINT scalar decoding, and grayscale normalization for tiny or very wide finite float ranges. These affect diagnostic PNGs used to investigate rendering. Three new regression tests failed before the patch and pass afterward in an isolated Windows GNU run of the conversion code, alongside the existing format test. No game data or GPU required.
DrDarkDK commented 2026-11-25 19:06:22 +00:00 (Migrated from github.com)

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


R32_UINT values [16_777_216, 16_777_217] produce two black pixels in to_rgba. Both values become 16_777_216 at the as f32 cast, so the later f64 normalization sees a zero-width range. R32_SINT has the same precision loss.

Could we keep the 32-bit integer channels exact through min/max and normalization, for example by decoding them to f64? A two-pixel R32_UINT regression with those adjacent values should produce black then white.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171000709 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2701#issuecomment-7171000709). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:30:25Z. --- `R32_UINT` values `[16_777_216, 16_777_217]` produce two black pixels in `to_rgba`. Both values become `16_777_216` at the `as f32` cast, so the later `f64` normalization sees a zero-width range. `R32_SINT` has the same precision loss. Could we keep the 32-bit integer channels exact through min/max and normalization, for example by decoding them to `f64`? A two-pixel `R32_UINT` regression with those adjacent values should produce black then white. *AI-assisted with Codex.*
fuzeofficlal commented 2026-11-25 19:06:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:48:24Z.


Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of a86d36ef (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • RTX 5090: cargo test --locked -p victory-gpu --features diagnostics --lib capture: 7 passed, 0 failed (all 5 new tests pass, including adjacent_large_32_bit_integers_keep_distinct_gray_levels).
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 203 passed, 0 failed, 1 ignored.
  • Merge compatibility with #2702: clean zero-conflict 3-way git merge-tree with #2702 (b48e6c74); the two PRs touch disjoint regions of capture.rs and complement each other cleanly.

Code Review Notes

  • Signed integer/SNORM decoding (i8/i16/i32), R10G10B10_XR_BIAS_A2_UNORM, f64 range scaling (preserving adjacent 32-bit integer precision without f32 overflow), two-pass streaming without double full-frame buffers, and half/small_float NaN decoding all look solid.
  • Non-blocking future follow-ups: R32G32B32A32_UINT/_SINT (3, 4) and R32G32_UINT/_SINT (17, 18) remain outside to_rgba, and on multi-channel signed formats large negative values still push p99 via value.abs() while negative outputs clamp at low = 0.0 (consistent with existing HDR float behaviour).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7171425849 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2701#issuecomment-7171425849). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T18:48:24Z. --- Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of `a86d36ef` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics`: **0 warnings**. - **RTX 5090:** `cargo test --locked -p victory-gpu --features diagnostics --lib capture`: **7 passed, 0 failed** (all 5 new tests pass, including `adjacent_large_32_bit_integers_keep_distinct_gray_levels`). - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1`: **203 passed, 0 failed, 1 ignored**. - **Merge compatibility with #2702:** clean zero-conflict 3-way `git merge-tree` with #2702 (`b48e6c74`); the two PRs touch disjoint regions of `capture.rs` and complement each other cleanly. ### Code Review Notes - Signed integer/SNORM decoding (`i8`/`i16`/`i32`), `R10G10B10_XR_BIAS_A2_UNORM`, `f64` range scaling (preserving adjacent 32-bit integer precision without `f32` overflow), two-pass streaming without double full-frame buffers, and `half`/`small_float` NaN decoding all look solid. - Non-blocking future follow-ups: `R32G32B32A32_UINT/_SINT` (`3, 4`) and `R32G32_UINT/_SINT` (`17, 18`) remain outside `to_rgba`, and on multi-channel signed formats large negative values still push `p99` via `value.abs()` while negative outputs clamp at `low = 0.0` (consistent with existing HDR float behaviour).
kotekompotek commented 2026-11-25 19:06:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:54:03Z.


Correct direction throughout: integer formats now decode as exact f64 integers (u32/s32 values were silently rounded or sign-mangled through the old f32/word paths), signed formats get their sign, and float_at/half_at keep normalized decoding. Single-channel-as-grey stays consistent.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171555471 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2701#issuecomment-7171555471). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:54:03Z. --- Correct direction throughout: integer formats now decode as exact f64 integers (u32/s32 values were silently rounded or sign-mangled through the old f32/word paths), signed formats get their sign, and float_at/half_at keep normalized decoding. Single-channel-as-grey stays consistent.
Marvisak commented 2026-11-25 23:06:02 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This branch no longer merges cleanly into main: the conflict is in crates/victory-gpu/src/capture.rs. No content review was done yet; it will be reviewed once it is rebased onto current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176136307 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2701#issuecomment-7176136307). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:15:34Z. --- <!-- victory-triage v1 head=a86d36ef60926911eb601817da80afb15820d8f7 verdict=needs-rebase at=2026-11-25T22:16:00Z --> Automated triage for the maintainers. **Needs rebase.** This branch no longer merges cleanly into `main`: the conflict is in `crates/victory-gpu/src/capture.rs`. No content review was done yet; it will be reviewed once it is rebased onto current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2701:upstream-pr/2701'
git switch 'upstream-pr/2701'

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