startup: copy compute input snapshots after the output checks #3481
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3481"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T17:14:19Z.
Fixes #3479.
What changes
On
main(c4b8a41b),indirect_table_buffercopies a compute input that lives only in guest memory into the snapshot pool as soon as the input is resolved, and reserves the 16 zero bytes of a null input at the same point. The dispatch's outputs are checked afterwards, so a dispatch refused on an output has already used pool bytes.With this change:
indirect_table_bufferreturns a pending view for these two cases (source 2: guest address and size, no resource; source 3: 16 bytes, no resource). The guest range is still checked for readability there.record_translated_dispatchdoes the copy and the null reservation after the output, heap SRV and indirect-argument checks have passed. It is the same recording call, still underdraw_lock. Readability is checked again just before the copy.FirstElementis set from the actual pool offset once the copy is done. The descriptor size check stays where it was.compute_inputs_snapshotandcompute_inputs_snapshot_kibadvance afterDispatch/ExecuteIndirectis recorded, for the same inputs as before (raw, source 2). A refused dispatch no longer counts.x2w_d3d12_snapshot_pool_used()in the shim (sum ofusedover the snapshot chunks, underallocator_lock), used by the fixture.Only the two callers that allow snapshots, both in
record_translated_dispatch, can receive a pending view.The copy happens later in the call than before, so the interval in which another guest thread can write the range before it is copied is slightly longer. Nothing in the recording call writes guest memory in between.
Refusal order
Refusal texts are unchanged. Which refusal is reported first changes for a dispatch that has two refusals at once:
Tests
New
startup_compute_snapshot_order_{warp,hardware}: one synthetic translated dispatch whose input is only in guest memory, sampled withx2w_d3d12_snapshot_pool_used()before and after recording.main, 0 bytes.Both pass on WARP and on hardware.
9 passed, 0 failed.
Skipped, reported separately:
startup_compute_typed_buffer_srv_warpexits 77 because WARP here lacks SM 6.6 with 32-lane waves. The hardware variant passes.Mutations, against
startup_compute_snapshot_order_warp:ring_copyput back inindirect_table_buffer: fails (refused dispatch uses 1,536 bytes);Merges cleanly with #3469, #3466 and #3480.
Not covered
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T20:58:39Z.
Review: COMMENTED
I read this against
main, and the deferral looks correct:One gap in the test. In
startup_compute_snapshot_order_check.py, the accepted dispatch is the first snapshot in a fresh process, so its pool slice probably starts at offset 0. The new code that matters most is the part that uses the actual slice:view.offsetfrom the deferredring_copy;FirstElement = view.offset / elementfor a typed input.At offset 0, a mutant that kept the pending offset (0) or skipped the
FirstElementupdate would still pass. Two ways to pin it:FirstElementat 0, and one that binds the pending offset, and show both fail.A typed-input variant of the accepted case would also cover the
describedbranch of the deferred loop, which the raw-only cases don't reach.A minor, pre-existing point that this PR makes visible: the pool hands out slices aligned to 512 bytes, so a 3-channel typed input (12-byte elements) is refused with "does not start at a whole element" unless its slice starts at a multiple of 1,536.
mainhas the same behaviour with the eager copy, so it's not a regression. Now that the check runs after the copy, it may be worth a comment.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T21:20:20Z.
New head
9f3068b2covers the three points:FirstElement384); pool use is asserted as1536 -> 3072.FirstElement128) reaches thedescribedbranch of the deferred loop; the input words encode their pool position, so the readback shows where the view began.d3d12_compute_dispatch.inlhas a comment on the 512-byte slice alignment and the 1536-byte multiple for 12-byte elements. No behaviour change.Mutations, each alone, on WARP and hardware: binding the pending offset fails at
startup_compute_snapshot_order_check.py:83(word 0 read 01234567, expected ea74e376); leavingFirstElementat 0 fails at:106(word 0 read 00000000, expected 00000600).ctest -R '^(startup_compute_snapshot_order|startup_compute_dispatch_input|startup_compute_d16_sample_srv_)': 7 run, 6 passed,d16_sample_srv_warpskipped for capability.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T08:31:17Z.
Review: APPROVED
Reviewed
9f3068b2by reading the diff; not built or run.Verdict: approve. The deferral is contained to the one function that can receive a pending view, and the body's list of what still uses pool bytes is exact. No MUST.
d3d12_compute_dispatch.inl:221(insidetyped_dword_input_view, called only at:1023) and:1034passallow_title_snapshot = true. Both are inrecord_translated_dispatch. The result-word path (:1234), the draw path and native mesh57 keep the default, so they never see a null-resource view. #3506's head adds no snapshot caller either.record_translated_dispatchis reached only from the guest list's Dispatch and ExecuteIndirect entry points (d3d12_xs_device.cpp:4113,:4845), so the later copy stays on the recording thread underdraw_lock.:1248) andDispatch(:1392) are "a formatted input has no word 3" (:1300) and "an input texture could not be uploaded" (:1314). That matches "Not covered", and the counters skip both because they advance afterDispatch.continues, so the old log scope is kept.Tests:
startup_compute_snapshot_order_{warp,hardware}reach the deferred copy, the null reservation, both binding paths at a non-zero offset, and three refusals at zero pool use. CI did not run them: they are not in theprpreset's list, and/O2was skipped on the PR. The author's WARP and hardware runs are the only ones at this head.