GPU: keep constant nonzero targets visible in captures #2484

Open
andrewpozdnakov7-jpg wants to merge 2 commits from upstream-pr/2486 into main
andrewpozdnakov7-jpg commented 2026-11-25 14:42:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T14:42:21Z.


A flat single-channel target has no contrast to stretch. The capture code subtracts its minimum from every pixel, so a depth buffer cleared to a nonzero value appears black and the dump filename receives the -black suffix. This can make a nonzero target look empty during rendering diagnostics.

Show a constant nonzero value as white in the grayscale dump. A zero target stays black and a varying target keeps its existing grayscale range.

The same synthetic readback test produced [0, 0, 0, 255] for the constant D32_FLOAT input 0.25 on 940d32f, then [255, 255, 255, 255] with the fix. The negative R32_FLOAT, zero-depth and varying-depth controls passed. All three capture tests, strict GPU Clippy with diagnostics, and the staged asset policy passed on Windows. This is a CPU-side capture conversion test with synthetic pixels.

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:5493521232 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2486). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T14:42:21Z. --- A flat single-channel target has no contrast to stretch. The capture code subtracts its minimum from every pixel, so a depth buffer cleared to a nonzero value appears black and the dump filename receives the `-black` suffix. This can make a nonzero target look empty during rendering diagnostics. Show a constant nonzero value as white in the grayscale dump. A zero target stays black and a varying target keeps its existing grayscale range. The same synthetic readback test produced `[0, 0, 0, 255]` for the constant D32_FLOAT input `0.25` on `940d32f`, then `[255, 255, 255, 255]` with the fix. The negative R32_FLOAT, zero-depth and varying-depth controls passed. All three capture tests, strict GPU Clippy with diagnostics, and the staged asset policy passed on Windows. This is a CPU-side capture conversion test with synthetic pixels. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7165587044) 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.
catminou4 commented 2026-11-25 14:57:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:57:45Z.

Review: COMMENTED


Keep constant nonzero targets visible in captures. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059998840 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2486#pullrequestreview-6059998840). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:57:45Z. **Review:** COMMENTED --- Keep constant nonzero targets visible in captures. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
oni-swr commented 2026-11-25 15:13:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T15:13:29Z.

Review: COMMENTED


Windows verification to go with the earlier macOS static review. VICTORY_D3D12_WARP=1 (WARP only, no hardware GPU touched). Tested commit 7ab6e539921f8147f91070dba8f2963edba5dac0 (clean detached checkout).

Note: the capture module is #[cfg(all(windows, feature = "diagnostics"))]. Without the feature, cargo test -p victory-gpu --lib capture compiles and runs 0 tests, so the new test only runs with --features diagnostics.

  • cargo test -p victory-gpu --locked --lib --features diagnostics capture — 3 passed, 0 failed, 0 ignored (includes constant_nonzero_grayscale_targets_do_not_look_black).
  • Mutation check: with flat_nonzero forced to false, the new test fails, so it guards the change.
  • cargo test -p victory-gpu --locked --lib — 143 passed, 0 failed, 2 ignored.
  • cargo test -p victory-gpu --locked --lib --features diagnostics — 147 passed, 0 failed, 2 ignored.

Code read: flat_nonzero = grey && low == high && low != 0.0 applies only to the grey formats (19..=22 | 39..=47 | 53..=65). Non-finite pixels still go through the old path. An all-non-finite target never satisfies low == high, because low stays f32::MAX and high stays f32::MIN. Constant-zero and varying targets are unchanged, and the test asserts both. A negative constant also renders white, which the test covers. One minor point: rustfmt --check reports diffs in capture.rs, but they are in lines this PR does not touch (e.g. listed()), so they are not caused by it. No problems found.

AI-assisted (Claude Code / Claude Sonnet 5.5)

<!-- greyfinch-sync:Marvisak/VIctory:review:6060258398 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2486#pullrequestreview-6060258398). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T15:13:29Z. **Review:** COMMENTED --- Windows verification to go with the earlier macOS static review. `VICTORY_D3D12_WARP=1` (WARP only, no hardware GPU touched). Tested commit `7ab6e539921f8147f91070dba8f2963edba5dac0` (clean detached checkout). Note: the `capture` module is `#[cfg(all(windows, feature = "diagnostics"))]`. Without the feature, `cargo test -p victory-gpu --lib capture` compiles and runs 0 tests, so the new test only runs with `--features diagnostics`. - `cargo test -p victory-gpu --locked --lib --features diagnostics capture` — 3 passed, 0 failed, 0 ignored (includes `constant_nonzero_grayscale_targets_do_not_look_black`). - Mutation check: with `flat_nonzero` forced to `false`, the new test fails, so it guards the change. - `cargo test -p victory-gpu --locked --lib` — 143 passed, 0 failed, 2 ignored. - `cargo test -p victory-gpu --locked --lib --features diagnostics` — 147 passed, 0 failed, 2 ignored. Code read: `flat_nonzero = grey && low == high && low != 0.0` applies only to the grey formats (`19..=22 | 39..=47 | 53..=65`). Non-finite pixels still go through the old path. An all-non-finite target never satisfies `low == high`, because `low` stays `f32::MAX` and `high` stays `f32::MIN`. Constant-zero and varying targets are unchanged, and the test asserts both. A negative constant also renders white, which the test covers. One minor point: `rustfmt --check` reports diffs in `capture.rs`, but they are in lines this PR does not touch (e.g. `listed()`), so they are not caused by it. No problems found. AI-assisted (Claude Code / Claude Sonnet 5.5)
cloph-dsp commented 2026-11-25 16:09:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T15:45:19Z.


Independent local validation for PR #2486 (Windows, Rust 1.100.0/MSVC, head 7ab6e53, no game data): cargo test --locked -p victory-gpu --lib -> 143 tests passed, 0 failed, 2 ignored, exit 0. CPU-only regression run; synthetic capture path not replayed. AI-assisted (Hy4 flash). GPU/driver noted only for provenance (RTX 5060 Laptop, driver 621.24).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167293903 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2486#issuecomment-7167293903). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T15:45:19Z. --- Independent local validation for PR #2486 (Windows, Rust 1.100.0/MSVC, head 7ab6e53, no game data): `cargo test --locked -p victory-gpu --lib` -> 143 tests passed, 0 failed, 2 ignored, exit 0. CPU-only regression run; synthetic capture path not replayed. AI-assisted (Hy4 flash). GPU/driver noted only for provenance (RTX 5060 Laptop, driver 621.24).
Marvisak commented 2026-11-25 16:09:31 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Verdict: merge candidate (unchanged). The new head is a merge of main. The PR diff is the same as before, still only crates/victory-gpu/src/capture.rs. In to_rgba, a grey target whose pixels all hold one finite nonzero value is shown white instead of stretching to black (and getting the -black suffix). Zero targets, varying targets and non-finite pixels are unchanged. The new unit test covers all four cases. It only affects diagnostic dumps.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167452703 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2486#issuecomment-7167452703). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:56:44Z. --- <!-- victory-triage v1 head=7996a01103b49ae5eb990052f9f663f33f0d74ea verdict=merge-candidate at=2026-11-26T03:25:48Z --> Automated triage for the maintainers. **Verdict: merge candidate (unchanged).** The new head is a merge of `main`. The PR diff is the same as before, still only `crates/victory-gpu/src/capture.rs`. In `to_rgba`, a grey target whose pixels all hold one finite nonzero value is shown white instead of stretching to black (and getting the `-black` suffix). Zero targets, varying targets and non-finite pixels are unchanged. The new unit test covers all four cases. It only affects diagnostic dumps. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 20:10:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:10:38Z.

Review: APPROVED


Verified locally merged onto origin/main (63bcca43) at PR head 7996a011 (Windows 11 x64, NVIDIA RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1):

  • crates/victory-gpu/src/capture.rs (to_rgba): adds flat_nonzero = grey && low == high && low != 0.0 and maps finite pixels to 255 instead of collapsing constant nonzero single-channel targets to black (matching the existing r32_integer_to_rgba convention). Keeping c.is_finite() preserves existing non-finite handling when mixed with a constant finite value, and all-non-finite/empty targets stay unaffected (low = f32::MAX, high = f32::MIN).
  • cargo xtask policy: 191 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features): 0 warnings.
  • cargo test --locked -p victory-gpu --features diagnostics --lib capture::: 12/12 passed (including constant_nonzero_grayscale_targets_do_not_look_black).
  • Extra synthetic edge probe (not committed): verified [-0.0, -0.0] -> black, all-NaN -> black, all--Inf -> black, all-+Inf -> white, mixed [0.25, NaN, +Inf, -Inf] -> [white, black, white, black], constant subnormal f32::MIN_POSITIVE / 2.0 -> white, and empty 0x0 -> Some([]).
  • Verified clean co-merge with #2518 (both edit capture.rs): clippy (default and --all-features) clean, and all combined capture/GPU tests pass on both RTX 5090 and WARP (including constant negative signed R8 rendering white while zero stays black).

Synthetic tests only; looks ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079992092 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2486#pullrequestreview-6079992092). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T20:10:38Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`63bcca43`) at PR head `7996a011` (Windows 11 x64, NVIDIA RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`): - `crates/victory-gpu/src/capture.rs` (`to_rgba`): adds `flat_nonzero = grey && low == high && low != 0.0` and maps finite pixels to `255` instead of collapsing constant nonzero single-channel targets to black (matching the existing `r32_integer_to_rgba` convention). Keeping `c.is_finite()` preserves existing non-finite handling when mixed with a constant finite value, and all-non-finite/empty targets stay unaffected (`low = f32::MAX`, `high = f32::MIN`). - `cargo xtask policy`: 191 files ok. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): 0 warnings. - `cargo test --locked -p victory-gpu --features diagnostics --lib capture::`: 12/12 passed (including `constant_nonzero_grayscale_targets_do_not_look_black`). - Extra synthetic edge probe (not committed): verified `[-0.0, -0.0]` -> black, all-`NaN` -> black, all-`-Inf` -> black, all-`+Inf` -> white, mixed `[0.25, NaN, +Inf, -Inf]` -> `[white, black, white, black]`, constant subnormal `f32::MIN_POSITIVE / 2.0` -> white, and empty `0x0` -> `Some([])`. - Verified clean co-merge with `#2518` (both edit `capture.rs`): clippy (default and `--all-features`) clean, and all combined capture/GPU tests pass on both RTX 5090 and WARP (including constant negative signed R8 rendering white while zero stays black). Synthetic tests only; looks ready to merge.
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/2486:upstream-pr/2486'
git switch 'upstream-pr/2486'

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