fix(agc): release a parked REWIND in frame replay with its whole memory group, and write REWIND control words last #12318
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12318"
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 Tehshortbus on 2026-10-28T09:19:27Z.
What
A title that parks a queue on a REWIND writes the tail's command buffers while the queue waits, and only then sets the control word's valid bit. GTA V does this for every submission: each one chains through REWIND-linked segments that the CPU fills in.
agc_frame_replaymishandled this in two ways:--release-after-ms, the replay copies the awaited dword from a later memory group. For a REWIND that sets the valid bit while the tail'sINDIRECT_BUFFERis still null in replay memory, so the tail fails withnull or misaligned address.The change in
tools/FrameReplay.cpp:releaseRewind: a REWIND wait (AwaitedWaitwithfunction == 0andbytes == 0;WaitMemoryalways sets a shape, and a function-0 WAIT_REG_MEM never blocks) is released by applying the first later memory group whose recorded control word hasPm4::RewindValidset, throughrestoreGroup. Other waits are released as before.restoreGroup: theMemorycall andreleaseRewindboth apply a group through it. It holds back a valid REWIND control word, writes the rest of the group, then publishes the held words with release stores. A word is held back when the word before it in the recorded chunk is a REWIND header, or when it is the address of a REWIND a queue is parked on. Holding a word back only changes the order of the writes, so a data word that happens to follow a REWIND-looking header still gets its recorded value.Tested
CachyOS Linux (kernel 7.3.0-4-cachyos), GCC 16.2.1, Release, NVIDIA GeForce RTX 4070 SUPER (615.78.08). Author-reported GPU tests (hosted CI does not run them).
agc_driver_frame_replay_rewind(new):INDIRECT_BUFFERwith a null target. It waits untilAgcDriverAwaitedWaitsreports the queue parked on that control word.INDIRECT_BUFFERat it, and sets the valid bit.--strictand compares the copy target.main'stools/FrameReplay.cppit fails as GTA V did:[gpu] driver failure: AGC driver: null or misaligned address, then a pacing timeout. With this change it passes.maine322066f82and this change merged with it (head748c64ea17), in the same build, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build-tests -V -R '^agc_driver_frame_replay'. The 21 existing replay tests pass on both,_rewindfails only withmain's tool, and neither log has aVUID-line or a missing-layer message.releaseRewindand the held-word path ofrestoreGroupfor a parked REWIND. Its control word follows the header in the same chunk, so both conditions hold.maina capture does not start in GTA V gameplay (#12235); this one was recorded with local, unsubmitted recorder changes, which chitters2004's announced PRs on #12235 cover.agc_frame_replayfailed on its first submission with the samenull or misaligned address.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass.Overlap:
752958c135intomain.748c64ea17resolves the argument-check conflict intests/FrameReplay.cppby addingrewindbesidemain'spipelinesandreservation_error. #11435 and #11436 are still open with later commits. Against their current heads (ce3b9a8bf6,a110d7694a), this branch conflicts in the same filesmaindoes and in no others.mainand add itsrewindmode to their argument check intests/FrameReplay.cpp.tools/pr_overlap.pylists #11435 and #11436 (Sam-mon7), which conflict with this PR only inmain()oftests/FrameReplay.cpp(L263–273). All three add a mode to its argument check, so whichever merges second adds its mode to the other's.752958c135, and itstests/FrameReplay.cppis #11436's unchanged. Its own commits (df74f29c46,89db2b5ae2) add a relaunch check aboverun()intools/FrameReplay.cppand a line indocs/dev/ENVIRONMENT.md, away from the wait release and the group restore. Its conflict is #11436's, and the rebase onto #11436 resolves it.Depends on.tools/FrameReplay.cpptheir changes do not touch the wait release or the restore of memory groups:CapturedMemory::Applyserves its new shader-listing mode;AgcDriverAwaitedWaitscall only describes blocked waits in the progress line.core/libs/prx/libSceAgcDriver/CMakeLists.txt. I checked their hunks there (#5021's through the files API): none touches the frame replay tests.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-28T09:47:57Z.
Review: CHANGES_REQUESTED
The focused replay evidence is thorough, including the same-machine main/change validation-layer runs and a negative control. I did find one remaining integration item in the PR's own overlap disclosure: #11435 and #11436 are both still open, and this change overlaps their argument-mode handling in
tests/FrameReplay.cpp; the description says whichever merges second must add its mode to the other. CONTRIBUTING asks authors to agree on overlap order and record that order withDepends onwhere needed. Could you coordinate with Sam-mon7 and update the checklist to show the agreed order (or explain why no dependency is needed)? I have not independently run the GPU tests reported in the description.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T11:46:26Z.
Review: CHANGES_REQUESTED
Checked the diff: the parked-REWIND release through
restoreGroup(FrameReplay.cpp:445,:476,:557) and the held valid control words look correct, the lock is already held byreleaseAwaited, andagc_driver_frame_replay_rewindfails withmain's tool. maskym's Windows/NVIDIA run also passes.tests/FrameReplay.cppmain()). Please record the agreed order inDepends ononce Sam-mon7 confirms, or rebase onto them and list them there.Once that is recorded this is ready to merge.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T23:56:12Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested for current-main integration
The overlap sequence is now documented with the relevant authors, but this branch is still based on an older
mainand needs the required current-base check before approval.What I ran
8e6bcba04d2247a75bb546c6c7e1a7410f133ca3; currentmainis3a2b91981651569163768854a1fcdc7193b6667b.git merge-tree --write-tree upstream/main upstream/pr-12318— clean preview, treeae3ed04466737f3d256c07745fe8803c972e8a7d.python3 tools/check_conventions.py --base upstream/main --head upstream/pr-12318— passed.git diff --check upstream/main...upstream/pr-12318— passed.Results
main284a487cd978824f442955918ec0f99ab9c556d3, behind currentmainFindings
The previously requested overlap order is now clear: #11435, then #11436, then this PR. The linked confirmation with Sam-mon7 and the
Depends on: #11436entry document that sequence; #12567 also now records its dependency on this PR. I consider that blocker resolved.The remaining integration item is the base.
CONTRIBUTING.mdsays to keep the branch up to date withmain. Since the tested head predates currentmain, andcore/libs/prx/libSceAgcDriver/CMakeLists.txtchanged on both sides after the merge base, please rebase onto3a2b91981651569163768854a1fcdc7193b6667band rerun the focusedagc_driver_frame_replaysuite on the updated tree. The merge preview is clean, but that does not replace testing the current merged tree.Sources
Not verified
I did not run Vulkan/GPU tests on this host, run GTA V, or verify behavior on another GPU. The PR's reported GPU tests apply to its earlier tested base, not current
main.To get this to a good state
Rebase onto current
main, rerun the focused replay tests with the validation layer enabled, and attach the exact head and output. I can then complete the re-review.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:30:22Z.
Review: APPROVED
Re-reviewed exact head
6ed6c2ba2a65e1873101267f40f409d9179956b0against currentupstream/main4c7d275bef89d309313d16bc2bc05d37a1b50be2. The author reports all 11 focused frame-replay tests passing on the exact head, including the new REWIND regression; the test fails with the priormainimplementation, and the validation-layer log has no VUID or missing-layer message. The declared order through #11435 and #11436 is recorded. My current-main merge preview is clean;git diff --checkandpython3 tools/check_conventions.py --base upstream/main --head refs/review/upstream-12318pass. I did not run the GPU tests locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T02:28:22Z.
Review: APPROVED
Re-checked — new head, looks good
I reviewed head
d3faa75d4aa9e44196409cdbbe524b0ce81d56a9; the replay implementation and regression assertions are unchanged from the previously reviewed head, and the current-main preview is clean.What I ran
GitHub records PR base
613f9b8edf056318b14ff96fe3aceda59a419323; currentmainiscf79276fee2f042feb6a7c71d0d6a27e9cfe2592. The no-build precheck reports a clean preview against currentmain. Environment: Debian 12 x86-64, Python 3.11.2, GCC 12.2.0.Results
cf79276fee2f042feb6a7c71d0d6a27e9cfe2592.FrameReplay.cpp; implementation and test source match the previously reviewed head.d3faa75d; the attached broad-run logs do not includeagc_driver_frame_replay_rewind.6ed6c2ba2a65e1873101267f40f409d9179956b0included the REWIND regression and reported that it fails with the prior replay implementation. Test and implementation source are unchanged since that head; I did not reproduce the run.Selected unedited output
Negative control
FrameReplay.cppimplementation.6ed6c2ba2a65e1873101267f40f409d9179956b0; not independently repeated ond3faa75d.Sources
Not verified
No local build, CTest, or GPU run. The latest broad NVIDIA run did not list the new CTest by name; the focused REWIND result is author-reported from the unchanged source on the earlier reviewed head. The current #11436 dependency head is not included yet; the PR records that it will be rebased and integrated after the dependency lands.