Capture: save packed R10G10B10A2 presentation frames #2825

Open
andrewpozdnakov7-jpg wants to merge 2 commits from upstream-pr/2827 into main
andrewpozdnakov7-jpg commented 2026-11-25 21:35:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T21:35:26Z.


The presenter already copies R10G10B10A2 textures into an UNORM swap chain, but the frame PNG path discards their readback. Decode the packed RGB fields while sampling pixels for the existing 8-bit PNG. UINT and TYPELESS use the displayed UNORM interpretation of the same packed colors. DXGI format documentation

The committed test encodes padded synthetic rows in-process through the same format selection and PNG encoder used by readback. It decodes the PNG and checks the dimensions and sampled RGB values for RGBA8, BGRA8, RGB10 UNORM, TYPELESS and UINT.

The original D3D12 fixture on inbox and Agility WARP produced the RGBA8 control PNG and skipped the 10-bit frame on the original base. With this change the same fixture produces the expected PNG for the control, the UNORM target and the TYPELESS target with an UNORM view. I reran the fixture on Agility WARP after the test refactor. Full GPU diagnostics passed (247 tests, one ignored), along with strict GPU Clippy in both builds and asset policy.

Coordination claim

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5499566553 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T21:35:26Z. --- The presenter already copies R10G10B10A2 textures into an UNORM swap chain, but the frame PNG path discards their readback. Decode the packed RGB fields while sampling pixels for the existing 8-bit PNG. UINT and TYPELESS use the displayed UNORM interpretation of the same packed colors. [DXGI format documentation](https://learn.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) The committed test encodes padded synthetic rows in-process through the same format selection and PNG encoder used by readback. It decodes the PNG and checks the dimensions and sampled RGB values for RGBA8, BGRA8, RGB10 UNORM, TYPELESS and UINT. The original D3D12 fixture on inbox and Agility WARP produced the RGBA8 control PNG and skipped the 10-bit frame on the original base. With this change the same fixture produces the expected PNG for the control, the UNORM target and the TYPELESS target with an UNORM view. I reran the fixture on Agility WARP after the test refactor. Full GPU diagnostics passed (247 tests, one ignored), along with strict GPU Clippy in both builds and asset policy. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7175152222) AI-assisted with Codex.
kotekompotek commented 2026-11-25 21:59:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:59:06Z.

Review: COMMENTED


Correct: R10G10B10A2 LE pixel unpacks R/G/B at shifts 0/10/20, the (c*255+511)/1023 rounding conversion is the standard 10->8 remap, alpha rightly dropped for RGB PNG. The PngPixel enum replaces the bgra bool cleanly and keeps the half-size read path identical. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065563399 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#pullrequestreview-6065563399). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:59:06Z. **Review:** COMMENTED --- Correct: R10G10B10A2 LE pixel unpacks R/G/B at shifts 0/10/20, the (c*255+511)/1023 rounding conversion is the standard 10->8 remap, alpha rightly dropped for RGB PNG. The PngPixel enum replaces the bgra bool cleanly and keeps the half-size read path identical. LGTM.
fuzeofficlal commented 2026-11-25 23:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:47:30Z.


Verified 8e7fd059 on Windows 11 (RTX 5090 + WARP) against main (f3578e3):

  • cargo xtask policy (190 files ok), cargo clippy --locked -p victory-gpu --all-targets (default & --features diagnostics, 0 warnings).
  • RTX 5090 & WARP (--features diagnostics): capture::tests 3/3 passed (including packed_10_bit_frames_are_saved_as_rgb_pngs).
  • Bit unpacking (R=[9:0], G=[19:10], B=[29:20]) and rounded scaling ((c * 255 + 511) / 1023) as u8 are exact (0->0, 511->127, 512->128, 1023->255, max intermediate 261,376), and switching save_read_back's mapped slice length to buffer.GetDesc().Width as usize cleanly fixes the potential last-row RowPitch * Height over-read.

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176791065 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7176791065). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T22:47:30Z. --- Verified `8e7fd059` on Windows 11 (RTX 5090 + WARP) against `main` (`f3578e3`): - `cargo xtask policy` (`190 files ok`), `cargo clippy --locked -p victory-gpu --all-targets` (default & `--features diagnostics`, 0 warnings). - RTX 5090 & WARP (`--features diagnostics`): `capture::tests` 3/3 passed (including `packed_10_bit_frames_are_saved_as_rgb_pngs`). - Bit unpacking (`R=[9:0]`, `G=[19:10]`, `B=[29:20]`) and rounded scaling `((c * 255 + 511) / 1023) as u8` are exact (`0->0`, `511->127`, `512->128`, `1023->255`, max intermediate `261,376`), and switching `save_read_back`'s mapped slice length to `buffer.GetDesc().Width as usize` cleanly fixes the potential last-row `RowPitch * Height` over-read. Looks clean and ready to merge.
Marvisak commented 2026-11-26 03:05:10 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Verdict: merge candidate. Re-reviewed at ce361dc, which merges cleanly into main. The test no longer starts a child process. packed_10_bit_frames_are_saved_as_rgb_pngs now calls encode_rgb_png on synthetic padded rows in-process and inflates the PNG to check the sampled pixels for five formats. PngPixel::for_present_format in crates/victory-gpu/src/capture.rs handles the same R10G10B10A2 formats (TYPELESS/UNORM/UINT) that swap_format in host.rs copies into a UNORM swap chain, and a comment now explains the UINT case. The 10-bit to 8-bit scaling rounds correctly. Sizing the mapped slice from the buffer's own width also avoids reading past the end on the last row.

CI: passing. Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180749134 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7180749134). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:22:47Z. --- <!-- victory-triage v1 head=ce361dc2ba482799af53add2f849e2d716550cfa verdict=merge-candidate at=2026-11-26T03:19:09Z --> Automated triage for the maintainers. **Verdict: merge candidate.** Re-reviewed at `ce361dc`, which merges cleanly into `main`. The test no longer starts a child process. `packed_10_bit_frames_are_saved_as_rgb_pngs` now calls `encode_rgb_png` on synthetic padded rows in-process and inflates the PNG to check the sampled pixels for five formats. `PngPixel::for_present_format` in `crates/victory-gpu/src/capture.rs` handles the same R10G10B10A2 formats (TYPELESS/UNORM/UINT) that `swap_format` in `host.rs` copies into a UNORM swap chain, and a comment now explains the UINT case. The 10-bit to 8-bit scaling rounds correctly. Sizing the mapped slice from the buffer's own width also avoids reading past the end on the last row. CI: passing. Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-26 03:05:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T02:33:50Z.


ce361dc replaces the self-spawned fixture with an in-process test of the production PNG encoder. The test decodes the resulting image for five source formats and checks the dimensions, pixel order, 10-bit rounding and padded-row sampling. The format selection documents the UNORM swap-chain interpretation for UINT sources.

The new regression passes. I also reran the original 4x2 D3D12 readback fixture privately on Agility WARP with this production code, and all three PNGs matched. Full GPU diagnostics passed (247 tests, one ignored), along with both strict Clippy builds and asset policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180918080 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7180918080). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T02:33:50Z. --- [ce361dc](https://github.com/Marvisak/VIctory/commit/ce361dc2ba482799af53add2f849e2d716550cfa) replaces the self-spawned fixture with an in-process test of the production PNG encoder. The test decodes the resulting image for five source formats and checks the dimensions, pixel order, 10-bit rounding and padded-row sampling. The format selection documents the UNORM swap-chain interpretation for UINT sources. The new regression passes. I also reran the original 4x2 D3D12 readback fixture privately on Agility WARP with this production code, and all three PNGs matched. Full GPU diagnostics passed (247 tests, one ignored), along with both strict Clippy builds and asset policy.
Dukestar69 commented 2026-11-26 03:33:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:33:37Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-gpu --features diagnostics --lib capture::tests: 6 passed, 0 failed (including new packed_10_bit_frames_are_saved_as_rgb_pngs).
  • 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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068196103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#pullrequestreview-6068196103). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T03:33:37Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-gpu --features diagnostics --lib capture::tests`: **6 passed, 0 failed** (including new `packed_10_bit_frames_are_saved_as_rgb_pngs`). - `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).
andrewpozdnakov7-jpg commented 2026-11-28 01:47:10 +00:00 (Migrated from github.com)

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


I checked ce361dc with the resolved signed-capture branch from #3639, #2518 and #2320 on 63bcca4. The conflict is limited to adjacent test insertions in capture.rs. The integration retains both test groups and all four exact PR commits. Integration branch c5b62ab

All 21 capture tests passed in an isolated Rust harness compiled from the exact CPU conversion and PNG encoding functions. The packed test encodes and reads back the expected 2x2 RGB pixels for RGBA8, BGRA8 and all three RGB10 views, with padded source rows. The signed fixtures still pass for R8 and R16 colors and grayscale, including the aliased SNORM endpoints. This run covers generated rows through CPU conversion and encoding. The D3D12 readback path is covered by the original #2827 report. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231915101 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7231915101). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:47:10Z. --- I checked `ce361dc` with the resolved signed-capture branch from #3639, #2518 and #2320 on `63bcca4`. The conflict is limited to adjacent test insertions in `capture.rs`. The integration retains both test groups and all four exact PR commits. [Integration branch `c5b62ab`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/packed-png-and-signed-capture) All 21 capture tests passed in an isolated Rust harness compiled from the exact CPU conversion and PNG encoding functions. The packed test encodes and reads back the expected 2x2 RGB pixels for RGBA8, BGRA8 and all three RGB10 views, with padded source rows. The signed fixtures still pass for R8 and R16 colors and grayscale, including the aliased SNORM endpoints. This run covers generated rows through CPU conversion and encoding. The D3D12 readback path is covered by the original #2827 report. AI-assisted with Codex.
andrewpozdnakov7-jpg commented 2026-11-28 07:07:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T07:07:15Z.


I combined #2827 at ce361dc with #3689 at 9872963 in 5a59b22. One PNG writer now samples RGBA8, BGRA8, packed 10-bit and FP16 pixels using their respective byte widths while retaining the same PNG dimensions and RGB layout.

The two committed pixel tests passed. Seven isolated WARP runs then went through normal presentation and readback for RGBA8, BGRA8, both FP16 layouts and all three R10G10B10A2 formats. An independent decoder verified the dimensions, chunk CRCs and every sampled RGB value in both the black and colored frames from each run. Strict GPU Clippy and the asset policy passed.

A maintainer can use the tested resolution if both PRs land together.

Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding this resolution into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7235728790 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7235728790). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T07:07:15Z. --- I combined #2827 at `ce361dc` with #3689 at `9872963` in [5a59b22](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/5a59b222e91ff626e676c3e68f61bb4b69d5af13). One PNG writer now samples RGBA8, BGRA8, packed 10-bit and FP16 pixels using their respective byte widths while retaining the same PNG dimensions and RGB layout. The two committed pixel tests passed. Seven isolated WARP runs then went through normal presentation and readback for RGBA8, BGRA8, both FP16 layouts and all three R10G10B10A2 formats. An independent decoder verified the dimensions, chunk CRCs and every sampled RGB value in both the black and colored frames from each run. Strict GPU Clippy and the asset policy passed. A maintainer can use the tested resolution if both PRs land together. Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding this resolution into another commit. AI-assisted with OpenAI Codex.
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/2827:upstream-pr/2827'
git switch 'upstream-pr/2827'

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