Capture: save packed R10G10B10A2 presentation frames #2827

Open
github-bot wants to merge 2 commits from github-bot/gh-2827 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 21:35 UTC · original
andrewpozdnakov7-jpg:codex2/capture-rgb10-frame → main · +124 −28 · 1 files · 2 commits · open

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 21:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2827) `andrewpozdnakov7-jpg:codex2/capture-rgb10-frame` → `main` · +124 −28 · 1 files · 2 commits · open 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://git.gtahub.st/github/Marvisak--VIctory/issues/1633) AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:14 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 22:47 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 22:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7176791065) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 02:22 UTC · original · edited 2026-11-26 03:19 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-26 02:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7180749134) · edited 2026-11-26 03:19 UTC <!-- 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)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:33 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 02:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2827#issuecomment-7180918080) [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.
This pull request can be merged automatically.
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/2827/head:github-bot/gh-2827'
git switch 'github-bot/gh-2827'

Merge

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