feat(agc): read frame capture deltas with the title's work in flight #15136
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15136"
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 boykopovar/AnyPS5. Originally posted by thuanquang on 2026-11-02T17:54:16Z.
Commits to review, oldest first. Only these 11 commits are this PR.
4cd4bc371aand everything below it is #12568 as its branch carries it, with its merges ofmain(#11435 and #11436 are not below it; #12318, #12567 and #14137 have merged intomain); the head merges intomain6711907d65without conflicts. The diff of the 11 commits alone:4cd4bc371a...7028c55d7e.2e523f3de0fix(agc): record a frame capture call with the serials it was made atfcf7c96a3efeat(agc): attribute driver stores into guest memory to the submission that makes them5b2c3473fafeat(agc): read a frame capture delta with the title's work in flight when nothing in flight can store into it5d89819712feat(agc): hold a frame capture delta for unwatched memory only after a driver store into it97a7cd7099fix(agc): keep a frame replay from applying a later memory delta early to release a REWINDbbbf52881efeat(agc): split frame capture hold reasons by wait kind and store age96602bde14fix(agc): record the serial each frame capture call took and check it in the replayf76854fd53fix(agc): hold a frame capture delta that a driver store reached between its hold check and its armb3754e8c4afix(agc): forget a frame capture's record of an unwatched page once a delta lists it while watched12da997d2ftest(agc): pin frame capture reads in flight, held re-collects, store owners and the last thread7028c55d7efix(agc): release the waits a frame replay still parks on at a delta its capture read with nothing in flight4cd4bc371ais #12568's head: its commits7d87265d66(an unchanged delta stored once, with the testsection_once),87111995ecandcf368d991c, then merges ofmainup to2f8c843691, which bringb3dcad85ac(guest calls pass a frame recorder waiting for its trigger). Ate0df5b76d8chitters2004 took our parked-wait compare (8fe56be720, which made #12568's calls format 3) and mergedmaindff7484fd1. Format 3 being taken, this PR's calls format is now 4 (see Format version). The 11 commits add about 830 lines to the driver, 260 to the replay tool and 2,870 lines of tests. BUILD.md and the debt file are complete only at commit 7: commits 4, 5 and 7 also document parts of commits 2 and 3. This stays a draft until #12568 settles; I restack whenever its head moves and update this list each time.This push (since
4c25e67185).4cd4bc371a, replacing the previous push's own merge ofmain. Its merge ofmainbringsb3dcad85ac, which also changesFrameRecorder::record: commit 7 now keeps that change's early path (a call made while the recorder waits for its trigger accepts without the lock) and adds its accepted-serial check after it. Commits 2 and 3 differ from the previous push only in hunk context; the others are the same patches.7028c55d7e: build;main's newagc_driver_frame_capture_waitingandagc_driver_frame_capture_startup10 of 10 runs each at commit 7 and at the head; the fourheld_*modes,wait_unwatched_reset,section_once,unwatched_in_flight,wait_before_readand the recorder rowsagc_bda_staging,agc_bda_staging_bound,agc_recorder_title_call_closure,agc_recorder_storage_writer,agc_recorder_completion_labels3 of 3 runs (14 tests); the frame set 117/117, and the same set under the validation layer 117/117 with the layer inserted and 0VUID-lines.reserveOutputsmust also visitMEM_SEMAPHORE(0x39), which this PR'snoteHeldAtSubmitregisters;semaphore_after_readfails otherwise.What
Frame captures from #12568's stack read each memory delta only after the submissions already accepted have completed, or every busy queue is parked on a wait for a title store. A paced replay therefore runs the captured frames with nothing in flight at those points. This PR lets the recorder read a delta while submissions are still in flight when none of the hold reasons below applies. Before it restores such a delta, the replay waits until the submissions that had started at the read have completed. To make this checkable, each recorded call carries the serials the driver had when the call entered it. Each submission, flip and suspend point also records the serial it took, and driver stores into guest memory carry the serial of the submission that made them. A driver store reported into such a delta's page after the read stops the capture when it comes from a submission accepted by the time of the read, or has no serial. The replay refuses a capture whose deltas read in flight were not checked.
Persona 5 Royal (PPSA05110): no change yet. A 20-frame gameplay capture made with an earlier revision of these changes (
02132ba69e) read no delta in flight. It recorded 120 submits: 100 with one submission in flight and 20 with none (submit_depths), so no submit was made with more than one submission in flight. All 120 deltas made with work in flight were held. Each was held for an unfinished label and for a dword in the delta that a submission waits on (wait_dword_in_delta), and 119 also for a page the driver had stored into. The capture also counted 56,540 driver stores with no serial (unattributed_stores). Any of them that lands in a page of a delta read in flight would stop the capture. A paced--strictreplay of that capture on the same build matched its reference images exactly (pixels_identical1.000000,max_channel_diff0, no pacing timeout). So this PR is the correctness layer that later timing work needs; it does not make replays faster or deeper on this title. A later 10-frame capture of the casino escape, made with the previous push plus nine local commits that port #14137's tracker change and other capture fixes (b18ca951c1), read 1 delta in flight and held 59, withstale_delta0,unverified_deltas0 and 10unattributed_stores. No capture has been made with this head yet.Capture
Driver stores into guest memory carry the serial of the submission that made them (
GuestMemory::StoreSerialScope):A title call's own stores carry a reserved title-call serial. A completion that a title call registered, a write-back that includes a unit a title call marked, and a store on a thread where none of these scopes is set report 0, which the recorder treats as unknown. While a capture runs, an observer passes each store and its serial to the recorder.
Each recorded submission, flip, suspend point and EOP flip reservation carries the accepted and completed serials the driver had when the call entered it, before its delta. A submission, flip or suspend point also records the serial it took (0 for a CPU flip that took none). A submission or suspend point that does not move the accepted serial by exactly one, or a flip that moves it by more than one, stops the capture.
capture.jsoncounts the submissions in flight at each recorded submit (submit_depths) and at each delta read in flight (read_depths).A delta is read with submissions in flight unless one of these holds it. A held delta is read as before, after the queues settle.
WAIT_REG_MEM,WAIT_REG_MEM_64or REWIND wait. AMEM_SEMAPHOREwait never counts as parked.DrawFinisher::AnyPendingOverlaps): the recorder asks from the title's thread, and before this push only a thread that hands the finisher work saw them.WAIT_REG_MEM,WAIT_REG_MEM_64,MEM_SEMAPHOREor REWIND wait on title memory that no unfinished label satisfies: its own last label ahead of the wait, else the last label on that dword of the newest unfinished submission before it on its queue that has one, or a label on another queue, with a value fixed at submit that the wait accepts. AMEM_SEMAPHOREcounts no label, and a REWIND only another queue's label that sets its valid bit. The rule is applied when the delta is read.These reasons do not cover every store a started submission can still make, such as a copy queued behind its labels. A reported store of that kind is caught by the stop below, as
in_flight_storetests. The label rule does not see a store over a counted label before the wait reads it (debt [Title waits in frame capture deltas]); a delta read in flight on such a wait makes the paced replay throw at its gate, or the capture counts it inunverified_deltas. Waits are registered at submit while a capture runs. With work in flight, an unwatched block whose bytes still equal its last record, and that took no reported driver store since, is left out of the delta; one whose bytes changed is judged like a watched page. A shader delta that writes a host page updates that record too.capture.jsoncounts each reason that applied (hold_reasons,hold_masks, with four keys that split parked waits, driver stores and title waits further), and per unwatched block how often it changed or took a driver store (unwatched_blocks).The record of a delta read in flight carries
InFlightDeltaFlagand lists the submissions that had started. Such a read is recorded even when it wrote no bytes.While it records a call, the recorder holds the queue worker at its next packet and the draw committer and finisher at their next item. So the driver's threads start no new packet or item while the delta is collected, read and compressed. GPU work already submitted, a packet already executing and completions keep running. A delta that has to wait for the queues releases them first. The last delta of the capture is read the same way.
A store the driver reports into a page of a delta read in flight, from a submission accepted by the time of that read or with no serial, stops the capture (
stale_delta). The check starts when the delta's pages are armed, right before the read; a store reported between the hold check and the arm holds the delta instead (above). A title call's own stores land before the call returns and are exempt.After the last frame, and at any stop that is not such a store, the recorder waits up to 10 s for the submissions those deltas depend on to complete, waits for the GPU, flushes pending GPU writes over their pages and checks them the same way. If that wait times out,
capture.jsoncounts the deltas it could not check (unverified_deltas).capture.jsonalso addsin_flight_deltas,held_deltasandunattributed_stores. Its magic becomesaps5-frame-capture 2; nothing checks that magic.Two driver exports are added:
AgcDriverSerialDone_nid_postfix, which the replay's gate uses, andAgcDriverQueuedSerials_nid_postfix, which only the tests call.Replay
capture.jsonor with a nonzerostale_delta. This includes a capture with no delta read in flight: one cut short by a kill or a crash has nocapture.json, so it is refused where the stack's tool replays its complete records. The tool still prints its "replaying the complete records" notice first. A capture with deltas read in flight is also refused whenstale_deltaorunverified_deltasis missing, orunverified_deltasis nonzero. A capture of the previous format withoutcapture.jsonis still accepted.--pace-timeout-ms, or after 10 minutes. A serial that differs from the capture's in any other way also throws, as does such a delta after a second thread's first call, or one that lists a serial no call since the frame start recorded.97284fe586); a capture of the previous format keeps it. A REWIND whose control word only a later delta sets stays blocked until that delta's own call. The first call paced behind it waits out--pace-timeout-ms, which releases nothing, and with--strictthe replay fails. Other waits are still released with an earlier recorded value, or with a value derived from the reference, which #12567'sfence_reuseneeds.4ef54b694cin #12567 took that list out to keep the warning's earlier text. This PR puts it back because it shows which wait a stalled replay of the current format is blocked on, such as a REWIND above. The text before it is unchanged.memory_held_wait_sandmemory_in_flight_wait_s(both insidepace_wait_s),restore_s, andin_flight_maxandin_flight_mean: the submissions in flight after each submit's pacing gate, from passes 2 to n with--repeat n.main'sconcurrenttest (#11197) now also accepts a memory delta flagged as read in flight: before the copier thread's first call, such a delta can be read while the copies run.Format version. Calls format 4 (
aps5-frame-calls 4,InFlightCallsVersion) changes three things against format 3. A call's accepted and completed serials are read when it enters, before its delta. A submission, flip or suspend point appends the serial it took. A delta read in flight carriesInFlightDeltaFlagand lists, after its group, the serials of the submissions that had started, in place of the parked waits a held delta lists. The replay compares a capture's format withInFlightCallsVersionat its checks. Formats 2 (#14137) and 3 (#12568's parked-wait records) keep their replay rules, apart from the empty command buffer described under Replay, and a format 2 or 3 capture that marks a delta read in flight is refused before any restore. Format 1 is still refused.Outside a capture these hooks stay on; their cost was not measured:
OnCompleteandAfterRecordedWorkwith a nonzero serial, one load of the store observer;AfterCompletionsaction and per batch finish, one scope;No new lock is taken.
Docs and debt. BUILD.md describes the in-flight read, its hold reasons and which unfinished labels satisfy a title wait, the stops, the replay's gate with its CPU-flip rules and the empty first command buffer, and the refusals. The debt file updates [Frame capture deltas] and [Frame replay pacing]. It adds [REWIND waits in frame replays], [Title waits in frame capture deltas], [Unwatched blocks in frame capture deltas], [Stores into frame capture deltas read in flight] and [Serials of frame replay calls]. The [Title waits ...] entry names the stores over a counted label that the rule does not see. The [Stores into ...] entry names the kinds of driver store for which it has not been checked whether they are reported with their writer. One that is not reported at all, and lands in a page of a delta read in flight after the read, is overwritten by the replay's restore. The longest new entry, [Serials ...], has 998 characters.
New tests. Each is
agc_driver_frame_replay_<mode>unless named otherwise. There are 44.Capture modes record frames through the driver, then replay them, except the two that say they run no replay. The title's work runs behind a long run of
WRITE_DATAlabels, so that it is still in flight at the title's next call.in_flight_delta: while the busy submission runs, the title stores a page and submits a copy of it. The delta of that call must be flagged as read in flight and counted at depth 1 inread_depths. The test takes a suspend point right after the flip that starts the capture; each submission and the suspend point must record the serial after the accepted one, both recorded flips must record the serial they took, and the replay must copy the stored page.in_flight_store: a copy queued behind the busy labels stores into a page that the title then writes and a delta reads in flight. The capture must stop on that page (stale_delta), and the replay must refuse it.in_flight_gate: a submission copies X to Y between two runs of labels and writes a label after the copy. The title waits for that label, overwrites X and makes a call. The delta must list the submission as started, and the replay must dump the old X from Y, so a gate that waits for the wrong submission, or for none, fails.late_store: in a one-frame capture, the last copy, behind the busy labels, lands after the last flip in a page of a delta read in flight. The end of the capture must find it (stale_deltaorunverified_deltas), and the replay must refuse the capture. It skips as inconclusive unless the capture recorded its end with the copy still pending, so only the end check can find the store.late_wait: in a one-frame capture, the last submission, accepted after a delta read in flight, waits on a title dword that the title stores only after its last flip returns. The end-of-capture check must still verify that delta (unverified_deltas0), and the replay must accept the capture.wait_after_read,wait64_after_read,rewind_after_read: a started submission still has to pass aWAIT_REG_MEM,WAIT_REG_MEM_64or REWIND wait on a title flag when the title writes the copy's source and makes its next call. No delta may be read in flight with that submission listed,awaits_titleandtitle_wait_unpassedmust be counted, and a replay with--no-releasemust copy the title's store.wait_labelled_after,wait_labelled_before,wait_labelled_skipped,wait_labelled_elsewhere: the same, but the flag also gets a label that must not count: behind the wait, ahead of it with a value the wait rejects, ahead of it under aCOND_EXECthat skips it, or in a compute submission in flight with a value the wait rejects. The delta of the title's next call must still be held and counted astitle_wait_unpassed.wait_labelled_afterreplays with the default release, since its label rewrites the flag before the next delta reads it.wait_labelled_rewind,wait_labelled_rewind_chain: the wait sits in a REWIND tail, and the flag's newest label ahead of it stores a value the wait rejects: inwait_labelled_rewindthe submission's label before its REWIND, inwait_labelled_rewind_chain(wait in the second tail) the first tail's label, which follows the submission's label of an accepted value. The queue's previous submission, which stored the accepted value, keeps its label record until the title's next call has returned. The delta read at that call must counttitle_wait_unpassed, and the strict replay must copy the title's store only after the wait passes.semaphore_after_read: the same withMEM_SEMAPHORE, signalled by a second thread once the submission has reached its wait. No delta may be read in flight with that submission listed andawaits_titlemust be counted, but nottitle_wait_unpassed, since the signal may come before that read. The capture must not stop. This mode runs no replay.wait_before_read: the submission has passed its wait on the title's flag but is still running when the title makes its next call. The delta holds the flag's page, so it must be held (awaits_title), and the replay must copy the title's store.unwatched_in_flight: an unwatched block that nothing changed and that holds no awaited dword does not hold a delta read with the busy submission in flight: that delta is read in flight, nounwatchedhold is counted, the block's counters show no change and no driver store, and the replay must restore the page the title wrote.unwatched_restored: the busy submission stores into an unwatched block, and the title writes the recorded bytes back. The call must be recorded with the busy submission in flight, its delta must be held forunwatched, and the replay must keep the title's bytes.wait_unwatched_reset: a submission waits on a flag in an unwatched block; the title stores the release value, the submission passes, the title writes the recorded value back and makes its next call while the submission still runs. The block's counters must show no change and no driver store, no delta may be read in flight with that submission listed,awaits_titlemust be counted, and the replay (with release on: no delta holds the release value) must copy the title's store.unwatched_rewatched(registered on Windows only; elsewhereRewatchnotes nothing, so a block cannot return to the write watch): an unwatched block is recorded with A, rewatched, stored B and listed, then, with a busy submission running, stored A again and unwatched. The next delta read in flight must hold A at the block; the test skips as inconclusive when that delta was held.host_page_restored: while a submission waits on the title's flag, a shader delta writes a host-range page that the title changed, and the title then writes back the bytes that the full delta before the shader delta recorded. The capture must hold those bytes at the next full delta, made with the submission in flight. It has no timing precondition and no inconclusive skip. This mode runs no replay; it checks the captured chunks.hold_diagnostics: deltas are read while a queue parks on a title gate, a submission queues behind it, and a compute queue parks on a label that a graphics submission writes. Each reason must be counted (parked,queued,parked_on_title,driver_pagewith and withoutdriver_page_since_full,title_wait_unpassed,wait_dword_in_delta), along with the unwatched block counters and the replay'sin_flight_max.flip_serial_start(in a build without the timing log; it skips in one with it): two CPU flips from a thread without graphics submissions after the driver accepted submissions, so the second takes no serial, then a delta read in flight behind a busy submission. The replay must reproduce the copy and, by the driver's accepted-serial trace (APS5_TRACE_GPU), take as many serials for CPU flips as the capture's flips did.in_flight_once: the title stores page x while the busy submission runs and makes a call, whose delta is read in flight; after the driver went idle it stores page y and makes another call. x must be in that in-flight delta's group only and y only in the idle delta read before the call that copies it, withstale_delta0 andunverified_deltas0, and the replay must copy both pages. Pins that a read in flight moves its ranges' marks past what it read.held_concurrent_store: a submission queued behind the busy one holds the delta at the title's call (queued); the title stores a watched page w before the call, and a second thread that makes no driver calls stores page z once the title's call waits for the queues to settle (seen through the driver's idle-waiter count). w and z must both be in the held delta's group and z in no later group. Pins the second collect after the settle (commit 3).owner_lifetime: a page read in flight by delta D, then an idle delta that does not list it, then a driver store with no serial into it: the capture must stop withstale_delta= D.owner_lifetime_rewritten: the title stores the page again before the idle delta, which lists it and frees D's owner, so the same store leavesstale_delta0. Pins the owner release rule; the base mode pins the stricter contract that a store with no serial long after D's work still stops the capture.empty_in_flight_read: every word of the page a delta reads in flight already holds a noted GPU word, so the read writes no bytes; the delta must still be recorded (flagged, no chunk for its group), and a later store into the page by the submission in flight must stop the capture naming that group. The GPU words are noted through the driver's label-store note (DriverTestAccess::NoteLabelStore), since no real store sequence reaches this read without a driver page store holding the delta first.shader_in_flight: a shader registration while the busy submission runs, with a page of the shader's 64 KiB block stored before it: its shader delta is read in flight (flagged, with the started submission) and holds the page; a second registration with nothing stored records no memory delta; the next full delta lists the page once more (shader deltas do not move the ranges' marks) and the page beside it, and no other delta holds them.last_thread_hold: a submission whose REWIND tail is released before it is submitted flips the capture's last frame while 20,000 labels behind it still run, and a second thread that has made no recorded call reaches that frame boundary first (its submit callsRewindTailFlipsbefore the recorder records it), sofinish()runs on that thread with work in flight. The last delta must be held (threadscounted), not read in flight, and the replay must accept the capture. Pinsfinish()counting its own thread (commit 3).Most capture modes skip as inconclusive (exit 77) when the title's work finishes, or reaches its wait, before the title's next call.
Without a capture:
carried_label(withAPS5_PIPELINED_DRAWS=0) installs a driver-store observer of its own. A queue-0 label that a submission queued, and that the next, already queued submission stores because the first one's end flush was skipped, must be reported under the serial of the submission that queued it, and the next submission's own label under that submission's serial.agc_driver_draw_finisher_overlap(withAPS5_DRAW_PIPELINE=1): a thread that hands the draw finisher no work must see, throughDrawPipeline::OverlapsAny, a write the finisher still holds, and not a range beside it.Replay modes run the replay in-process on synthetic captures:
gate_failure: a driver failure reported once a submission parked on an unwritten label, while the gate of a delta read in flight waits for it, must end the gate with that error, and shutdown must rethrow it.gate_settled: the same gate with no failure must end with the "no queue runs" error before its time limit, and must not restore the delta.held_drained_release: a submission parked on a flag that a held delta records as 0, the delta's record showing as many submissions completed as accepted, a submission queued behind the waiter, and a delta read in flight listing that one. The replay must finish; the waiter must copy the source the held delta restored (released after the first apply), the delta must be applied again (out3, flag 0), andof_them_at_deltas,of_them_synthesizedandpark_restoresmust each be 1.held_parked_no_release: the same, but the held delta's record shows the waiter in flight, parked on a value the replay never parks on, so only that record keeps the replay from releasing: the gate must end with the "no queue runs" error and restore nothing.held_drained_no_release: the first mode with--no-release: the gate must end as before.held_shader_no_release: no release at a delta followed by a shader registration or any of the three ABI resolutions, at one made after a second thread's first call, or in a calls format 3 capture; a release at a delta that ends the window.gate_no_frame_start: a delta read in flight in a capture without a frame start must make the gate throw instead of mapping its started serials by their distance from the accepted one.unverified: a capture of the current calls format withoutcapture.jsonis refused, also one with no delta read in flight. One with a delta read in flight is also refused withoutstale_deltaorunverified_deltas, with a non-numeric or nonzerounverified_deltas, or with a stale delta. A verified one (also one that stopped for low disk space), one without such deltas, and a capture of the previous calls format withoutcapture.jsonare not refused. A capture of the previous calls format with a delta marked as read in flight (flagged_previous) is refused. The mode calls the tool'srestoreMemorydirectly, which checks each capture and restores the ones it accepts; it replays no calls.depth_submits: the replay samples the in-flight depth at submits only, assubmit_depthsdoes, not at an EOP flip reservation.depth_passes: with two passes, the depth counters hold only the second pass's samples.in_flight_breaker: a queue parks at a REWIND whose valid bit only a later delta read in flight holds. The replay must release nothing, give up pacing once, and run the tail after that delta's own restore.previous_breaker: the same window from a capture rewritten to the calls format beforeInFlightCallsVersion, with the delta not flagged. The breaker must apply that later delta early to release the REWIND before pacing gives up (5 s), and the tail must run.serial_diverged: before a delta read in flight, each of these must make the replay throw: a submission or a suspend point recorded as taking the second serial after the frame start; a CPU flip recorded as taking the third serial after a submission that took the first (in a build without the timing log); a submission with no recorded serial; a delta read in flight at a serial that no call before it in the window took; one that lists a serial no call since the frame start took; and one after a second thread's first call. The tool'srun()must refuse, before its restore, a capture whose submission or suspend point before a delta read in flight recorded no serial. A window whose calls took the recorded serials replays.serial_flip_in_order(withAPS5_CPU_FLIP_IN_ORDER=1): a CPU flip that took no serial in the capture takes one in the replay. The replay must restore the delta read in flight behind it, and only after that flip presented.flip_serial_neutral(in a build without the timing log): a compute submission, a CPU flip recorded as taking the next serial and a graphics submission, where the replay's flip takes none. The delta read in flight behind them must be restored. With the graphics submission parked, the gate must skip the flip's serial and name that submission at the replay serial it took. With the compute submission before the flip parked instead, the gate must wait for it at the replay serial it took, and restore nothing.serial_diverged,flip_serial_startandflip_serial_neutralfail with a message whenAPS5_CPU_FLIP_IN_ORDERorAPS5_SYNC_FLIPis set orAPS5_DUMP_SUBMITSis not empty, since a CPU flip would then take a serial. Their CTest registrations set none of these, so only a run that sets one for every test makes them fail.Recorder tests:
agc_recorder_title_call_closure: completions registered throughOnComplete,AfterCompletionsandAfterRecordedWorkunder the title-call serial must reach the store observer with serial 0, and under submission 141 with 141.agc_recorder_storage_writer: a storage image marked pending under serial 100 (or 0), dropped without a write-back and marked again under 141 must report its write-back under 141. One marked under 141 and again under a title call must report 0.Changed:
main'sconcurrent(above), and #12568'sgpu_restore_cachednow also checks the serials each recorded call took. It expects its CPU flip to record 0 only in a build without the timing log, with neitherAPS5_CPU_FLIP_IN_ORDERnorAPS5_SYNC_FLIPset andAPS5_DUMP_SUBMITSunset or empty.Open before ready for review
late_or_host,label,snapshot,storage,shadowandqueue0(agc_driver_draw_finisher_overlaptests the query behindqueue0, not the term), the recorder's queue hold, commit 8's hold when the arm finds a newer driver store, and, at this head, the host-page loop's update of the unwatched record (commit 4):forget(commit 9) now drops the record first, so a page without the update counts as changed and is listed anyway; the update only lets a later delta read in flight leave an unchanged host page out (no committed test reaches that window; only the local injectiond-t2ashows it). The recorder's stop when a recorded call moves the driver's accepted serial by anything but one (none or one for a flip) is an invariant check, not an untested behaviour: no input reaches it through the driver's entry points, since every submission, flip and suspend point enters the driver through the recorder, the recorder holds its mutex across each call's accept, and a submission or suspend point moves the accepted serial by exactly one or throws.NativeMultisampleDepth; until then debt [Stores into frame capture deltas read in flight] names it. A miss needs the HTILE plane to share a 4 KiB page with title data written between the draw's submission and the delta read; the replay then fails at the publication's same-value check rather than replaying wrong bytes. From code reading; not seen on P5R.main: with frame capture on, a command-buffer flip waits in #7978's flip hold while the recorder holds its lock across the call (#12568's design, which commit 7's accepted-serial check also relies on). If the previous flip submission waits after its flip on a queue-0MEM_SEMAPHOREthat another thread signals with a later submission, that thread blocks on the lock and the run hangs. The root is that the flip hold does not count aMEM_SEMAPHOREwait as a wait on the title, as it doesWAIT_REG_MEM; without the recorder the same hang needs the signal to come after the title's next flip. From code reading, not reproduced; P5R's captures record calls from one thread.stale_deltaandunverified_deltashave not been measured at this head (the latest capture,b18ca951c1above, carries an earlier push).mainor a dispatch, not on a pull request. There,tools/check_skips.pyfails any skip that does not report a device limitation, and the capture modes' inconclusive skips do not.Tested
Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.16010, WinLibs GCC 15.2.0 r7, Release. Each arm is a full build (
cmake --build build) aftergit submodule update --init --recursive. The focused set isctest -R "frame_(replay|capture)|agc_recorder_(title_call_closure|storage_writer|completion_labels)|draw_finisher_overlap|queued_constant_ram_dump|dumped_constant_capture|draw_pipeline_retired_items|agc_recorder_stored_bytes|agc_driver_(present_mode|flip_compute|eop_interrupts)" -V --timeout 120withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. Validation runs addVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(a local build of the layer),VK_LOADER_LAYERS_DISABLE=~implicit~andVK_LOADER_DEBUG=layer, so their logs show whether the layer loaded. The focused-set rows below ran at236795e85c, the previous push's tree but for one skip message inlate_store. At this head the frame set passed 103/103 under the layer (0VUID-lines, layer loaded), the gate modes (gate_failure,gate_settled,gate_no_frame_start,serial_diverged,flip_serial_neutral) and three of the new capture modes passed 3 of 3 runs, and commits 7 to 10 each built and passedctest -R "frame_(replay|capture)"(95, 95, 96 and 103 tests). Rows for earlier heads are in this description's edit history.Focused set, base and head:
VUID-linese0df5b76d8e0df5b76d8Inserted device layer "VK_LAYER_KHRONOS_validation"lines); 0 missing-layer lines236795e85c236795e85c236795e85c236795e85cInserted device layer "VK_LAYER_KHRONOS_validation"lines); 0 missing-layer lineslate_storealso passed 3 of 3 runs each at236795e85cwith--repeat until-fail:3, with no skip.reservation_error(#11435's), which timed out at 30 s in all our earlier Windows runs, passes at the base and the head: #14100 is inmainbelowe0df5b76d8, so a replay error now exits instead of hanging the tool on Windows.Every commit built at its earlier revisions, and from commit 3 on passed the frame tests (
ctest -R "frame_(replay|capture)",ANYPS5_REQUIRE_VULKAN=1). This push is a restack checked at its head only (above); at the previous push (f99e62f0bb, one0df5b76d8) commits 7, 8, 9 and 10 built and passed 95/95, 95/95, 96/96 and 103/103. Commits 3 to 6 passed 67/67, 86/86, 87/87 and 89/89 (commits 4 and 5 at236795e85c's series, 3 and 6 on trees identical to them). Commits 1 and 2 were built only. The recorder and draw-pipeline test targets were built at the previous push's head only.Flakes, not from this PR. #12568's
rewind_storeandstore_second_waitrestore a delta again once the queue parks as captured; each failed now and then in our runs, on the base as well as the head: in 30 runs each,rewind_storefailed 0 at the head and 2 at the base ("the replay applied the CPU store before the copy that preceded it"),store_second_wait1 at each ("the replay ran the copy behind the gate's first wait after restoring the CPU store ...").rewind_storealso failed once in a validation run of the frame set at236795e85c. I will look into them on #12568.Full suite not rerun for this push; the last run (at
e4dfa4b069) and its reruns are in this description's edit history.Red checks. Each patch undoes one piece of this PR and must turn the named test red; the other tests its regex matches must pass.
d-t2ainstead injects the store that commit 8 handles. The patched tree is built, the test executables relinked (their copy of the driver checked by hash), then the tests run withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. The rows that say236795e85cran there; the others ran on the previous pushes' series on #12568'sda47027017andf21b60440d(e4dfa4b069had this push's commits 1 to 8 as trees before the restack;58d76317c6,7c7333675d,9cac8e2692and0191553a68are earlier heads of this PR) and were not rerun at this head.236795e85cis the previous push's tree but for a skip message)agc_recorder_title_call_closure58d76317c6: failedagc_recorder_storage_writer3366c145f6, patch fixed by hand: failed 3 of 3 runsagc_recorder_storage_writer58d76317c6: failedunwatched_restored58d76317c6: failed236795e85c: failedin_flight_store58d76317c6: failed236795e85c: failedlate_store58d76317c6: failed236795e85c: failedlate_wait58d76317c6: failed236795e85c(re-anchored: onlyawaitLateStoreschanged): failedawaits_titleholdwait_after_read,wait64_after_read,rewind_after_read,wait_before_read,semaphore_after_read58d76317c6: failed, 5/5236795e85c: failed, 5/5queuedin_flight_delta,late_store,unwatched_in_flight58d76317c6: failed, 3/3236795e85c: failed, 3/3in_flight_gate58d76317c6: failed0191553a68: failedSerialDonedoes not rethrow a driver failuregate_failure58d76317c6: failedgate_settled58d76317c6: failed0191553a68: failed after 20.20 s (the test's form before this push; not rerun on its new form)unverified58d76317c6: failed0191553a68: faileddepth_submits58d76317c6: failed--repeat, the first pass's depth samples are keptdepth_passes58d76317c6: failedOverlapsAnyasks the finisher's producer-only query againagc_driver_draw_finisher_overlapef6a91568d: failedOnComplete,AfterCompletionsorAfterRecordedWorkwrap is removedagc_recorder_title_call_closureef6a91568d: failed, 3/3carried_labelef6a91568d: failedcarried_labelef6a91568d: failedwait_labelled_*modes9fc6d89504, before it was committed: failed, 4/4wait_labelled_afterwait_labelled_before,wait_labelled_elsewhereCOND_EXECcounts as fixed at submitwait_labelled_skippedwait_labelled_elsewhereserial_divergedd6fa1cb409: failed0191553a68: failedserial_divergedd6fa1cb409: failed0191553a68: failedrun()before the restoreserial_divergedd6fa1cb409: failedserial_divergedd6fa1cb409: failedserial_divergedd6fa1cb409: failedin_flight_breakerabc85ff056: failedprevious_breakerabc85ff056: failed after 5.09 scapture.jsonunverifiedd6fa1cb409: failedunverified,previous_breakerd6fa1cb409: failed, 2/2in_flight_deltad6fa1cb409: failedin_flight_deltad6fa1cb409: failedAPS5_CPU_FLIP_IN_ORDER=1:gpu_restore_cachedalways expects a CPU flip without a serialgpu_restore_cachedabc85ff056: failedin_flight_delta(the delta must be held, not read in flight)7c7333675dwith commit 8's change: failed236795e85c: failed ("the delta read while the busy submission ran was held, not read in flight" is the injected store's hold)host_page_restored9cac8e2692with the fix uncommitted: failed236795e85c: passed: commit 9'sforgetnow drops the record first (see Open)flip_serial_start27408f2a32: the replay refused the capture ("call 5 (flip) took replay serial 1 where the capture's call took none") and the test timed out at 120 s (Known, above);flip_serial_neutralandserial_flip_in_orderfailedflip_serial_start27408f2a32: failed0191553a68: failedflip_serial_neutral,serial_flip_in_order27408f2a32: failed, 2/2serial_flip_in_order27408f2a32: failedexecuteRewindTailadds no labels ahead of a REWIND tail's waitswait_labelled_rewind,wait_labelled_rewind_chain36551c543c(the fix on4daf1dbd66, whose driver and tool are0191553a68's): failed, 2/2, in 3 of 3 runs3d1e020f44: failed, 2/2, in 3 of 3 runswait_labelled_rewind_chain(wait_labelled_rewindmust pass)wait_labelled_rewindpassed3d1e020f44: failed in 3 of 3 runs,wait_labelled_rewindpassedunverified(flagged_previous)1f77916e75: failed, 1 of 1 ("the replay did not refuse capture flagged_previous ...")forgetkeeps the per-page records of unwatched pagesunwatched_rewatched1f77916e75: failed, 1 of 1 ("... left out the unwatched block whose bytes the title wrote back ...")in_flight_once236795e85c: failedheld_concurrent_store236795e85c: failedheld_concurrent_store236795e85c: failedowner_lifetime236795e85c: failedowner_lifetime_rewritten236795e85c: failedempty_in_flight_read236795e85c: failedshader_in_flight236795e85c: failedshader_in_flight236795e85c: failedfinish()does not count its own threadlast_thread_hold236795e85c: failedgate_no_frame_startflip_serial_neutral,serial_diverged0191553a68: failed, 2/2Each failure in the table printed the message its test gives for that defect, except u13-red0's
flip_serial_start(the tool's refusal, then the exit hang) and c-v1branch (the reader's "is not a frame capture file"). With commit 8 reverted as well as injected (t2b, on7c7333675d),in_flight_deltapasses: the delta is read in flight and the capture is accepted withstale_delta0, which is the silent case commit 8 closes. 41 of the 43 new tests have a red row at this head or the previous pushes;hold_diagnosticshas none, andhost_page_restored's (d-t3red) no longer turns it red at this head.Not tested:
58d76317c6passed 26 of 63 tests. The 37 frame-capture tests stop at "frame capture: the guest write watch is unavailable", because asynchronous userfaultfd write protection fails there. That is not the CI path, and the pull request build does not run the Linux job. None of this push's new or changed tests has run on Linux. Third-party Linux runs so far cover only the stack, without this PR's code: TechLevelZero ran this PR's basef21b60440dmerged ontomain4f41f4c375on an NVIDIA RTX 2000 Ada and on an AMD RX 6300 (RADV); both runs passed with 0 new failures and no new validation IDs againstmain.-DAPS5_ENABLE_TIMING_LOG=ONbuild of this head. By the code, in such a buildflip_serial_startskips,flip_serial_neutralreturns at once,serial_divergedleaves out its CPU-flip row, andgpu_restore_cachedaccepts 0 or the next serial for its CPU flip. Such a build of4daf1dbd66ran (an earlier push: its driver and tool are0191553a68's, not this head's), and its tests lack the assembled-head review's changes (theflip_serial_startguard,flip_serial_neutral's third window andserial_diverged's listed-serial row). Thereflip_serial_startfailed 3 of 3 runs ("the first CPU flip after the frame start, from a thread without graphics submissions, took a serial in the capture"), the case its guard now skips, andserial_diverged,serial_flip_in_order,flip_serial_neutral,gpu_restore_cachedandin_flight_deltapassed 3 of 3. The same tree built without the timing log passed all six, 3 of 3. The environment side ran:gpu_restore_cachedpassed 3 of 3 runs withAPS5_CPU_FLIP_IN_ORDER=1on the tree ofabc85ff056, and failed with its guard forced (the c-u7env row).APS5_DUMP_SUBMITS: Windows removes a variable set to empty, so the empty-is-unset terms rest on code reading.DrawFinisher::Enqueue, applied around each job inDrawFinisher::run): the finisher runs only withAPS5_DRAW_PIPELINE, and none of the tests that install a driver-store observer sets it. Without that scope a finisher store reports serial 0. Into a page of a delta read in flight, that stops the capture (stale_delta), so a good capture is refused, loudly. Anywhere else it only adds tounattributed_storesand, like any reported store, holds later deltas over its page. It cannot make a replay silently wrong.RELEASE_MEMtimestamp terms of a label's fixed value, predicatedINDIRECT_BUFFERranges, the newest earlier submission on the waiter's own queue, the pairing of a 64-bit wait's two dwords,RewindValidon another queue's label, theMEM_SEMAPHOREearly return, and the erase of a completed submission's labels.02132ba69eandb18ca951c1.236795e85cthe slowest test took 4.8 s (rewind_release) and the seven new modes of this push 2.0-3.1 s each.Checklist
main; no other open PR implements the same functions (these commits sit on #12568's4cd4bc371a;git merge-treeof the head intomain6711907d65is clean)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)4cd4bc371a(merge order: this PR after it)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T19:49:00Z.
Review: COMMENTED
Reviewed — comments
The change is substantial and the inspected replay and capture paths did not establish a blocking defect, but most changed lines and two excluded files were not reviewed, so a formal approval is not justified.
What I ran
Reviewed head
7028c55d7eb09a2acfb8121779ea4d5322209db8using the prepared review bundle and the pinnedrepo_read.pyreader; no build or tests were run.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Not verified
The inspected source ranges were
FrameCapture.cpp:260–400andFrameReplay.cpp:680–745, plus targeted search results inFrameReplay.cpp. The review bundle also includeddescription.md,commits.md,manifest.json,README.md, and the initial and final portions ofdiff.patch. Other changed source and test lines were not read.Graphics/src/Texture.cppandtests/Recorder.cppwere excluded from the review folder as too large and were not read through the reader. No test or build results were independently confirmed; the checks in the description are author-reported.To get this to a good state
Nothing is required. The optional point is to complete review of the remaining changed code, especially the excluded files, before requesting a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:45:17Z.
Review: COMMENTED
I trial-merged the exact head onto
c1601e56d5. It conflicts in the recorder and replay tools, packet memory, label history, and their tests. Please keep replay coverage for a capture boundary with outstanding work, including a partial store and an unrelated submission, when reconciling the recorded serials. A fully settled capture only exercises the simpler layout. The author’s historical clean merge does not cover this main revision.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.