runtime: forward CopyBufferRegion from a title-backed buffer through a snapshot #3503
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3503
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3501"
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?
@Kawiu on GitHub · 2026-11-29 18:28 UTC · original
Kawiu:runtime/copy-buffer-title-snapshot→main· +115 −11 · 7 files · 5 commits · merged 2026-11-30 19:58 UTCChange
CopyBufferRegionfrom a title-backed buffer that has no desktop copy is skipped astitle_backed_source. A title thatupdates a constant buffer this way keeps the old or empty bytes in the destination.
With the opt-in
X2W_D3D12_TITLE_COPY_SNAPSHOT=1, such a copy of up to 64 KiB reads the source's title memory at recordtime into the snapshot pool and copies from there. Without the switch the behavior is unchanged.
Limits:
they do not see the copied bytes yet. That is a separate follow-up.
run_presets.json.Verification
Commit
b97a694d, Windows 11, AMD Radeon RX 6750 XT (driver 32.0.21045.29003) and WARP, debug layer requested(
X2W_D3D12_DEBUG=1; the test fails on any stored error).13/13 passed.
82/82 passed.
Evidence and follow-up
The new cases in
tests/startup_list_copy.cppare built from the test's own byte pattern. A 128 KiB buffer is placed256 bytes into a
VirtualAllocblock, so it cannot alias.Follow-up: let translated draws read a destination written this way from the desktop buffer.
Checklist
This change was AI-assisted.
@Not-Saii on GitHub · 2026-11-29 20:58 UTC · original · reviewed
The change itself reads well. It's opt-in, limited to buffers of 64 KiB or less, it reads at record time into the upload ring, and it skips the
COPY_SOURCEtransition on the title resource when the ring slice is the source. Overwriting the source after recording is a good way to show it's a record-time snapshot.Two things:
The header comment of
tests/startup_list_copy.cpplost a line break. Item 8 is now glued to the end of 7b:It needs a newline before
// 8..8e doesn't show why it was refused. With the switch off, 8e is refused as
title_backed_sourcebecause the snapshot is never tried. With it on, 8e is refused because 0x10004 bytes is over the cap. Both count as one refusal, so a regression that dropped the 64 KiB cap would still pass with the switch off, and would only fail with it on if the counter changed. Ifstepor the log can check the refusal reason, asserting the reason in snapshot mode would pin the cap. Otherwise, copying 0x10000 bytes (accepted) next to 0x10004 (refused) in snapshot mode would show the boundary.A related note:
title_copy_snapshotprobes withreadable_windowand then callsring_copy(..., true). Until #3471 lands, that copy is a plainmemcpy, so a page decommitted between the probe and the copy would fault, as #3470 describes. Once #3471 merges, this path fails closed like the other snapshot callers.AI-assisted.
@Kawiu on GitHub · 2026-11-29 21:06 UTC · original
Thanks, both fixed in the new commit:
startup_list_copy_title_snapshot_warpand_hardwareboth failed.ctest --preset dev -R "^startup_list_copy": 13/13 passed.Agreed on #3471: this path relies on it for the probe-to-copy window. I have not changed
ring_copyhere.AI-assisted.
@lukaslw-lab on GitHub · 2026-11-30 09:30 UTC · original · reviewed
Reviewed
484fe487by reading the diff; not built or run.Verdict: comment. No MUST: the off path is inert (
enabledis checked first, andsnapshotstays null, so the old transition and source are used). One SHOULD belongs in this PR because it is on the same lines.SHOULD With
mesh_xmem_tracking()on, a snapshotted copy still handsfrom.resourceandsource_offsettonote_mesh_xmem_write(src/startup_stubs/list_copy.inl:271-272). That function records a secondCopyBufferRegionfrom that resource into the lease (mesh_xmem_handoff.inl:296), so:default-uavsource, the title resource never got itsCOPY_SOURCEtransition, because line 252 skips it whensnapshotis set.Before this PR, both cases were refused. Passing the snapshot resource and offset there fixes it. It only happens when both opt-ins are on.
SHOULD Nothing counts or logs a snapshotted copy. It increments
list_buffer_copieslike any other forwarded copy, so a real-title run cannot show whether any copy took this path. One counter, or a first-N log line, would cover it.NIT The comment at
list_copy.inl:214, the docs paragraph and the PR body say "upload ring".ring_copy(..., true)reserves from the separate snapshot pool (128 MiB cap), so theupload_ring_*counters do not include it.Checked, no finding:
check_copy_buffer_regionbounds the range before the snapshot is taken.GENERIC_READupload buffers, so a copy from them needs no transition.Tests:
startup_list_copy_title_snapshot_{warp,hardware}reach the new branch:No test turns on the mesh handoff switches. CI did not run any
startup_list_copy*test, because theprfilter inCMakePresets.jsonleaves them out.@JohnConnorNPC on GitHub · 2026-11-30 17:03 UTC · original
Review of
484fe487(static read plus a trial merge into current main, which has no conflicts; nothing built or run): no MUST.SHOULD
mesh_xmem_trackingon,note_mesh_xmem_writestill receivesfrom.resourceandsource_offsetinstead of the snapshot, so that path records a second copy of the stale bytes. This is the same point lukaslw-lab raised on this head, and it is still open.+ offsetpasses. Add a case with an offset and check the copied bytes.prpreset has nostartup_list_copy, so CI ran none of the new tests.NIT
4. The author email on the second commit is not a noreply address.
AI-assisted.
1b82bb59a0to577a17fd2d@lukaslw-lab on GitHub · 2026-11-30 19:03 UTC · original · approved these changes
Reviewed
c308f362by reading the diff since our review at484fe487; not built or run. The merge of main is clean, and113a764fdiffers from484fe487only in the author email.Verdict: approve. Both SHOULDs from our earlier review are fixed, and the off path stays inert. No MUST.
note_mesh_xmem_writegets the pool chunk and its offset (list_copy.inl:277-278), andsrv_wordaccepts a snapshot source (:266).note_mesh_xmem_writerecords no transition on the source, and the chunk is aGENERIC_READupload buffer. So thedefault-uavcase needs noCOPY_SOURCEtransition either.:252-256), enough to see the path in a real-title run.startup_mesh_title_snapshot_{warp,hardware}reaches the fixed line. The fixture enables the handoff itself. The source sits 256 bytes into aVirtualAllocblock, so its desktop copy is a committed buffer that never received the title bytes (d3d12_xs_device.cpp:6585-6590). The old code leased zeros there, and the test assertsred.source_kindstill names the title resource's kind (buffer/default-uav) (list_copy.inl:272-273). Handoff traces therefore do not show that the lease came from a snapshot.b97a694d. It does not mention the handoff fix, the log line, or the newprfilter entries.Tests: CI ran
startup_list_copy_title_snapshot_warpandstartup_mesh_title_snapshot_warpat this head, both passed (97/97), now that the PR adds them to theprfilter. The_hardwarecases did not run on CI. Thedefault-uav(12-byte mesh arguments) snapshot branch has no test.@Kawiu on GitHub · 2026-11-30 19:05 UTC · original
Thanks for the reviews! I’ve pushed updates addressing the feedback:
The D3D12 debug layer was unavailable locally. GitHub reports three successful checks and two skipped jobs. This change was AI-assisted.