Repository navigation
runtime: forward CopyBufferRegion from a title-backed buffer through a snapshot - #3501
Conversation
…a snapshot Opt-in X2W_D3D12_TITLE_COPY_SNAPSHOT=1. A copy of up to 64 KiB whose source has no desktop copy is read from title memory at record time instead of being skipped as title_backed_source. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Not-Saii
left a comment
There was a problem hiding this comment.
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_SOURCE transition 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:// whose pages are gone, or a range over 64 KiB, is refused either way// 8. after Close, the same calls change no counterIt 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_snapshot probes with readable_window and then calls ring_copy(..., true). Until #3469 lands, that copy is a plain memcpy, so a page decommitted between the probe and the copy would fault, as #3468 describes. Once #3469 merges, this path fails closed like the other snapshot callers.
AI-assisted.
Fix the line break in the header comment of startup_list_copy. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
Thanks, both fixed in the new commit:
Agreed on #3469: this path relies on it for the probe-to-copy window. I have not changed AI-assisted. |
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed 484fe487 by reading the diff; not built or run.
Verdict: comment. No MUST: the off path is inert (enabled is checked first, and snapshot stays 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:- the lease gets the stale desktop bytes while the destination gets the snapshot;
- for the
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.- When the pool is full, the copy is refused as before.
- Pool chunks are
GENERIC_READupload buffers, so a copy from them needs no transition. - The list holds the chunk until its fence, so running a closed list again reads the same bytes.
Tests: startup_list_copy_title_snapshot_{warp,hardware} reach the new branch:
- 8c: the copy is accepted with exact bytes, even after the source is overwritten;
- the two size cases: exactly 64 KiB accepted, 4 bytes more refused;
- 8d: the decommitted source.
No test turns on the mesh handoff switches. CI did not run any startup_list_copy* test, because the pr filter in CMakePresets.json leaves them out.
|
Review of 484fe48 (static read plus a trial merge into current main, which has no conflicts; nothing built or run): no MUST.
SHOULD
NIT AI-assisted. |
Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
1b82bb5 to
577a17f
Compare
Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed c308f362 by reading the diff since our review at 484fe487; not built or run. The merge of main is clean, and 113a764f differs from 484fe487 only in the author email.
Verdict: approve. Both SHOULDs from our earlier review are fixed, and the off path stays inert. No MUST.
- Fixed: the snapshot now reaches the handoff.
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. - Fixed: a log line. The first ten snapshot copies are logged (
:252-256), enough to see the path in a real-title run. - New test, checked.
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. - NIT For a snapshot copy,
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. - NIT The PR body still reports verification at
b97a694d. It does not mention the handoff fix, the log line, or the newprfilter entries.
Tests: CI ran startup_list_copy_title_snapshot_warp and startup_mesh_title_snapshot_warp at this head, both passed (97/97), now that the PR adds them to the pr filter. The _hardware cases did not run on CI. The default-uav (12-byte mesh arguments) snapshot branch has no test.
|
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. |
Change
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 b97a694, 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.