fix(agc): run the packets after a call once its REWIND is released #22441
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22441"
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 adam25136 on 2026-11-17T16:05:05Z.
What
A REWIND's second dword is its control word; its tail, the packets after it, may run once the game sets bit 31 of that word. When a buffer reached by INDIRECT_BUFFER stopped at a REWIND,
copyLink(Submission.cpp) returned at once, so the caller's packets after the call were never copied. Once the game released the REWIND, the called buffer's tail ran and the submission ended there: the packets after the call, in that caller and in any caller above it, never ran.copyLinkkeeps a copy of the packets after each such call (AGC's copy), innermost caller first, with the address they were read from;executeRewindTailcopies them after the released tail, through a newcopyRewindTailaround the unchangedcopyCommands, and the look-ahead over released tails innoteReleasedTailsuses it too;testBranchSubmission);SubmitLockedpasses a merged copy that it frees on return.main(read from the code, not reproduced); open #22375 makesMergeEnginesrefuse such a REWIND.Packets after a call that stops at a REWINDentry under Functional.Tested
Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 (r7), CMake 4.3.1, Release, this branch on
main5a23c6303b.main's ownagc_driver_upload_cache_read_only_flush_testsdoes not build with MinGW (setenv; open #19899 fixes it), so the builds went on past it. No game is known to hit this; it was found while working on #22375.main7058988458with only this branch's test file and its CMake line: the new test fails at its first case,the caller's packets after a call whose REWIND was released did not run; the called buffer's own label was written, as that case checks first.agc_driver_pm4_rewind_call, passes. Its five cases:agc_driver_pm4_rewind_callfail:the caller's packets after a call whose REWIND was released did not run);the packets after a second released REWIND and after the outer call did not run);unsupported PM4 packet type: header 0x00000000);packets after a second REWIND, met in the packets after a call, ran before the title released it);the branch returned like a call).tools/select_tests.pyselects for the 6 changed files (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1): 3,282 on this branch and the same 3,281 onmain, which lacks the new test. No test fails only on the branch, and both runs skip the same 19. Five fail on both:agc_driver_bda_deviceandagc_driver_stencil_plane_memory;agc_driver_upload_cache_read_only_flush(not built);agc_driver_store_over_untracked, which fails on either side from run to run in earlier runs here too (a pending storage result was stored over bytes the CPU wrote to untracked memory);performance_runner_PerformanceRunTests: 3 of its 5 cases error, becauserun_performance_titlerefusesANYPS5_NO_SHADER_CACHE=1.VK_LAYER_KHRONOS_validation1.4.367 (throughVK_ADD_LAYER_PATH) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,VK_LOADER_LAYERS_DISABLE=~implicit~,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1,ctest -V, on the tests matchingpm4|rewind|frame_replay|frame_capture: 89 on this branch, 88 onmain.Insert instance layer "VK_LAYER_KHRONOS_validation"lines, from the 19 tests that create a Vulkan instance, no "was not found" line and noVUID-message.frame_capture_minimizefailed once in the branch's run (PermissionErrordeleting a temporary file), then passed 3 of 3 times alone on the branch.python tools/check_conventions.py --base origin/main --title "<this title>" --body <this description>:All conventions checks passed.python tools/pr_overlap.py --branch:main, so pr_overlap exits 2.Pm4.cpp'smain()sits next to the new test's mode block.git merge-treeof this branch with the heads of #12944, #18914, #22029 and #22156 finds no conflict in this branch's files. The last three editcopyCommands,copyLinkorPm4.cppnear this branch's lines. #12944's four conflicts are the ones it has withmain.APS5_LEAN_FRONT) changescopyCommands,copySegment,copyLink,noteReleasedTailsandexecuteRewindTailtoo, sogit merge-treewith its head conflicts inDriver.hpp,Submission.cppandPm4.cpp. Where this branch keeps the caller's packets after a call that stopped at a REWIND, #22434 records the words read for its packet table (read(cursor + count)) and still returns without them, so the two fix different things; whichever merges second needs a rebase.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)AI-assisted: Claude Code found the bug while working on #22375, reproduced it with the new test, wrote the change, ran the tests, and drafted this description; separate review agents checked it.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T03:46:53Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and its added test cover the described REWIND return behavior, while the Gnm path remains unverified.
What I ran
Reviewed head
f1377ee36bed5742cef0dfc6a1df4d979149aa6f. No commands or tests were run in this review; the commands and test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
description.md,commits.md,manifest.json,diff.patch,README.md; all six changed files listed inmanifest.json; and the targetedPacketExecution.cppranges. No changed files were excluded.To get this to a good state
Nothing is required.