GPU: preserve wide float contrast in diagnostic captures #2655

Open
github-bot wants to merge 2 commits from github-bot/gh-2655 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 17:38 UTC · original
andrewpozdnakov7-jpg:codex2/capture-wide-float-range → main · +24 −2 · 1 files · 2 commits · open

Problem

A diagnostic R32_FLOAT target can contain finite values at both ends of the float range. The grayscale span then overflows to infinity. Values with a finite numerator scale to zero, and the brightest values compute infinity divided by infinity and also become black.

Change

Halve the extrema and samples only when the span overflows. This keeps the ratios and reported statistics while bringing the span back into the f32 range.

Verification

  • The same synthetic two-row R32_FLOAT readback with padding produces grayscale [0, 0, 0, 0] on main 13f91ca and [0, 127, 191, 255] after the patch. The ordinary-range control produces [0, 127, 191, 255] in both versions.
  • All three 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].

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 17:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655) `andrewpozdnakov7-jpg:codex2/capture-wide-float-range` → `main` · +24 −2 · 1 files · 2 commits · open ## Problem A diagnostic R32_FLOAT target can contain finite values at both ends of the float range. The grayscale span then overflows to infinity. Values with a finite numerator scale to zero, and the brightest values compute infinity divided by infinity and also become black. ## Change Halve the extrema and samples only when the span overflows. This keeps the ratios and reported statistics while bringing the span back into the f32 range. ## Verification - The same synthetic two-row R32_FLOAT readback with padding produces grayscale [0, 0, 0, 0] on main 13f91ca and [0, 127, 191, 255] after the patch. The ordinary-range control produces [0, 127, 191, 255] in both versions. - All three diagnostic capture tests, strict victory-gpu Clippy, and the staged policy passed on Windows. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) 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]>.
Scale the endpoints and samples before subtraction when two finite grayscale extrema would overflow the f32 range. The same pitched R32_FLOAT fixture changes from all black to the expected four levels.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:19 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:54 UTC · original

Reviewed: halving endpoints and samples when high - low overflows to INF is a neat way to keep contrast without restructuring the normalizer, and logging the unscaled low keeps the report honest. Test covers the f32::MAX edge. CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655#issuecomment-7170161626) Reviewed: halving endpoints and samples when `high - low` overflows to INF is a neat way to keep contrast without restructuring the normalizer, and logging the *unscaled* low keeps the report honest. Test covers the f32::MAX edge. CI green.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:13 UTC · original

Independent verification of head ee109c3e8482aaa30d72049b8abac56bc77fd329 on origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca (merges cleanly, fast-forward).

Environment: Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set for every run; victory-gpu tests were only run with --features diagnostics (without it the crate opens the default adapter). Limits: no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware.

  • Focused: ... -p victory-gpu --features diagnostics grayscale_capture -> capture::grayscale_capture_preserves_contrast_across_a_wide_float_range 1 passed.
  • Full crate: 199 passed, 0 failed, 1 ignored. origin/main baseline (cargo test -j 4 --locked -p victory-gpu --features diagnostics): 197 passed, 1 failed (memory::tests::a_submission_that_missed_leaves_the_copies_at_once, memory.rs:886), 1 ignored. That test passed in all four PR runs, so it looks flaky; I did not investigate it, and none of these PRs touch memory.rs.
  • clippy (same four invocations as above): clean.
  • Negative control: made the overflow branch dead (if high - low == f32::INFINITY -> if false) -> test fails for the -f32::MAX..f32::MAX case: got all-black [0,0,0,255, 0,0,0,255, ...], wanted [0, 127, 191, 255] greys. The f32::MAX/4 case does not overflow and passes either way, so it acts as the non-overflow control.
  • Code read: samples and both endpoints are halved together, so the normalised result is unchanged apart from the overflow case; the logged low/high stay the real values. No bugs found.

AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.

**@⁠oni-swr** on GitHub · 2026-11-25 18:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655#issuecomment-7170612016) **Independent verification of head `ee109c3e8482aaa30d72049b8abac56bc77fd329`** on `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` (merges cleanly, fast-forward). **Environment:** Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` set for every run; `victory-gpu` tests were only run with `--features diagnostics` (without it the crate opens the default adapter). **Limits:** no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware. - Focused: `... -p victory-gpu --features diagnostics grayscale_capture` -> `capture::grayscale_capture_preserves_contrast_across_a_wide_float_range` 1 passed. - Full crate: 199 passed, 0 failed, 1 ignored. `origin/main` baseline (`cargo test -j 4 --locked -p victory-gpu --features diagnostics`): 197 passed, 1 failed (`memory::tests::a_submission_that_missed_leaves_the_copies_at_once`, `memory.rs:886`), 1 ignored. That test passed in all four PR runs, so it looks flaky; I did not investigate it, and none of these PRs touch `memory.rs`. - clippy (same four invocations as above): clean. - **Negative control:** made the overflow branch dead (`if high - low == f32::INFINITY` -> `if false`) -> test fails for the `-f32::MAX..f32::MAX` case: got all-black `[0,0,0,255, 0,0,0,255, ...]`, wanted `[0, 127, 191, 255]` greys. The `f32::MAX/4` case does not overflow and passes either way, so it acts as the non-overflow control. - Code read: samples and both endpoints are halved together, so the normalised result is unchanged apart from the overflow case; the logged `low`/`high` stay the real values. No bugs found. AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:19 UTC · original

Automated triage for the maintainers.

Merge candidate (small, diagnostics only). In to_rgba (crates/victory-gpu/src/capture.rs), when a grey target's finite span high - low overflows f32 (for example a float target holding both -FLT_MAX and FLT_MAX, as a clear value can), the samples and both endpoints are halved so the ratios survive. Before this, the whole image came out black. I checked that infinities and NaN map as before, that the non-grey path cannot overflow (low is 0), and that the log line still reports the unscaled low. The regression test covers an overflowing and a non-overflowing range. It merges cleanly onto current main (it is based on f3578e3); CI check: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655#issuecomment-7176213078) <!-- victory-triage v1 head=61e9f8f544861986b56dc288dda91bc38e8d26dc verdict=merge-candidate at=2026-11-25T22:19:30Z --> Automated triage for the maintainers. **Merge candidate** (small, diagnostics only). In `to_rgba` (`crates/victory-gpu/src/capture.rs`), when a grey target's finite span `high - low` overflows f32 (for example a float target holding both -FLT_MAX and FLT_MAX, as a clear value can), the samples and both endpoints are halved so the ratios survive. Before this, the whole image came out black. I checked that infinities and NaN map as before, that the non-grey path cannot overflow (low is 0), and that the log line still reports the unscaled low. The regression test covers an overflowing and a non-overflowing range. It merges cleanly onto current `main` (it is based on f3578e3); CI `check`: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 04:50 UTC · original · approved these changes

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 grayscale_capture_preserves_contrast_across_a_wide_float_range).
  • 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 04:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655#pullrequestreview-6068707740) · **approved these changes** 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 `grayscale_capture_preserves_contrast_across_a_wide_float_range`). - `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).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 09:15 UTC · original

NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head 61e9f8f (on its base f3578e3).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 863 passed, 0 failed, 10 ignored.
  • grayscale_capture_preserves_contrast_across_a_wide_float_range only builds with the diagnostics feature, so the run above doesn't include it; it passes in cargo test -p victory-core -p victory-gpu -p victory-hle -p victory-loader -p victory-shader -p victory --lib --locked --features victory-core/diagnostics,victory-gpu/diagnostics,victory-hle/diagnostics,victory-loader/diagnostics,victory-shader/diagnostics,victory/diagnostics (same skips).
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 09:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655#issuecomment-7187666366) NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head `61e9f8f` (on its base `f3578e3`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **863 passed, 0 failed, 10 ignored**. - `grayscale_capture_preserves_contrast_across_a_wide_float_range` only builds with the `diagnostics` feature, so the run above doesn't include it; it passes in `cargo test -p victory-core -p victory-gpu -p victory-hle -p victory-loader -p victory-shader -p victory --lib --locked --features victory-core/diagnostics,victory-gpu/diagnostics,victory-hle/diagnostics,victory-loader/diagnostics,victory-shader/diagnostics,victory/diagnostics` (same skips). - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 14:53 UTC · original · approved these changes

Reviewed crates/victory-gpu/src/capture.rs at 61e9f8f5 merged onto origin/main (63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.

  • Range scaling math & diagnostics gating: in capture.rs:717-731 (strictly under diagnostics), halving low, high, and finite samples only when high - low == f32::INFINITY keeps the span finite for wide-range signed float grayscale captures without altering non-grey targets (low == 0.0), all-non-finite images (high - low == -f32::INFINITY), or normal ranges, while reported_low preserves the unscaled range in the log line.
  • Verification:
    • cargo run -p xtask -- policy: 191 files ok.
    • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
    • cargo test -p victory-gpu --lib --features diagnostics capture::: 12/12 passed on RTX 5090 + Debug Layer and 12/12 passed on WARP + Debug Layer (including grayscale_capture_preserves_contrast_across_a_wide_float_range at capture.rs:777).
    • Additional synthetic edge probe covering NaN, ±Inf, all-non-finite, asymmetric -f32::MAX..1e38, negative-only, all-zero, constant non-zero, tiny subnormal, and R16_FLOAT inputs passed cleanly with no overflow or divide-by-zero.
    • Merges cleanly with #2673 (22/22 capture + capture_diff tests pass together on WARP + Debug Layer).
**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2655#pullrequestreview-6076226310) · **approved these changes** Reviewed `crates/victory-gpu/src/capture.rs` at `61e9f8f5` merged onto `origin/main` (`63bcca43`) and verified on RTX 5090 and WARP (`VICTORY_D3D12_WARP=1`) with `VICTORY_D3D12_DEBUG=1`. - **Range scaling math & diagnostics gating**: in `capture.rs:717-731` (strictly under `diagnostics`), halving `low`, `high`, and finite samples only when `high - low == f32::INFINITY` keeps the span finite for wide-range signed float grayscale captures without altering non-grey targets (`low == 0.0`), all-non-finite images (`high - low == -f32::INFINITY`), or normal ranges, while `reported_low` preserves the unscaled range in the log line. - **Verification**: - `cargo run -p xtask -- policy`: 191 files ok. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - `cargo test -p victory-gpu --lib --features diagnostics capture::`: **12/12 passed** on RTX 5090 + Debug Layer and **12/12 passed** on WARP + Debug Layer (including `grayscale_capture_preserves_contrast_across_a_wide_float_range` at `capture.rs:777`). - Additional synthetic edge probe covering `NaN`, `±Inf`, all-non-finite, asymmetric `-f32::MAX..1e38`, negative-only, all-zero, constant non-zero, tiny subnormal, and `R16_FLOAT` inputs passed cleanly with no overflow or divide-by-zero. - Merges cleanly with `#2673` (`22/22` `capture` + `capture_diff` tests pass together on WARP + Debug Layer).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2655/head:github-bot/gh-2655'
git switch 'github-bot/gh-2655'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2655'
git switch 'github-bot/gh-2655'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2655'
git switch 'github-bot/gh-2655'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2655'
git switch 'main'
git merge --squash 'github-bot/gh-2655'
git switch 'main'
git merge --ff-only 'github-bot/gh-2655'
git switch 'main'
git merge 'github-bot/gh-2655'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2655
No description provided.