GPU: preserve integer contrast in R32 captures #1893

Merged
DoubleD17 merged 1 commit from upstream-pr/1895 into main 2026-11-25 21:52:18 +00:00
DoubleD17 commented 2026-11-25 00:17:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-25T00:17:06Z.


The diagnostic capture path decodes R32_UINT and R32_SINT words as floating-point bit patterns, which can turn distinct integer texels into an all-black preview. Decode the words as integers and scale the exact range to RGBA8. Keep the capture statistics and leave other formats on the existing conversion path.

On Windows x64 with Rust 1.98.1 and MSVC, three new synthetic cases failed on e82a6ad. All five capture tests passed on ba1a666 with cargo test --offline --locked --jobs 2 -p victory-gpu --features diagnostics --lib capture::tests::. The cases cover signed and unsigned scaling, large adjacent values, and a padded row with signed extrema. Validation was limited to the CPU capture conversion.

Adapted from fxceless/victory-fork #347.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6594159943 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1895). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-25T00:17:06Z. --- The diagnostic capture path decodes R32_UINT and R32_SINT words as floating-point bit patterns, which can turn distinct integer texels into an all-black preview. Decode the words as integers and scale the exact range to RGBA8. Keep the capture statistics and leave other formats on the existing conversion path. On Windows x64 with Rust 1.98.1 and MSVC, three new synthetic cases failed on e82a6ad. All five capture tests passed on ba1a666 with `cargo test --offline --locked --jobs 2 -p victory-gpu --features diagnostics --lib capture::tests::`. The cases cover signed and unsigned scaling, large adjacent values, and a padded row with signed extrema. Validation was limited to the CPU capture conversion. Adapted from [fxceless/victory-fork #347](https://github.com/fxceless/victory-fork/pull/347). AI-assisted.
catminou4 commented 2026-11-25 01:07:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T00:32:48Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Integer contrast preserved in R32 captures: capture-path format fix for integer formats.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049697596 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1895#pullrequestreview-6049697596). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T00:32:48Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Integer contrast preserved in R32 captures: capture-path format fix for integer formats.
Marvisak commented 2026-11-25 03:03:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:17:41Z.


Automated triage for the maintainers.

Merge candidate (unchanged). The new head keeps the earlier fix: to_rgba in crates/victory-gpu/src/capture.rs sends formats 42/43 (R32_UINT/R32_SINT) to r32_integer_to_rgba, which reads the words as integers and scales the exact low..high span in i64 instead of decoding them as f32 bits. That decoding turned small integers into denormals and gave an all-black capture. R32 float, depth and typeless formats stay on the old path, and the "target values" log line is kept.

What changed since the last verdict: the head now includes the follow-up proposed in the comments, with co-author credit. A constant nonzero integer target is drawn white, and an all-zero target stays black, so a filled target no longer looks empty. Three new tests cover constant +7 unsigned, constant -7 signed and constant zero. I checked the expected bytes of all six tests against the arithmetic, including the 2x2 padded-pitch case. This is the same rule #2486 (still open) proposes for the float single-channel paths. It is a diagnostics-only change with no dependency changes.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150544093 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1895#issuecomment-7150544093). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:17:41Z. --- <!-- victory-triage v1 head=9ce9d6fbea8e36979f6e92d47991a42599461fc4 verdict=merge-candidate at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. **Merge candidate (unchanged).** The new head keeps the earlier fix: `to_rgba` in `crates/victory-gpu/src/capture.rs` sends formats 42/43 (R32_UINT/R32_SINT) to `r32_integer_to_rgba`, which reads the words as integers and scales the exact low..high span in `i64` instead of decoding them as `f32` bits. That decoding turned small integers into denormals and gave an all-black capture. R32 float, depth and typeless formats stay on the old path, and the "target values" log line is kept. **What changed since the last verdict:** the head now includes the follow-up proposed in the comments, with co-author credit. A constant nonzero integer target is drawn white, and an all-zero target stays black, so a filled target no longer looks empty. Three new tests cover constant +7 unsigned, constant -7 signed and constant zero. I checked the expected bytes of all six tests against the arithmetic, including the 2x2 padded-pitch case. This is the same rule #2486 (still open) proposes for the float single-channel paths. It is a diagnostics-only change with no dependency changes. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-25 16:09:10 +00:00 (Migrated from github.com)

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


I checked the exact head 7f69c0f with constant R32_UINT and R32_SINT readbacks. Both produced black pixels for a nonzero constant. That makes a filled target look empty in the capture, which is the same grayscale case addressed for the other single-channel paths in #2486.

The tested follow-up applies the same rule to this PR's integer converter. The same synthetic inputs (+7 unsigned, -7 signed) now produce white, and zero produces black. Six capture tests passed on Windows, including the existing adjacent-integer and full-range/pitch tests. Strict GPU Clippy with diagnostics and staged asset policy passed.

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

AI-assisted with Codex. Synthetic readback data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166765341 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1895#issuecomment-7166765341). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T15:23:22Z. --- I checked the exact head `7f69c0f` with constant `R32_UINT` and `R32_SINT` readbacks. Both produced black pixels for a nonzero constant. That makes a filled target look empty in the capture, which is the same grayscale case addressed for the other single-channel paths in #2486. [The tested follow-up](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4eefc9172bbb91186ff16fb2e89e82f030802d77) applies the same rule to this PR's integer converter. The same synthetic inputs (`+7` unsigned, `-7` signed) now produce white, and zero produces black. Six capture tests passed on Windows, including the existing adjacent-integer and full-range/pitch tests. Strict GPU Clippy with diagnostics and staged asset policy passed. If you use the follow-up, please retain its Git author when cherry-picking or rebasing. If you fold it into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic readback data.
upstream-sync closed this pull request 2026-11-25 22:03:15 +00:00
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!1893
No description provided.