Preserve signed R8 contrast in PNG captures #2516

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

Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-25T15:12:41Z.


The capture converter reads signed 8-bit DXGI channels as unsigned bytes, so a negative value can appear as a bright positive value. Decode the six signed SNORM and SINT formats in the RGBA8, RG8, and R8 families as i8 before applying the existing diagnostic scale. Negative color channels clamp to zero, and single-channel grayscale uses the observed signed minimum and maximum. Unsigned, sRGB, typeless, and alpha-only inputs retain their existing interpretation. Synthetic CPU tests on Windows x64 with Rust 1.98.1 MSVC and diagnostics passed 3 of 6 with the same fixtures on main 940d32f, then 6 of 6 on 26f1159. The tests check the RGBA bytes passed to the PNG encoder. A temporary combination with the signed R16 change in #2320 passed 8 of 8 capture tests after resolving adjacent textual conflicts. The default workspace CI test command runs without diagnostics; the focused capture test was performed locally.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5494025940 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2518). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-25T15:12:41Z. --- The capture converter reads signed 8-bit DXGI channels as unsigned bytes, so a negative value can appear as a bright positive value. Decode the six signed SNORM and SINT formats in the RGBA8, RG8, and R8 families as `i8` before applying the existing diagnostic scale. Negative color channels clamp to zero, and single-channel grayscale uses the observed signed minimum and maximum. Unsigned, sRGB, typeless, and alpha-only inputs retain their existing interpretation. Synthetic CPU tests on Windows x64 with Rust 1.98.1 MSVC and `diagnostics` passed 3 of 6 with the same fixtures on main `940d32f`, then 6 of 6 on `26f1159`. The tests check the RGBA bytes passed to the PNG encoder. A temporary combination with [the signed R16 change in #2320](https://github.com/Marvisak/VIctory/pull/2320) passed 8 of 8 capture tests after resolving adjacent textual conflicts. The default workspace CI test command runs without `diagnostics`; the focused capture test was performed locally. AI-assisted.
Marvisak commented 2026-11-25 17:05:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:13:39Z.


Automated triage for the maintainers.

Merge candidate.

to_rgba in crates/victory-gpu/src/capture.rs now decodes the signed 8-bit DXGI formats as i8 before the existing scaling: 31/32 (R8G8B8A8 SNORM/SINT), 51/52 (R8G8) and 63/64 (R8). The unsigned, typeless, sRGB and A8 cases keep the byte path. The format numbers match DXGI. With main's scaling (colour from 0 using the 99th percentile of absolute values, grey from the observed min/max), negative colour clamps to black and signed grey uses its real range, which is what the new tests assert.

This only affects diagnostic PNG captures and does not change emulation. The tracing-subscriber test for the RGBA8 stats is more than strictly needed, but it is harmless. It complements #2320 (signed R16).

CI: check passing. CI builds without diagnostics, so the capture tests themselves were run only locally.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167703745 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2518#issuecomment-7167703745). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:13:39Z. --- <!-- victory-triage v1 head=ff54044b1de400a7d9a8063a2e9ea0f38e759d59 verdict=merge-candidate at=2026-11-25T16:42:59Z --> Automated triage for the maintainers. **Merge candidate.** `to_rgba` in `crates/victory-gpu/src/capture.rs` now decodes the signed 8-bit DXGI formats as `i8` before the existing scaling: 31/32 (R8G8B8A8 SNORM/SINT), 51/52 (R8G8) and 63/64 (R8). The unsigned, typeless, sRGB and A8 cases keep the byte path. The format numbers match DXGI. With main's scaling (colour from 0 using the 99th percentile of absolute values, grey from the observed min/max), negative colour clamps to black and signed grey uses its real range, which is what the new tests assert. This only affects diagnostic PNG captures and does not change emulation. The tracing-subscriber test for the RGBA8 stats is more than strictly needed, but it is harmless. It complements #2320 (signed R16). CI: `check` passing. CI builds without `diagnostics`, so the capture tests themselves were run only locally. --- _Generated by [Claude Code](https://claude.ai/code)_
futurepro62 commented 2026-11-26 02:06:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:06:09Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head ff54044 (on its base 67e8ae1).

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: 773 passed, 0 failed, 9 ignored.
  • signed_rgba8_clamps_negative_colour_and_keeps_alpha_opaque, signed_rg8_clamps_negative_colour, signed_r8_grayscale_uses_signed_extrema, unsigned_srgb_and_alpha_only_keep_their_byte_interpretation, unsigned_rgba8_logs_raw_channel_stats_excluding_row_padding only build with the diagnostics feature, so the run above doesn't include them; they pass in cargo test -p victory-gpu --lib --locked --features 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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7179433670 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2518#issuecomment-7179433670). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T01:06:09Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `ff54044` (on its base `67e8ae1`). **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`: **773 passed, 0 failed, 9 ignored**. - `signed_rgba8_clamps_negative_colour_and_keeps_alpha_opaque`, `signed_rg8_clamps_negative_colour`, `signed_r8_grayscale_uses_signed_extrema`, `unsigned_srgb_and_alpha_only_keep_their_byte_interpretation`, `unsigned_rgba8_logs_raw_channel_stats_excluding_row_padding` only build with the `diagnostics` feature, so the run above doesn't include them; they pass in `cargo test -p victory-gpu --lib --locked --features 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.
fuzeofficlal commented 2026-11-26 20:10:37 +00:00 (Migrated from github.com)

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

Review: APPROVED


Verified locally merged onto origin/main (63bcca43) at PR head ff54044b (Windows 11 x64):

  • crates/victory-gpu/src/capture.rs (to_rgba): cleanly separates the six signed 8-bit DXGI formats (31..=32 RGBA8 SNORM/SINT, 51..=52 RG8 SNORM/SINT, 63..=64 R8 SNORM/SINT) to decode channels as i8, while preserving byte interpretation for unsigned/typeless/sRGB/A8 formats (27..=30, 48..=50, 60..=62 | 65). Negative color channels clamp to black with opaque alpha, and signed R8 grayscale maps observed signed extrema monotonically (-128, -1, 0, 127 -> 0, 127, 128, 255).
  • cargo xtask policy: 191 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features): 0 warnings.
  • Default build (cargo test --locked -p victory-gpu --lib capture): compiles cleanly.
  • Diagnostics build (--features diagnostics, capture::): 16/16 tests passed both sequentially (--test-threads=1) and across 20/20 consecutive parallel runs (--test-threads=8), confirming RGBA8_TRACE reliably guards the scoped subscriber test.
  • Extra synthetic edge probe (not committed): verified all-negative and all-zero RGBA8/RG8 inputs clamp cleanly to black without NaN/overflow, and signed R8 row-pitch padding (0x7f) does not skew extrema.
  • Verified clean co-merge with #2486 (both edit capture.rs), with clippy and all combined capture tests passing (including constant negative signed R8 rendering white while zero stays black).

Synthetic tests only; looks ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079991960 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2518#pullrequestreview-6079991960). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T20:10:37Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`63bcca43`) at PR head `ff54044b` (Windows 11 x64): - `crates/victory-gpu/src/capture.rs` (`to_rgba`): cleanly separates the six signed 8-bit DXGI formats (`31..=32` RGBA8 SNORM/SINT, `51..=52` RG8 SNORM/SINT, `63..=64` R8 SNORM/SINT) to decode channels as `i8`, while preserving byte interpretation for unsigned/typeless/sRGB/A8 formats (`27..=30`, `48..=50`, `60..=62 | 65`). Negative color channels clamp to black with opaque alpha, and signed R8 grayscale maps observed signed extrema monotonically (`-128, -1, 0, 127` -> `0, 127, 128, 255`). - `cargo xtask policy`: 191 files ok. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): 0 warnings. - Default build (`cargo test --locked -p victory-gpu --lib capture`): compiles cleanly. - Diagnostics build (`--features diagnostics`, `capture::`): 16/16 tests passed both sequentially (`--test-threads=1`) and across 20/20 consecutive parallel runs (`--test-threads=8`), confirming `RGBA8_TRACE` reliably guards the scoped subscriber test. - Extra synthetic edge probe (not committed): verified all-negative and all-zero RGBA8/RG8 inputs clamp cleanly to black without NaN/overflow, and signed R8 row-pitch padding (`0x7f`) does not skew extrema. - Verified clean co-merge with `#2486` (both edit `capture.rs`), with clippy and all combined capture tests passing (including constant negative signed R8 rendering white while zero stays black). Synthetic tests only; looks ready to merge.
Dukestar69 commented 2026-11-26 21:11:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:11:02Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Preserving signed R8 contrast in diagnostic PNG captures passes cleanly with both default and --features diagnostics builds.
  • cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default + --features diagnostics): clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6080513492 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2518#pullrequestreview-6080513492). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T21:11:02Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Preserving signed R8 contrast in diagnostic PNG captures passes cleanly with both default and `--features diagnostics` builds. - `cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default + `--features diagnostics`): clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/2518:upstream-pr/2518'
git switch 'upstream-pr/2518'

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