GPU capture: decode signed R8 and R16 targets #3639

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3639 into main
andrewpozdnakov7-jpg commented 2026-11-28 01:24:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:24:44Z.


Signed one-channel render targets are decoded as unsigned words when producing a grayscale diagnostic image. This reverses contrast near zero and can make a negative pixel look like a bright positive one.

Decode R8_SINT and R16_SINT as signed integers. Decode R8_SNORM and R16_SNORM in [-1, 1], including the two negative endpoint encodings that both map to -1. The grayscale scaling and row-pitch handling stay in the existing path.

The two new tests fail on main at 63bcca43 and pass with the fix. The tests use generated rows with padding to check negative, zero and positive values in each format, and compare the lowest two SINT and SNORM encodings.

DXGI format definitions. Claimed in #1633.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5535344895 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:24:44Z. --- Signed one-channel render targets are decoded as unsigned words when producing a grayscale diagnostic image. This reverses contrast near zero and can make a negative pixel look like a bright positive one. Decode `R8_SINT` and `R16_SINT` as signed integers. Decode `R8_SNORM` and `R16_SNORM` in `[-1, 1]`, including the two negative endpoint encodings that both map to `-1`. The grayscale scaling and row-pitch handling stay in the existing path. The two new tests fail on main at `63bcca43` and pass with the fix. The tests use generated rows with padding to check negative, zero and positive values in each format, and compare the lowest two SINT and SNORM encodings. [DXGI format definitions](https://learn.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format). Claimed in #1633. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 01:25:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:25:03Z.


Verified main 63bcca43c6a00a758510398fa43096ce7e4f7df0 and this head e0b5e8f7fbbea890f9a41ec95242305444e6c6e1 with the same two generated-pixel tests. Both tests fail on main. The PR passed all 13 capture tests, strict all-features GPU Clippy, and the asset policy check (191 files).

For padded rows with components -2, 0, +2, all four signed R8/R16 formats now give the grayscale levels 0, 127, 255. The two lowest SNORM encodings give the same level. Their SINT counterparts remain distinct. This ran through the capture decoder with generated rows and did not depend on game or driver output.

Please preserve the Git author if cherry-picking or rebasing, or include this trailer if folding the change into another commit.

Co-authored-by: andrewpozdnakov7-jpg <[email protected]>

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231651152 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639#issuecomment-7231651152). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:25:03Z. --- Verified main `63bcca43c6a00a758510398fa43096ce7e4f7df0` and this head `e0b5e8f7fbbea890f9a41ec95242305444e6c6e1` with the same two generated-pixel tests. Both tests fail on main. The PR passed all 13 capture tests, strict all-features GPU Clippy, and the asset policy check (191 files). For padded rows with components `-2, 0, +2`, all four signed R8/R16 formats now give the grayscale levels `0, 127, 255`. The two lowest SNORM encodings give the same level. Their SINT counterparts remain distinct. This ran through the capture decoder with generated rows and did not depend on game or driver output. Please preserve the Git author if cherry-picking or rebasing, or include this trailer if folding the change into another commit. `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`
andrewpozdnakov7-jpg commented 2026-11-28 01:43:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:43:52Z.


#2518 and #2320 already cover the signed 8-bit and 16-bit color families, including two- and four-component targets. I resolved their overlaps with e0b5e8f on 63bcca4, keeping those color paths and #3639's single-channel SNORM endpoint handling. The branch preserves all three PR heads. Integration branch fd4476f

The two most-negative codes represent the same normalized value in SNORM. They remain distinct in SINT. I split #2518's grayscale ramp expectations accordingly. With inputs 80 ff 00 7f, the resulting 8-bit levels are 0, 126, 127, 255 for R8_SNORM and 0, 127, 128, 255 for R8_SINT. Direct3D SNORM conversion

I compiled the unmodified CPU conversion functions from each revision in a small Rust test harness, with the same 20 capture fixtures in both runs. Main failed the seven signed-format checks. All 20 passed on the integration, including row padding and the unsigned/HDR/R32 controls. This covers CPU conversion from generated rows to RGBA. The full GPU crate was outside the run. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231877716 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639#issuecomment-7231877716). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:43:52Z. --- #2518 and #2320 already cover the signed 8-bit and 16-bit color families, including two- and four-component targets. I resolved their overlaps with `e0b5e8f` on `63bcca4`, keeping those color paths and #3639's single-channel SNORM endpoint handling. The branch preserves all three PR heads. [Integration branch `fd4476f`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/signed-r8-r16-capture) The two most-negative codes represent the same normalized value in SNORM. They remain distinct in SINT. I split #2518's grayscale ramp expectations accordingly. With inputs `80 ff 00 7f`, the resulting 8-bit levels are `0, 126, 127, 255` for R8_SNORM and `0, 127, 128, 255` for R8_SINT. [Direct3D SNORM conversion](https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#SNORM_to_FLOAT) I compiled the unmodified CPU conversion functions from each revision in a small Rust test harness, with the same 20 capture fixtures in both runs. Main failed the seven signed-format checks. All 20 passed on the integration, including row padding and the unsigned/HDR/R32 controls. This covers CPU conversion from generated rows to RGBA. The full GPU crate was outside the run. AI-assisted with Codex.
Dukestar69 commented 2026-11-28 02:48:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-28T02:48:17Z.

Review: APPROVED


LGTM — verified on Windows:

  • cargo test -p victory-gpu --features diagnostics --lib capture:: passed (13/13, including signed_grayscale_targets_keep_the_order_across_zero)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings and --features diagnostics --all-targets -- -D warnings both passed with 0 warnings
  • cargo xtask policy passed (191 files ok)

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6095258577 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639#pullrequestreview-6095258577). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T02:48:17Z. **Review:** APPROVED --- LGTM — verified on Windows: - `cargo test -p victory-gpu --features diagnostics --lib capture::` passed (13/13, including `signed_grayscale_targets_keep_the_order_across_zero`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics --all-targets -- -D warnings` both passed with 0 warnings - `cargo xtask policy` passed (`191 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
andrewpozdnakov7-jpg commented 2026-11-28 06:44:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T06:44:53Z.


I added a paired signed/unsigned control for the two single-channel SINT formats. Each test passes the same bytes and pitch through both views of a generated 2×2 target, so it checks that the change restores signed order while keeping the unsigned output.

Format Grayscale on main (63bcca4) On #3639 (e0b5e8f)
R8_SINT 128, 255, 0, 127 0, 127, 128, 255
R16_SINT 127, 255, 0, 127 0, 127, 127, 255

Both tests fail their signed assertion on main and pass on #3639. The unsigned expectations pass on both. On the PR head with the two tests, all 15 capture tests, strict GPU Clippy and the asset policy passed.

Test-only branch

Please retain the Git author if you cherry-pick or rebase the tests. If you fold them into another commit, please retain the trailer below.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7235492691 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639#issuecomment-7235492691). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T06:44:53Z. --- I added a paired signed/unsigned control for the two single-channel SINT formats. Each test passes the same bytes and pitch through both views of a generated 2×2 target, so it checks that the change restores signed order while keeping the unsigned output. | Format | Grayscale on `main` (`63bcca4`) | On #3639 (`e0b5e8f`) | | --- | --- | --- | | R8_SINT | 128, 255, 0, 127 | 0, 127, 128, 255 | | R16_SINT | 127, 255, 0, 127 | 0, 127, 127, 255 | Both tests fail their signed assertion on `main` and pass on #3639. The unsigned expectations pass on both. On the PR head with the two tests, all 15 capture tests, strict GPU Clippy and the asset policy passed. [Test-only branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/3639-signed-unsigned-controls) Please retain the Git author if you cherry-pick or rebase the tests. If you fold them into another commit, please retain the trailer below. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with OpenAI Codex.
futurepro62 commented 2026-11-29 21:15:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-29T21:15:55Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head e0b5e8f (on its base 63bcca4).

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: 866 passed, 0 failed, 10 ignored.
  • signed_grayscale_targets_keep_the_order_across_zero, signed_normalized_targets_alias_the_two_negative_endpoints only build with the diagnostics feature, so the run above doesn't include them; they pass 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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7262737158 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639#issuecomment-7262737158). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-29T21:15:55Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `e0b5e8f` (on its base `63bcca4`). **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`: **866 passed, 0 failed, 10 ignored**. - `signed_grayscale_targets_keep_the_order_across_zero`, `signed_normalized_targets_alias_the_two_negative_endpoints` only build with the `diagnostics` feature, so the run above doesn't include them; they pass 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.
passerbyyhx commented 2026-11-30 23:21:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-30T23:21:04Z.


Added a GPU-to-PNG comparison on e0b5e8f7fbbea890f9a41ec95242305444e6c6e1. On RTX 4090 Laptop and WARP, four typed R8/R16 SINT/SNORM textures were written and copied back at a real 256-byte row pitch. The original texel bytes matched between the head and base. An independent decoder then checked all rows of the 16 PNGs produced by the capture code (two devices × two revisions × four formats). On the head both SINT formats produced first-row grayscale 0,127,255,191; both SNORM formats produced 0,0,127,255, including the two negative endpoints.

For this GPU fixture both revisions had the same local mapping-length adjustment to account for the final row's omitted trailing padding. Pixel decoding, sampling and PNG encoding were unchanged by that adjustment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7295013965 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3639#issuecomment-7295013965). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-30T23:21:04Z. --- Added a GPU-to-PNG comparison on `e0b5e8f7fbbea890f9a41ec95242305444e6c6e1`. On RTX 4090 Laptop and WARP, four typed R8/R16 SINT/SNORM textures were written and copied back at a real 256-byte row pitch. The original texel bytes matched between the head and base. An independent decoder then checked all rows of the 16 PNGs produced by the capture code (two devices × two revisions × four formats). On the head both SINT formats produced first-row grayscale `0,127,255,191`; both SNORM formats produced `0,0,127,255`, including the two negative endpoints. For this GPU fixture both revisions had the same local mapping-length adjustment to account for the final row's omitted trailing padding. Pixel decoding, sampling and PNG encoding were unchanged by that adjustment.
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/3639:upstream-pr/3639'
git switch 'upstream-pr/3639'

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