fix(agc): read capture deltas and replay them while queues wait on the title #12567
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12567"
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 chitters2004 on 2026-10-28T20:44:43Z.
What
Review
db4ab05bc1(+574 −52), @JJenkx's76ce637975(+10 −3) and6cee7614e5(+51 −14). The others belong to PRs that merge first in the agreed order and drop out of this diff as they do: #11435 and #11436 (Sam-mon7) and #12318 (Tehshortbus). #12566 has merged, and79d7617af2mergesmain(ce9394b844) into this branch.76ce637975is JJenkx's fixture shutdown fix (his42ccdf0b79, first carried in #12568), kept as his commit. The replay fixture callsAgcDriverShutdownbefore static teardown; on Linux the driver's static destructor otherwise crashes the tests this PR adds after they pass (his GDB trace). It moves here because this PR adds those tests.A memory delta is read only once every accepted submission has completed, so a capture stops after 10 s whenever a queue waits on a REWIND control word or a label that a later call stores: @JJenkx's two-queue reproducer on #11157 (comment), and the Ghost of Yōtei capture on #11197 (comment).
Driver:
AgcDriverHoldSettled(ms)succeeds once every queue has finished or is parked on a REWIND orWAIT_REG_MEMvalue the title has not stored yet (parkedOnTitle: no uncommitted queue 0 work, queued draw, unrecorded label or pending label write, and the awaited value still fails its compare). On success it holds:SubmitandSuspendPointwait at admission, and a worker leaving a wait waits innoteWaitBlocked, untilAgcDriverReleaseSettled.AgcDriverSettledis the same check without the hold.Pm4::WaitComparesleavesPm4.cpp's anonymous namespace for that compare.Recorder:
writeDeltatakes the hold instead of waiting for idle and reads the delta through the coherent path (readGuest, from #12566), so the bytes of work that ran before the hold are in it.Replay (built on #11436 and #12318, whose commits are included until they merge):
AgcDriverPrepareCommandWrite). It waits for the hold for up to the busy timeout, or not at all once pacing has already given up at the current serial.AgcDriverHoldSettled(0)). Any other wait gets the last earlier recorded value or a synthesized one; the breaker no longer writes a value from a later delta, which applied a later CPU store early.--pace-timeout-ms(new option, default 10000) only once the driver is settled and progress did not change, or after the busy timeout regardless, so a queue still executing (compiling pipelines on a cold cache) counts as progress. The busy timeout is #11435's ten-minute drain limit, renamedbusyTimeoutand shared by pacing, the settled hold and the drain, replacing a separate limit of this PR. A memory delta waits for the hold instead of a submission depth.Overlap: this follows the order agreed on #11435 (comment): #11435, #11436, #12318, then this PR, which is stacked on all three and adds its test modes to their argument check in
tests/FrameReplay.cpp. #7978 changesQueueWorker.cppL72-74 next to the worker's wait hook, #11455 rewrites BUILD.md L257, and #10760, #11447, #12348 and #12452 edit the frame capture debt entries; whichever merges second rebases those lines.BUILD.md is updated. The frame capture debt entry loses its delta stop; two entries are added for what is still open: a capture still stops when a busy queue neither completes nor parks within 10 s, a submission another captured thread made before a delta can still reach the driver after it, and a queue that neither finishes nor parks holds the replay for the busy timeout.
Tested
Windows 11 Pro 26220, WinLibs GCC, Ninja Release, NVIDIA GeForce RTX 3080 (driver 621.01).
New tests. "Before", measured before this was restacked onto #11436, is this branch with
FrameRecorder.cppandtools/FrameReplay.cppat their base (#12318), keeping only the--pace-timeout-msparsing, and the admission wait removed fromSubmitandSuspendPoint:agc_driver_frame_capture_eopnow also takes a settled hold on an idle driver and checks that another thread'sSuspendPointis not admitted until the release. Before:the driver admitted a submission while a settled hold was taken on an idle driver.agc_driver_frame_replay_rewind_store,_rewind_copy,_rewind_compute,_rewind_releaseand_busy_queueread a delta while a queue is parked on a REWIND or a fence and check the capture and the replayed bytes (see BUILD.md). Before, each capture stops after 10 s:the GPU work submitted before a memory delta did not finish within 10 s.agc_driver_frame_replay_wait_labelis JJenkx's reproducer. Before:the producer submission waited 10016 ms for the capture.agc_driver_frame_replay_rewind_fill,_rewind_splitand_fence_reusepass before and after; they cover delta restoration and fence reuse under the hold.All pass with this PR.
_busy_queuealso covers the replay's pacing and breaker rules: it runs the replay with--pace-timeout-ms 1while a queue copies 64 MiB, and with the tool'sAgcDriverSettledchecks removed it fails 3 of 3 (pacing gave up at call 9 (flip): serials 0/2); with them it passes 3 of 3 in about 1 s. On GTA V (PPSA04263, North Yankton prologue, 3 frames, 13 deltas, all four PRs of this series applied), with an earlier revision of this tool that had neither the pacing rule nor the one-wait-per-pass limit, each of 6 replays gave up pacing once (pacing gave up at call 131479 (suspend): serials 0/3, the capture had 0 in flight, a queue still compiling) and released 2 to 3 waits with synthesized values. With this PR's tool before the restack, which changed only the busy limit (never reached in these runs) and the drain's reports: 1 cold-cache run with--no-synthesize(90 s) and 5 normal runs, all with 0 pace timeouts, 0 released waits, 0 synthesized and no unfinished submissions. With the restacked tool at5ed0a3f0bc, a cold run with--no-synthesizeand a warm run give the same. This is not a pixel-fidelity claim; replayed frames still differ from the title's.Paired run on
mainand this branch, same machine and GPU,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "frame_(capture|replay)|sample_multisample_target" -V:mainat1235db19dc: 12 tests, all passed, 0VUID-lines; #11436 at210bd86b58: 19 tests, all passed, 0VUID-lines; this branch atdb4ab05bc1: 29 tests, all passed, 0VUID-lines (the full set ran on the previous revision, which differed only in one check intests/FrameCapture.cpp;agc_frame_capturewas rerun at this head and passes). Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS.After
4ef54b694c(the pacing warning back to its text before this PR):ctest -R "frame_(replay|capture)" -Vwith the same variables, full builds with submodules at their pinned commits.mainbb04a4f1ea: 11 tests, all passed. This head merged into it (79e77c5da3): 28 tests, all passed, includingagc_driver_frame_replay_busy_queue. 0VUID-lines on both, and neither log has the missing-layer message.After
76ce637975, onmain4c8cff1916(after #12264), the same command and variables, full builds:main: 11 tests, all passed. This head merged into it (13240d9aca): 28 tests, all passed, including the nine replay modes the Linux CI saw crash. 0VUID-lines on both, and neither log has the missing-layer message. Windows 11 26220, RTX 3080, driver 621.01.After
79d7617af2(mainwith #12566 merged in), the same command, variables and full builds:maince9394b844: 11 tests, all passed. This head merged into it (ba86d7be1f): 28 tests, all passed. 0VUID-lines on both, and neither log has the missing-layer message.After
6cee7614e5, @oneandonlydean's report: a delta is now applied again once the replay parks where the capture did. Full build, thenANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc_driver_frame_replay" -V:b9ba8debb8, the head before it: 41 of 42 pass.agc_driver_frame_replay_rewind_storefails withthe replay applied the CPU store before the copy that preceded it.6cee7614e5: 42 of 42 pass.rewind_storepasses 5 of 5 with--repeat until-fail:5.VUID-lines in the test logs or the replay logs, and neither log has the missing-layer message.Windows 11 26220, RTX 3080, driver 621.01. Not run on Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:05:45Z.
Review: APPROVED
Reviewed — last commit only
Per the PR description, this review covers commit
7431fc799665d5a853e54cbc2892f4dd81d0e1cfand its settled-driver hold. It does not independently approve the preceding stacked work in this PR or its prerequisites.What I checked
git diff --check upstream/main...refs/review/pr-12567-currentpassed.git merge-tree --write-tree upstream/main refs/review/pr-12567-currentwas clean (8f8f26546a275d3b913eb7c95cbd09457018ce2b).Findings
Blocking
None found in the reviewed commit.
Limits
I did not build or run the AGC/Vulkan tests locally or reproduce the paired Windows/Linux and GTA V reports. Those results are author-provided; the hosted Windows job passed. This review is scoped to the requested commit and makes no console-equivalence or pixel-fidelity claim.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T00:55:41Z.
Review: APPROVED
Reviewed — looks good
This approval is scoped to commit
db4ab05bc12abeadf6a58184d2b7901c958c01bcand itsReadAroundRangesextraction; it does not independently approve the preceding stacked PRs.What I ran
7431fc799665d5a853e54cbc2892f4dd81d0e1cf.FrameCapture.cppandtests/FrameCapture.cpptogether with the exact-head header using GCC, C++20, and system Zstd; ran the resulting executable.git diff --checkon the follow-up.Results
Raw output
frame capture tests passedRaw output
git diff --check 7431fc799665d5a853e54cbc2892f4dd81d0e1cf...refs/review/pr-12567— no output; exit status 0Raw statuses
windows pass; conventions pass; labels pass; report pass; linux, register-context, relinker, relinker-asan, write-watch skippedAuthor-reported exact-head result
RTX 3080, Windows 11 Pro 26220: 29 selected tests passed, 0VUID-lines, and no missing-layer warning. The author reports the same focused command on main and intermediate stack heads with 12 and 19 tests respectively.Negative control
The PR report includes main and intermediate-stack comparison runs, but no mutation control for this extraction. I did not run a Vulkan main-versus-change control locally.
Findings
Blocking
None found in this scoped follow-up.
Non-blocking
ReadAroundRangeswalks skipped ranges in order. Its production producer,HostOnlySampleRanges, sorts the ranges before returning them; the new tests cover overlapping ranges and ranges outside the captured block. The standalone test passed.Sources
db4ab05bc12abeadf6a58184d2b7901c958c01bc.7431fc799665d5a853e54cbc2892f4dd81d0e1cf.Not verified
I did not run the Vulkan suite or test a console. The Vulkan results above are author-reported; my independent run covered the CPU frame-capture target only.
To get this to a good state
No further change is requested for this commit. Keep the PR's declared dependency order so the other stacked commits are reviewed and merged separately.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T20:00:11Z.
Review: APPROVED
Re-checked — new head, looks good
The latest commit restores the prior pacing-timeout warning text, addressing the requested default-output change; the author also reports the refreshed paired Windows run passing.
What I ran
4ef54b694c2c5cd4900ff418eb1923bcf29f516f.main420b6a064eadaa7c5e50b080c7fad59c41150b4b; merge preview is clean (5d547a7a98bb27bed8ad9161bc56fe4090314dce).Results
5d547a7a98bb27bed8ad9161bc56fe4090314dce.git diff --checkpacing gave upstderr format; the busy-timeout and blocked-queue suffixes are removed.Unedited local output
Negative control
No mutation control was run for the stderr-format restoration. The author reports a paired main/PR run, but says no test specifically asserted the restored warning text.
Findings
Blocking
None found in the latest commit.
Non-blocking
The author-reported test run was against
bb04a4f1ea, not the newer420b6a064eadaa7c5e50b080c7fad59c41150b4b; my merge preview against currentmainis clean, but I did not rerun the product suite locally. This approval is scoped to the previously approved follow-up and the latest warning-text restoration; the PR still declares its dependency stack in the body.Sources
Not verified
I did not build or run CTest locally, test on a console, or independently rerun the author-reported Windows/GPU matrix. No test specifically asserts the warning text.
To get this to a good state
No further change is requested for this scoped follow-up. Preserve the declared dependency order; I will recheck any changed head and rerun the relevant commands then.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T22:53:00Z.
Review: COMMENTED
Re-checked — new head, Linux verification pending
The branch now includes the #12566 merge and has a passing Windows run reported for the updated integration tree, but an NVIDIA Linux report on the preceding head records replay-test crashes and a new validation message, so I’m not issuing a fresh approval until that platform discrepancy is resolved.
What I ran
Reviewed PR head
79d7617af20f9d8c0c93e46489d481b5a21ce733, whose GitHub base SHA is102b7a5cf0ed98dd94d9da76862eb1ee7865a932. A merge preview against currentmainfdd1753204a4732e1011539cc9d3bb69f70b27a6was clean. Environment: Linux; no compiler was invoked.I read the updated PR description, the #12566 merge commit, current hosted checks, and the latest NVIDIA report comment.
Results
ce9394b844; 11/11 pass on that main baseline, with 0VUID-lines reported4ef54b694c2c5cd4900ff418eb1923bcf29f516fmerged ontobb04a4f1ea0175e9e4f149f0359a764d62ff3296, the report records 9 replay-test failures not compared against main and one newVUID-VkDeviceCreateInfo-pNext-pNextoccurrence inagc_driver_frame_replay_concurrent.Unedited local command output
The NVIDIA failures are from an older tested head and older main baseline, not the current head. The updated Windows result is reported by the author; I did not independently build or run either test matrix.
Findings
Blocking
None established from the current-head source review. I am not requesting changes based on a report for a superseded head.
Non-blocking
Please provide or link an exact-current-head Linux/NVIDIA rerun, or explain why the prior-head replay crashes and validation message do not reproduce after merging #12566. The configured hosted workflow skips Linux, so it does not settle this discrepancy.
Sources
Not verified
I did not build or run tests. The 28/28 Windows result and 11/11 baseline result are author-reported. I did not rerun the Linux/NVIDIA matrix on head
79d7617af20f9d8c0c93e46489d481b5a21ce733; hosted Linux is skipped.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T01:07:57Z.
Review: COMMENTED
Re-checked — new head, Linux verification pending
The new shutdown call is consistent with the reported static-teardown failure, but the exact-head Linux/NVIDIA rerun promised in the thread is not present in the current checks.
What I ran
76ce637975b4102bcc90d68d353f0e39649e6990; recorded PR base:102b7a5cf0ed98dd94d9da76862eb1ee7865a932; currentmain:f6fddd60d826831f70f7c62e25423610ee742bcc.git diff --checkand conventions pass.Results
a68d7b0485802f354c3b202feb9ad1e42a7d7039git diff --checkmain4c8cff1916, 28/28 on this head merged onto that base; no VUID lines or missing-layer message reportedUnedited local command output
git diff --checkproduced no output and exited 0.Not verified
I did not run the replay tests locally. The Windows comparison is author-reported. The specific Linux post-test segfault reported on the prior head is not yet shown to be fixed on this head. The known
VUID-VkDeviceCreateInfo-pNext-pNextexplanation is in the linked #12568 thread; I did not independently inspect that runner’s full log.To get this to a good state
Please link the exact-head Linux/NVIDIA run and its full result, including whether the replay tests exit cleanly after printing success and any validation output. I will recheck that head and update the review when the run is available.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T01:59:48Z.
Review: APPROVED
Re-checked — new head, looks good
The exact-head Linux/NVIDIA report now addresses the earlier teardown concern: it reports no new test failures, and the validation message is explained by the runner’s older Vulkan validation layer; the current-main merge preview and repository checks pass.
What I ran
Reviewed PR head
76ce637975b4102bcc90d68d353f0e39649e6990, recorded PR base102b7a5cf0ed98dd94d9da76862eb1ee7865a932, against currentmain91a69952c10099966378a6a9006b8ef616ae22da. The merge preview is clean (treec05f64ebee444566e0179eaf710721af76a531bc). Environment: Linux x86_64, Git 2.39.5, Python 3.11.2; no compiler or project build was run.Results
c05f64ebee444566e0179eaf710721af76a531bc.git diff --checkagc_driver_frame_replay_concurrent.1000574000isVK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_8_FEATURES_KHR; the runner’s validation layer identifies itself as header version 275, while the repository’s Vulkan headers know this structure. The same ID is reported in unrelated baseline tests; the author also documented that the stack does not change device creation. I do not count this runner/version mismatch as a defect in this PR.Unedited local command output
Findings
Blocking
None found in the reviewed head.
Non-blocking
The NVIDIA report records one validation ID because that runner’s validation layer does not recognize the Maintenance 8 structure already used by the project. A current validation layer would provide a cleaner validation result. The report also records 41 environment-dependent skips. I did not independently run the GPU suite.
Sources
Not verified
I did not build or run tests locally, run a GPU test, test other operating systems, or test console behavior. The NVIDIA run is contributor-reported and its 41 skips remain unverified here.
To get this to a good state
No further change is requested for this head. I will recheck the same commands and relevant tests if the PR head changes.