Preserve signed R16 contrast in PNG captures #2318

Open
DoubleD17 wants to merge 1 commit from upstream-pr/2320 into main
DoubleD17 commented 2026-11-25 10:35:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-25T10:35:43Z.


The diagnostic capture converter treated signed R16 texture channels as unsigned, which could turn negative components into bright pixels. Decode the six signed R16 SNORM and SINT DXGI formats as little-endian i16 and keep the existing display normalization. On Windows with Rust 1.98.1, the base with the regression fixtures passed 2 of 4 focused tests and this commit passed 4 of 4. The synthetic tests check the RGBA passed to the PNG encoder for signed color and grayscale, including an unsigned control.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6602517251 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2320). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-25T10:35:43Z. --- The diagnostic capture converter treated signed R16 texture channels as unsigned, which could turn negative components into bright pixels. Decode the six signed R16 SNORM and SINT DXGI formats as little-endian i16 and keep the existing display normalization. On Windows with Rust 1.98.1, the base with the regression fixtures passed 2 of 4 focused tests and this commit passed 4 of 4. The synthetic tests check the RGBA passed to the PNG encoder for signed color and grayscale, including an unsigned control. AI-assisted.
DenRakEiw commented 2026-11-25 11:04:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T10:42:05Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Preserving signed i16 semantics in capture::to_rgba prevents negative components in signed 16-bit formats from wrapping/brightening while keeping unsigned formats unchanged.
  • cargo test -p victory-gpu --features diagnostics capture::tests: 4/4 passed on RTX 5090, 4/4 passed on WARP (including signed_r16_colours_do_not_brighten_negative_components and signed_r16_luma_keeps_negative_zero_and_positive_in_order).
  • cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056055543 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2320#pullrequestreview-6056055543). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T10:42:05Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Preserving signed `i16` semantics in `capture::to_rgba` prevents negative components in signed 16-bit formats from wrapping/brightening while keeping unsigned formats unchanged. - `cargo test -p victory-gpu --features diagnostics capture::tests`: 4/4 passed on RTX 5090, 4/4 passed on WARP (including `signed_r16_colours_do_not_brighten_negative_components` and `signed_r16_luma_keeps_negative_zero_and_positive_in_order`). - `cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 11:04:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:54:06Z.

Review: COMMENTED


PNG captures decode signed R16/R16G16 as signed (i16) instead of unsigned — contrast preserved. 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. Capture/diagnostics only, safe.

<!-- greyfinch-sync:Marvisak/VIctory:review:6056244092 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2320#pullrequestreview-6056244092). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:54:06Z. **Review:** COMMENTED --- PNG captures decode signed R16/R16G16 as signed (i16) instead of unsigned — contrast preserved. 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. Capture/diagnostics only, safe.
cloph-dsp commented 2026-11-25 13:02:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T12:39:06Z.


Independent local validation (Windows, Rust 1.100.0/MSVC, head 49bcd08, no game data): cargo test --locked -p victory-gpu --lib --features diagnostics signed_r16 -> 2 tests passed (signed_r16_colours_do_not_brighten_negative_components, signed_r16_luma_keeps_negative_zero_and_positive_in_order), exit 0. The same command on main 940d32f matches 0 tests, confirming the PR adds both. Note: mod capture is gated by #[cfg(all(windows, feature = "diagnostics"))] at crates/victory-gpu/src/lib.rs:21-22, so the --features diagnostics flag is required; the plain capture:: filter matches nothing. Two pre-existing fetch_update/try_update deprecation warnings. I did not run a real title capture or verify the PNG output with game data. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU unit tests with diagnostics feature). No game data, assets or extracted content used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162667103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2320#issuecomment-7162667103). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T12:39:06Z. --- Independent local validation (Windows, Rust 1.100.0/MSVC, head 49bcd08, no game data): `cargo test --locked -p victory-gpu --lib --features diagnostics signed_r16` -> 2 tests passed (`signed_r16_colours_do_not_brighten_negative_components`, `signed_r16_luma_keeps_negative_zero_and_positive_in_order`), exit 0. The same command on main 940d32f matches 0 tests, confirming the PR adds both. Note: `mod capture` is gated by `#[cfg(all(windows, feature = "diagnostics"))]` at crates/victory-gpu/src/lib.rs:21-22, so the `--features diagnostics` flag is required; the plain `capture::` filter matches nothing. Two pre-existing `fetch_update`/`try_update` deprecation warnings. I did not run a real title capture or verify the PNG output with game data. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU unit tests with diagnostics feature). No game data, assets or extracted content used.
Marvisak commented 2026-11-25 16:09:08 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Merge candidate (worth a look). In capture.rs to_rgba, this decodes the signed 16-bit formats as i16 instead of u16: R16G16B16A16 SNORM/SINT (13, 14), R16G16 SNORM/SINT (37, 38) and R16 SNORM/SINT (58, 59). Negative components therefore no longer show up as bright pixels in diagnostic PNG captures. I checked the format ranges against the DXGI numbering, so the UNORM/UINT and D16 arms keep the unsigned path, and worked the new tests through the existing scaling (colour clamped at 0 and scaled by p99; grey scaled from min to max): the expected bytes match. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166610572 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2320#issuecomment-7166610572). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:17:37Z. --- <!-- victory-triage v1 head=49bcd08f1d1d93ee5d78060606a65b1dbb2fe8ab verdict=merge-candidate at=2026-11-25T15:17:04Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** In `capture.rs` `to_rgba`, this decodes the signed 16-bit formats as `i16` instead of `u16`: R16G16B16A16 SNORM/SINT (13, 14), R16G16 SNORM/SINT (37, 38) and R16 SNORM/SINT (58, 59). Negative components therefore no longer show up as bright pixels in diagnostic PNG captures. I checked the format ranges against the DXGI numbering, so the UNORM/UINT and D16 arms keep the unsigned path, and worked the new tests through the existing scaling (colour clamped at 0 and scaled by p99; grey scaled from min to max): the expected bytes match. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 03:03:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:08:26Z.

Review: COMMENTED


Reviewed and verified against main (63bcca43) on Windows 11 — clean fix and ready to merge:

  • Splitting signed 16-bit DXGI formats (13..=14 RGBA16 SNORM/SINT, 37..=38 RG16 SNORM/SINT, 58..=59 R16 SNORM/SINT) onto i16::from_le_bytes prevents negative components from wrapping to 65535 and blowing out highlights while keeping signed single-channel R16 ordered across i16::MIN..=i16::MAX.

Local verification:

  • cargo test --locked -p victory-gpu --features diagnostics --lib capture::: 13/13 passed (including both new signed R16 tests)
  • cargo clippy --all-targets -p victory-gpu -- -D warnings (default & --features diagnostics) + cargo xtask policy (191 files ok): 0 warnings
<!-- greyfinch-sync:Marvisak/VIctory:review:6067611425 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2320#pullrequestreview-6067611425). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:08:26Z. **Review:** COMMENTED --- Reviewed and verified against `main` (`63bcca43`) on Windows 11 — clean fix and ready to merge: - Splitting signed 16-bit DXGI formats (`13..=14` RGBA16 `SNORM`/`SINT`, `37..=38` RG16 `SNORM`/`SINT`, `58..=59` R16 `SNORM`/`SINT`) onto `i16::from_le_bytes` prevents negative components from wrapping to `65535` and blowing out highlights while keeping signed single-channel R16 ordered across `i16::MIN..=i16::MAX`. **Local verification**: - `cargo test --locked -p victory-gpu --features diagnostics --lib capture::`: **13/13 passed** (including both new signed R16 tests) - `cargo clippy --all-targets -p victory-gpu -- -D warnings` (default & `--features diagnostics`) + `cargo xtask policy` (`191 files ok`): 0 warnings
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/2320:upstream-pr/2320'
git switch 'upstream-pr/2320'

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