Repository navigation
startup: copy compute input snapshots after the output checks - #3481
Conversation
Not-Saii
left a comment
There was a problem hiding this comment.
I read this against main, and the deferral looks correct:
- pending views carry no resource and so can't alias an output or the indirect argument;
- the counters and the "comes from" log line keep their old scope (raw inputs only, with source 1 still logged);
- the typed path's whole-element check moves to the point where the real pool offset is known.
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 FirstElement update would still pass. Two ways to pin it:
- record a second snapshot dispatch, or a null input first, in the same process, so the checked slice starts at a non-zero offset;
- add a mutation that leaves
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 described branch 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. main has 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.
|
New head 9f3068b covers the three points:
Mutations, each alone, on WARP and hardware: binding the pending offset fails at
|
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed 9f3068b2 by 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.
- Callers: only
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. - After the copy: the only refusals between the deferred loop (
: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. - Source 1 views pass through the new loop only to keep their alignment check and "comes from" line. Source 0
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 the pr preset's list, and /O2 was skipped on the PR. The author's WARP and hardware runs are the only ones at this head.
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