GPU: capture the mip selected by 2D render-target views #2756
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2756
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2756"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 19:45 UTC · original
andrewpozdnakov7-jpg:codex2/capture-bound-mip→main· +177 −23 · 4 files · 2 commits · openSummary
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
13f91ca, both captures contain only the red 4x4 base-mip PNG.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.
@fuzeofficlal on GitHub · 2026-11-25 20:03 UTC · original
Reviewed and verified
2cc21c3con Windows 11 (RTX 5090 + WARP) againstmain(13f91ca).Code review
note_rtvrestricts mip extraction strictly toSome(view)withD3D12_RTV_DIMENSION_TEXTURE2DandPlaneSlice == 0, safely falling back tomip = 0for null RTVs, non-2D/array/MSAA/3D RTVs, non-zero planes, and depth targets (with zero overhead whendiagnosticsis disabled).dump_onebounds-checkstarget.mip >= u32::from(d.MipLevels)beforeread_back_subresource, which passessubresource = target.mipconsistently toGetCopyableFootprints(BaseOffset = 0) andCopyTextureRegion, matchingf.Width/f.Height/f.RowPitchinto_rgba/save_as.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'sf.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 (includingresource::tests::capture_uses_the_bound_render_target_mip).--features diagnostics):capture::tests2/2,draw::tests --test-threads=111/11.cargo clippy -p victory-gpu --all-targets --locked(default and--features diagnostics): 0 warnings;cargo xtask policy: 184 files ok.git merge-treeagainst13f91ca,#2680, and#2701; text conflicts with#2702(capture.rs),#2673(capture.rs), and#2732(capture.rs,host.rs).@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.
@oni-swr on GitHub · 2026-11-25 20:16 UTC · original
Independent WARP verification: PR head
2cc21c3Environment: 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.0dxil.dll1.8.2502.11 onPATH. Tested the PR head itself (single commit directly onorigin/main13f91caee2, so identical to the merge tree). All commandscargo ... --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.draw.rsfrom origin/main (note_targetinstead ofnote_rtv):capture_uses_the_bound_render_target_mipfails; 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
GetCopyableFootprintsandCopyTextureRegionfor that subresource. The mip comes only from an explicit Texture2D RTV withPlaneSlice == 0.dump_oneskips a mip beyondMipLevels. 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-mipNsuffix. The change is diagnostics-only. Without thediagnosticsfeature 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.
@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.rsnow keys capture targets by (resource, mip).note_rtvtakes the MipSlice from a Texture2D RTV withPlaneSlice == 0, anddump_onereads that subresource back throughread_back_subresource, skipping mips pastMipLevels. I checked the footprint and copy subresource indices, and that the new test's 4x4/2x2 expectations match the half-size PNG output ofsave_as.Update for
e5f86c1: thanks, the filename nit is fixed. The only change since the last review is thatdump_onenames the file with the footprint'sf.Width/f.Heightinstead 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:checkpassing. This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
@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@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).
@fuzeofficlal on GitHub · 2026-11-26 11:56 UTC · original · approved these changes
Reviewed and verified at head
e5f86c12againstorigin/main(63bcca43) on Windows 11 (RTX 5090 + WARP, D3D12 Debug Layer):#[cfg(feature = "diagnostics")](plus avoiding a duplicaterecord.desc()call incrates/victory-gpu/src/draw.rs:422-425).note_rtv(crates/victory-gpu/src/capture.rs:293-307) restricts mip extraction to explicitD3D12_RTV_DIMENSION_TEXTURE2Dviews withPlaneSlice == 0, where the D3D12 subresource index equalsMipSlice, while safely falling back to mip 0 for other dimensions, planes, and depth targets.dump_one(capture.rs:555-617) guardstarget.mip >= u32::from(d.MipLevels)(capture.rs:563), passessubresource = target.mipconsistently to bothGetCopyableFootprintsandCopyTextureRegioninread_back_subresource(capture.rs:135-205), and labels output PNGs with the selected mip'sf.Width x f.Heightplus-mip{N}for nonzero mips (capture.rs:611-617).git merge-treeagainstorigin/main(63bcca43);cargo xtask policy(184 files ok);cargo clippy -p victory-gpu --all-targets -- -D warningsclean 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::tests2/2 passed.VICTORY_D3D12_DEBUG=1on both RTX 5090 and WARP (VICTORY_D3D12_WARP=1) exited cleanly with zero debug-layer errors and produced all four expected PNGs (-8x8-f28.pngand-4x4-f28-mip1.pngat both submission and present).LGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.