Repository navigation
Conversation
A title lays a render target out linearly in its memory when its CPU reads it, as a photo it encodes to an image file. The host copy was the target's only picture, so the memory under it stayed zero and such photos were saved black. Draws into such a target now mark it written, and texback copies it back when the list closes. LEONIDA_TARGET_BACK_LINEAR=0 turns it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent GPU readback of synthetic linear render targets at With the PR’s default setting, both linear layouts ( The fixture covers selection and the production close, copy, and landing path after explicit write registration. MEASURED with synthetic textures. AI-assisted (Codex). |
KelboLive
left a comment
There was a problem hiding this comment.
Tested 8c8ae9b4: 634 lib tests pass including the new predicate test, forcing the RENDER_TARGET guard makes it fail, clippy keeps only the four pre-existing warnings, and merge-tree against current main is clean. The hook is right: targets are !fills (resource.rs:1884-1888), so the host copy is the only picture, and close-time registration (draw.rs:3063 → host.rs:8878, :9295) runs after the list's resolves with one back_wanted entry per owner, so there is no double copy.
Two scope issues:
linear_target_descacceptsmip_levels > 1/depth_or_array_size > 1(resource.rs:3959), whiletexture_writtenmarks every subresource (host.rs:9265,texback.rs:164) and non-copy tickets write the whole allocation (texback.rs:496-500). For a mip chain or array, that copies back mips/slices no draw touched, from a host copy that was never uploaded (targets are!fills). Please restrict it to the RTV's subresource, or at least single-mip/single-slice.- A linear target written only by
ResolveSubresourceis still uncovered.texture_copiedis gated ontitle_written(texture.rs:1290-1294), which is false when the target flag is set, so an MSAA→linear-photo resolve stays black. Is the measured photo path a direct draw? A synthetic resolve fixture would settle it — and would also cover the case where an earlier list's whole-target copy-back lands pre-resolve pixels.
Minor: texback.rs:71 is over rustfmt width.
The in-tree test only checks the predicate plumbing — not wanted(), the toggle, or the copy/land path — so the end-to-end claim still rests on the author's and the independent commenter's runs. No conflict with current main; resource.rs overlaps #2908/#2765/#2658 only outside these hunks.
Claimed in the coordination issue as: D3D12-LINEAR-TARGETS-BACK (#2570 (comment))
What and why
A title lays a render target out linearly in its memory (layout 1, or
0x100 |the linear swizzle mode) when its CPU reads what is drawn there, for example a photo it encodes to an image file from that memory. On the D3D12 runtime the host texture was the target's only picture: nothing copied it back, so the memory under it stayed zero and such photos were saved black.This PR:
resource::linear_target(linear_target_descfor the description): a 2D, single-sample texture with the render-target flag in a linear layout;texback::wantedalso take such targets, so the existing copy-back path (texback) returns them to title memory when the list closes;draw.rs(list.texture_written), so the copy-back sees draws into it;LEONIDA_TARGET_BACK_LINEAR=0to turn it off (as before).Targets in the library's own tiled layouts, MSAA targets and textures without the target flag are unchanged.
Tested
Played on Windows 11, RTX 5070 12 GB, NVIDIA 621.01. D3D12 runtime, diag build, Series X profile.
cargo test -p leonida-gpu --lib: 634 passed (new testresource::tests::only_linear_render_targets_go_back).cargo clippy -p leonida-gpu --all-targets -- -D warnings: nothing in the changed lines (the four lints it reports are inmainalready:host.rs,pipeline/host.rs,pipeline/known.rs).python -I scripts/check_no_game_data.pyon the three files: clean.GPUs tested: NVIDIA GeForce RTX 5070 12 GB, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code)
🤖 Generated with Claude Code