Preserve signed R16 contrast in PNG captures #2320

Open
github-bot wants to merge 1 commit from github-bot/gh-2320 into main AGit
Owner

@⁠DoubleD17 on GitHub · 2026-11-25 10:35 UTC · original
DoubleD17:fix/signed-r16-capture-contrast → main · +44 −3 · 1 files · 1 commits · open

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.

**@⁠DoubleD17** on GitHub · 2026-11-25 10:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2320) `DoubleD17:fix/signed-r16-capture-contrast` → `main` · +44 −3 · 1 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:10 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 12:39 UTC · original

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.

**@⁠cloph-dsp** on GitHub · 2026-11-25 12:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2320#issuecomment-7162667103) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:17 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 15:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2320#issuecomment-7166610572) <!-- 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)_
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/2320/head:github-bot/gh-2320'
git switch 'github-bot/gh-2320'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2320'
git switch 'github-bot/gh-2320'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2320'
git switch 'github-bot/gh-2320'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2320'
git switch 'main'
git merge --squash 'github-bot/gh-2320'
git switch 'main'
git merge --ff-only 'github-bot/gh-2320'
git switch 'main'
git merge 'github-bot/gh-2320'
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!2320
No description provided.