startup: input script waits for the presented picture, marks, relative times and groups #1970
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1977"
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 rasptum on 2026-11-24T22:28:31Z.
Depends on the input-script holds/axes PR (
startup/input-script-holds-axes); this branch is stacked on it.Fixed script times drift when a run gets slower or faster, so presses land on the wrong screen. This adds:
wait[=<settle>[/<timeout>[/stop|/go]]]waits until the presented picture changes and then stays unchangedfor
<settle>s (default 1). After<timeout>s (default 120) it logs a timeout and goes on or stops.mark[=<label>]logs the script time and the present number.@+<s>on any timed item:<s>seconds after the previous timed item started, or after a wait completed.;:cells=<n>(default 16),level=<n>(default 12),region=<x0>:<y0>:<x1>:<y1>(fractions of the picture), andfine(a 64 x 72 grid instead of 32 x 18).group[=<label>] ... end: when a wait inside a group times out, the rest of the group is skipped and thescript goes on after
end, timed from the timeout.Example:
wait,80@+2,4@+0.5waits for a new screen, pauses 2 s, presses down, pauses 0.5 s and presses accept.The signal comes from the D3D12 stand-in in render mode. Every 4 presents it copies 18 one-texel rows of the
presented surface without waiting, reduces them to 32 x 18 cells of mean luma, and publishes them in
Local\x2w_present_signature_<pid>. On request it also copies 72 more rows for the 64 x 72 grid. There is nofull-resolution readback per frame. Measured on WARP at 3840 x 2160, release, CPU side: 0.16 ms per sampled
present with the default grid and 0.56 ms with the fine one. A 1 % bar between two default rows changes 0
default cells and 40 fine cells. Without a presenter, waits time out and the log says so. Waits and marks
count toward the 256-entry limit with presses;
base,groupandenddo not.Scripts without the new items play exactly as before.
Test:
Result in dev and release: 10/10 passed, 0 skipped. Negative controls, applied locally, each fail their
checks: entries released before their wait resolves; unstable cells from the sampler; the region ignored;
per-wait cells ignored; group skips disabled; fine rows never copied.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T22:42:58Z.
Review: CHANGES_REQUESTED
The sampler records a copy using the raw source surface and returns before the copy fence. It holds the allocator, list and readback buffer, but never holds the surface. A guest can release or replace the surface immediately after Present. D3D12 command-list calls do not retain resources. Hold the source through completion, and define how it is retired if Signal fails after submission. Add a source-built control which stalls the GPU queue, releases the caller's reference after Present, then unblocks the queue and verifies the signature with the debug layer enabled. Also keep signature sampling opt-in for runs without a picture wait, since the current default records extra GPU submissions on ordinary render runs. D3D12 command-list reference counting
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T23:29:18Z.
Review: APPROVED
The revised sampler retains the source through the copy fence and stops safely if a submitted copy cannot be fenced. Ordinary runs do not sample until requested. Release passed the six GameInput and WARP checks, including the held-source and unheld-source controls.
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-24T23:04:14Z.
Thanks, all three points are addressed in
2a898640, which is rebased on current main.1. Source lifetime.
AddRefs the presented surface just beforeExecuteCommandListsand releasesit once the copy's fence has passed.
Signalfails after submission, there is no fence that can show when the copy ends. In thatcase the sampler is marked stranded and stops sampling. The surface, allocator, list and readback
buffer stay referenced for the rest of the process. The presenter's sampler is never destroyed,
and the log says
x2w-present picture signature: Signal failed after a copy was submitted; sampling stopped, its surface stays referenced.finished by then, it releases nothing the copy may still use.
2. Source-built control. This is
startup_present_signature_held_source_warp, which runs withthe debug layer on:
Waits on an unsignalled fence, and the sampler records its row copy behind it.sampler's, is left. The fence is then signalled from the CPU.
must drop its reference after the fence, and the info queue must hold no error or corruption
message.
Signalfails, and requires the strandedsampler to keep the surface.
The negative control is
startup_present_signature_unheld_source_control_warp. It runs the samestall with a plain copy that does not hold its source, and passes only when the debug layer reports
OBJECT_DELETED_WHILE_STILL_IN_USE. As a mutant, removing the sampler'sAddRefmakes theheld-source check crash with an access violation.
3. Opt-in.
sampling_wantedfield at +0x1478. The GameInput stand-in sets itonly for scripts with at least one
wait, and logsx2w-input script: picture signature requested.GPU objects and submits nothing.
X2W_PRESENT_SIGNATURE_EVERY=<n>still samples from the start without a request, and0turnsthe signature off.
always = falsecreates nothing until the block asks. A newmarks_onlycase (negative control) shows that a script without a wait never sets the request.
Command, run in dev and release (12/12 passed in each, no skips):
AI-assisted (Claude Code).