GPU: capture the mip selected by 2D render-target views #2756

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 19:45 UTC · original
andrewpozdnakov7-jpg:codex2/capture-bound-mip → main · +177 −23 · 4 files · 2 commits · open

Summary

Use the MipSlice from a single-sampled Texture2D render-target view when dumping its first plane. Track a resource and mip together across lists and frames, and use the selected subresource for both the copy and the readback footprint. Nonzero mips are named in the PNG filename. D3D12_TEX2D_RTV

Verification

  • The same synthetic guest command list binds and clears mip 0 to red and mip 1 to green. On 13f91ca, both captures contain only the red 4x4 base-mip PNG.
  • With the change, submission and present each also produce a green 2x2 PNG. The test decodes and checks every pixel and the PNG dimensions.
  • The targeted D3D12 WARP regression, full app-local WARP GPU library suite, strict GPU Clippy with and without diagnostics, and staged asset policy pass.

Coordination claim

Please retain the Git author if cherry-picking or rebasing this commit. If folding it into another commit, add Co-authored-by: andrewpozdnakov7-jpg [email protected].

AI-assisted. Verification used synthetic textures and commands.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 19:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756) `andrewpozdnakov7-jpg:codex2/capture-bound-mip` → `main` · +177 −23 · 4 files · 2 commits · open ## Summary Use the MipSlice from a single-sampled Texture2D render-target view when dumping its first plane. Track a resource and mip together across lists and frames, and use the selected subresource for both the copy and the readback footprint. Nonzero mips are named in the PNG filename. [D3D12_TEX2D_RTV](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_tex2d_rtv) ## Verification - The same synthetic guest command list binds and clears mip 0 to red and mip 1 to green. On 13f91ca, both captures contain only the red 4x4 base-mip PNG. - With the change, submission and present each also produce a green 2x2 PNG. The test decodes and checks every pixel and the PNG dimensions. - The targeted D3D12 WARP regression, full app-local WARP GPU library suite, strict GPU Clippy with and without diagnostics, and staged asset policy pass. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) Please retain the Git author if cherry-picking or rebasing this commit. If folding it into another commit, add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>. AI-assisted. Verification used synthetic textures and commands.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:27 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 20:03 UTC · original

Reviewed and verified 2cc21c3c on Windows 11 (RTX 5090 + WARP) against main (13f91ca).

Code review

  • note_rtv restricts mip extraction strictly to Some(view) with D3D12_RTV_DIMENSION_TEXTURE2D and PlaneSlice == 0, safely falling back to mip = 0 for null RTVs, non-2D/array/MSAA/3D RTVs, non-zero planes, and depth targets (with zero overhead when diagnostics is disabled).
  • dump_one bounds-checks target.mip >= u32::from(d.MipLevels) before read_back_subresource, which passes subresource = target.mip consistently to GetCopyableFootprints (BaseOffset = 0) and CopyTextureRegion, matching f.Width/f.Height/f.RowPitch in to_rgba/save_as.
  • Minor non-blocking note: the output PNG filename (capture.rs:611-617) still embeds the top-level {d.Width}x{d.Height} alongside -mip{target.mip} even though the saved PNG dimensions are the selected mip's f.Width x f.Height.

Verification (Windows 11, RTX 5090 + WARP)

  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- --test-threads=1: 199 passed, 0 failed, 1 ignored (including resource::tests::capture_uses_the_bound_render_target_mip).
  • RTX 5090 (--features diagnostics): capture::tests 2/2, draw::tests --test-threads=1 11/11.
  • cargo clippy -p victory-gpu --all-targets --locked (default and --features diagnostics): 0 warnings; cargo xtask policy: 184 files ok.
  • Merge compatibility: clean git merge-tree against 13f91ca, #2680, and #2701; text conflicts with #2702 (capture.rs), #2673 (capture.rs), and #2732 (capture.rs, host.rs).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 20:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#issuecomment-7173122342) Reviewed and verified `2cc21c3c` on Windows 11 (RTX 5090 + WARP) against `main` (`13f91ca`). ### Code review - `note_rtv` restricts mip extraction strictly to `Some(view)` with `D3D12_RTV_DIMENSION_TEXTURE2D` and `PlaneSlice == 0`, safely falling back to `mip = 0` for null RTVs, non-2D/array/MSAA/3D RTVs, non-zero planes, and depth targets (with zero overhead when `diagnostics` is disabled). - `dump_one` bounds-checks `target.mip >= u32::from(d.MipLevels)` before `read_back_subresource`, which passes `subresource = target.mip` consistently to `GetCopyableFootprints` (`BaseOffset = 0`) and `CopyTextureRegion`, matching `f.Width`/`f.Height`/`f.RowPitch` in `to_rgba`/`save_as`. - Minor non-blocking note: the output PNG filename (`capture.rs:611-617`) still embeds the top-level `{d.Width}x{d.Height}` alongside `-mip{target.mip}` even though the saved PNG dimensions are the selected mip's `f.Width x f.Height`. ### Verification (Windows 11, RTX 5090 + WARP) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- --test-threads=1`: **199 passed, 0 failed, 1 ignored** (including `resource::tests::capture_uses_the_bound_render_target_mip`). - RTX 5090 (`--features diagnostics`): `capture::tests` **2/2**, `draw::tests --test-threads=1` **11/11**. - `cargo clippy -p victory-gpu --all-targets --locked` (default and `--features diagnostics`): **0 warnings**; `cargo xtask policy`: **184 files ok**. - **Merge compatibility**: clean `git merge-tree` against `13f91ca`, `#2680`, and `#2701`; text conflicts with `#2702` (`capture.rs`), `#2673` (`capture.rs`), and `#2732` (`capture.rs`, `host.rs`).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:04 UTC · original

Correct: restricting to D3D12_RTV_DIMENSION_TEXTURE2D (non-array, non-MS) makes subresource == MipSlice exactly, and PlaneSlice==0 keeps planar formats on the first plane. Threading Target{resource,mip} through note_texture/targets/dump keeps the bookkeeping consistent, and nonzero mips land in the filename so sequential dumps don't clobber each other.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#issuecomment-7173162287) Correct: restricting to D3D12_RTV_DIMENSION_TEXTURE2D (non-array, non-MS) makes subresource == MipSlice exactly, and PlaneSlice==0 keeps planar formats on the first plane. Threading Target{resource,mip} through note_texture/targets/dump keeps the bookkeeping consistent, and nonzero mips land in the filename so sequential dumps don't clobber each other.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 20:16 UTC · original

Independent WARP verification: PR head 2cc21c3

Environment: Windows 11, rustc/cargo 1.98.1, debug build, VICTORY_WARP=1 VICTORY_D3D12_WARP=1 (Microsoft WARP only, no physical GPU), Windows SDK 10.0.26100.0 dxil.dll 1.8.2502.11 on PATH. Tested the PR head itself (single commit directly on origin/main 13f91caee2, so identical to the merge tree). All commands cargo ... --locked.

Baseline on origin/main: test -p victory-gpu --lib: 195 passed, 0 failed, 1 ignored. --features diagnostics: 1 failure, memory::tests::a_submission_that_missed_leaves_the_copies_at_once (memory.rs:886), pre-existing and flaky on main (failed 3 of 4 repeated full runs, passes alone). clippy --all-targets --features diagnostics -D warnings: clean.

On this PR:

  • test -p victory-gpu --lib: 195 passed, 0 failed, 1 ignored.
  • test -p victory-gpu --lib --features diagnostics: 199 passed, 0 failed, 1 ignored (+1 new test, which runs on WARP and does not skip).
  • clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings: clean.
  • Negative control: restored draw.rs from origin/main (note_target instead of note_rtv): capture_uses_the_bound_render_target_mip fails; only 2 PNGs are produced instead of the expected 4 (mip 0 and mip 1, at submission and at present), then restored the PR file.

Review: capture targets are now keyed by (resource, mip), and the readback uses GetCopyableFootprints and CopyTextureRegion for that subresource. The mip comes only from an explicit Texture2D RTV with PlaneSlice == 0. dump_one skips a mip beyond MipLevels. Observations, none blocking: array/Texture2DArray views and the array slice are still captured as mip 0 (as before); the file name still shows the mip-0 width and height, with a -mipN suffix. The change is diagnostics-only. Without the diagnostics feature nothing in it compiles in. The test re-runs itself as a child process with env vars.

Not tested: a physical GPU, any retail title or game behavior, a release build, non-Windows targets.

AI disclosure: this verification was run by Claude Code (Claude Sonnet 5.5). No game files, dumps, shader names or retail hashes were used.

**@⁠oni-swr** on GitHub · 2026-11-25 20:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#issuecomment-7173422387) ## Independent WARP verification: PR head `2cc21c3` **Environment:** Windows 11, rustc/cargo 1.98.1, debug build, `VICTORY_WARP=1 VICTORY_D3D12_WARP=1` (Microsoft WARP only, no physical GPU), Windows SDK 10.0.26100.0 `dxil.dll` 1.8.2502.11 on `PATH`. Tested the PR head itself (single commit directly on `origin/main` 13f91caee25f2fdf2c062be5f7a27f058e51cbca, so identical to the merge tree). All commands `cargo ... --locked`. **Baseline on origin/main:** `test -p victory-gpu --lib`: 195 passed, 0 failed, 1 ignored. `--features diagnostics`: 1 failure, `memory::tests::a_submission_that_missed_leaves_the_copies_at_once` (`memory.rs:886`), pre-existing and flaky on main (failed 3 of 4 repeated full runs, passes alone). `clippy --all-targets --features diagnostics -D warnings`: clean. **On this PR:** - `test -p victory-gpu --lib`: 195 passed, 0 failed, 1 ignored. - `test -p victory-gpu --lib --features diagnostics`: 199 passed, 0 failed, 1 ignored (+1 new test, which runs on WARP and does not skip). - `clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings`: clean. - **Negative control:** restored `draw.rs` from origin/main (`note_target` instead of `note_rtv`): `capture_uses_the_bound_render_target_mip` fails; only 2 PNGs are produced instead of the expected 4 (mip 0 and mip 1, at submission and at present), then restored the PR file. **Review:** capture targets are now keyed by (resource, mip), and the readback uses `GetCopyableFootprints` and `CopyTextureRegion` for that subresource. The mip comes only from an explicit Texture2D RTV with `PlaneSlice == 0`. `dump_one` skips a mip beyond `MipLevels`. Observations, none blocking: array/Texture2DArray views and the array slice are still captured as mip 0 (as before); the file name still shows the mip-0 width and height, with a `-mipN` suffix. The change is diagnostics-only. Without the `diagnostics` feature nothing in it compiles in. The test re-runs itself as a child process with env vars. **Not tested:** a physical GPU, any retail title or game behavior, a release build, non-Windows targets. AI disclosure: this verification was run by Claude Code (Claude Sonnet 5.5). No game files, dumps, shader names or retail hashes were used.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:26 UTC · original · edited 2026-11-26 02:17 UTC

Automated triage for the maintainers. This is diagnostics only: crates/victory-gpu/src/capture.rs now keys capture targets by (resource, mip). note_rtv takes the MipSlice from a Texture2D RTV with PlaneSlice == 0, and dump_one reads that subresource back through read_back_subresource, skipping mips past MipLevels. I checked the footprint and copy subresource indices, and that the new test's 4x4/2x2 expectations match the half-size PNG output of save_as.

Update for e5f86c1: thanks, the filename nit is fixed. The only change since the last review is that dump_one names the file with the footprint's f.Width/f.Height instead of the mip-0 size, and the test now asserts the name (-4x4-f28-mip1 / -8x8-f28). Still a merge candidate; it may conflict textually with other open capture PRs (#2702, #2673, #2732). CI: check passing. This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#issuecomment-7177572096) · edited 2026-11-26 02:17 UTC <!-- victory-triage v1 head=e5f86c128ce3165830d23305169bd87d4d5a274f verdict=merge-candidate at=2026-11-26T02:17:40Z --> Automated triage for the maintainers. This is diagnostics only: `crates/victory-gpu/src/capture.rs` now keys capture targets by (resource, mip). `note_rtv` takes the MipSlice from a Texture2D RTV with `PlaneSlice == 0`, and `dump_one` reads that subresource back through `read_back_subresource`, skipping mips past `MipLevels`. I checked the footprint and copy subresource indices, and that the new test's 4x4/2x2 expectations match the half-size PNG output of `save_as`. Update for `e5f86c1`: thanks, the filename nit is fixed. The only change since the last review is that `dump_one` names the file with the footprint's `f.Width`/`f.Height` instead of the mip-0 size, and the test now asserts the name (`-4x4-f28-mip1` / `-8x8-f28`). Still a merge candidate; it may conflict textually with other open capture PRs (#2702, #2673, #2732). CI: `check` passing. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 23:38 UTC · original

The capture filename now uses the selected subresource's dimensions in e5f86c128c. The same synthetic app-local WARP test failed at the old head when it expected -4x4-f28-mip1. At the updated head, all four submission and present PNGs have the expected source labels (8x8 for mip 0, 4x4 for mip 1), half-size IHDR dimensions and distinct pixels.

The full GPU suite reports 199 passed and 1 ignored. Strict GPU Clippy passed with default and all features, and the staged asset policy passed. The updated head merges cleanly with main at 63bcca43c6.

github.com/Marvisak/VIctory@e5f86c128c

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 23:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#issuecomment-7177835004) The capture filename now uses the selected subresource's dimensions in e5f86c128ce3165830d23305169bd87d4d5a274f. The same synthetic app-local WARP test failed at the old head when it expected `-4x4-f28-mip1`. At the updated head, all four submission and present PNGs have the expected source labels (8x8 for mip 0, 4x4 for mip 1), half-size IHDR dimensions and distinct pixels. The full GPU suite reports 199 passed and 1 ignored. Strict GPU Clippy passed with default and all features, and the staged asset policy passed. The updated head merges cleanly with main at 63bcca43c6a00a758510398fa43096ce7e4f7df0. https://github.com/Marvisak/VIctory/commit/e5f86c128ce3165830d23305169bd87d4d5a274f
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 04:10 UTC · original · approved these changes

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):

  • cargo test -p victory-gpu --features diagnostics --lib capture_uses_the_bound_render_target_mip: 1 passed, 0 failed.
  • 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 04:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#pullrequestreview-6068439366) · **approved these changes** Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090): - `cargo test -p victory-gpu --features diagnostics --lib capture_uses_the_bound_render_target_mip`: **1 passed, 0 failed**. - `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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 11:56 UTC · original · approved these changes

Reviewed and verified at head e5f86c12 against origin/main (63bcca43) on Windows 11 (RTX 5090 + WARP, D3D12 Debug Layer):

  • Design & correctness:
    • Scoped cleanly to #[cfg(feature = "diagnostics")] (plus avoiding a duplicate record.desc() call in crates/victory-gpu/src/draw.rs:422-425).
    • note_rtv (crates/victory-gpu/src/capture.rs:293-307) restricts mip extraction to explicit D3D12_RTV_DIMENSION_TEXTURE2D views with PlaneSlice == 0, where the D3D12 subresource index equals MipSlice, while safely falling back to mip 0 for other dimensions, planes, and depth targets.
    • dump_one (capture.rs:555-617) guards target.mip >= u32::from(d.MipLevels) (capture.rs:563), passes subresource = target.mip consistently to both GetCopyableFootprints and CopyTextureRegion in read_back_subresource (capture.rs:135-205), and labels output PNGs with the selected mip's f.Width x f.Height plus -mip{N} for nonzero mips (capture.rs:611-617).
  • Verification:
    • Clean git merge-tree against origin/main (63bcca43); cargo xtask policy (184 files ok); cargo clippy -p victory-gpu --all-targets -- -D warnings clean with default features and --all-features.
    • cargo test -p victory-gpu --features diagnostics --lib resource::tests::capture_uses_the_bound_render_target_mip -- --exact --nocapture: 1/1 passed (bound-mip capture produced 4 PNGs, verifying filenames, IHDR dimensions, and decoded red/green pixels); capture::tests 2/2 passed.
    • Live child-process capture runs with VICTORY_D3D12_DEBUG=1 on both RTX 5090 and WARP (VICTORY_D3D12_WARP=1) exited cleanly with zero debug-layer errors and produced all four expected PNGs (-8x8-f28.png and -4x4-f28-mip1.png at both submission and present).

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 11:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2756#pullrequestreview-6073721560) · **approved these changes** Reviewed and verified at head `e5f86c12` against `origin/main` (`63bcca43`) on Windows 11 (RTX 5090 + WARP, D3D12 Debug Layer): - **Design & correctness**: - Scoped cleanly to `#[cfg(feature = "diagnostics")]` (plus avoiding a duplicate `record.desc()` call in `crates/victory-gpu/src/draw.rs:422-425`). - `note_rtv` (`crates/victory-gpu/src/capture.rs:293-307`) restricts mip extraction to explicit `D3D12_RTV_DIMENSION_TEXTURE2D` views with `PlaneSlice == 0`, where the D3D12 subresource index equals `MipSlice`, while safely falling back to mip 0 for other dimensions, planes, and depth targets. - `dump_one` (`capture.rs:555-617`) guards `target.mip >= u32::from(d.MipLevels)` (`capture.rs:563`), passes `subresource = target.mip` consistently to both `GetCopyableFootprints` and `CopyTextureRegion` in `read_back_subresource` (`capture.rs:135-205`), and labels output PNGs with the selected mip's `f.Width x f.Height` plus `-mip{N}` for nonzero mips (`capture.rs:611-617`). - **Verification**: - Clean `git merge-tree` against `origin/main` (`63bcca43`); `cargo xtask policy` (`184 files ok`); `cargo clippy -p victory-gpu --all-targets -- -D warnings` clean with default features and `--all-features`. - `cargo test -p victory-gpu --features diagnostics --lib resource::tests::capture_uses_the_bound_render_target_mip -- --exact --nocapture`: **1/1 passed** (`bound-mip capture produced 4 PNGs`, verifying filenames, IHDR dimensions, and decoded red/green pixels); `capture::tests` **2/2 passed**. - Live child-process capture runs with `VICTORY_D3D12_DEBUG=1` on both **RTX 5090** and **WARP** (`VICTORY_D3D12_WARP=1`) exited cleanly with zero debug-layer errors and produced all four expected PNGs (`-8x8-f28.png` and `-4x4-f28-mip1.png` at both submission and present). LGTM.
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/2756/head:github-bot/gh-2756'
git switch 'github-bot/gh-2756'

Merge

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