fix(agc): commit the pages of a sub-page capture range when replaying on Windows #22181
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22181"
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 LeandroLP23 on 2026-11-17T07:38:00Z.
What
agc_frame_replayon Windows could not restore a capture whose guest allocation registry holds ranges smaller than a page. A title's heap can register allocations of a few bytes at addresses inside a page. The replay committed each captured range at its own address and size.GuestArenaCommitthen tried to split the arena's placeholder at that address, and Windows refuses to split a placeholder inside a page. The replay stopped withsplit guest placeholder prefixbefore it restored any memory.commitnow commits the 4 KiB host pages (dwPageSize) that hold the range. For a later range in a page that is already committed,WindowsMappings::Committakes its committed-memory branch, which only callsVirtualProtect(and resets the write-tracking state of shared views there).commitalways uses read-write (0x04), as before. A host page shared by several captured ranges is therefore read-write as a whole, and so are the bytes of that page outside any captured range. Those bytes belong to no captured range, so the replay never reads or restores them. Linux already sets the whole page read-write this way.GuestAllocations::Mutation::Add) still uses the captured address and size, so the replayed registry matches the captured one.Found with a capture of SuperTuxKart (PPSA69421, open-source homebrew). Its heap registers ranges of 1 to 16 bytes, for example 1 byte at 0x200220020. No capture data is attached.
Tested
Windows 11, MinGW-w64 GCC 15.2, Release, AMD Radeon 860M (driver 32.0.32015.12012).
agc_driver_frame_replay_subpage. In one 64 KiB guest block it registers a 1-byte range at +0x20 and a 16-byte range at +0x40, both in the first 4 KiB host page, and a 48-byte range at +0x1010 in the next page. It captures two frames of copies, replays them with--strict, and checks the copy and the bytes of all three ranges. The 16-byte range is the case of a range in a page that an earlier range already committed. The second commit added it.tools/FrameReplay.cppchange reverted, the replay stops withsplit guest placeholder prefix, exits with 2, and the test fails. With the change restored, it passes.ctest -R agc_driver_frame_replay: all 48 pass after a full build.agc_driver_frame_replay,agc_driver_frame_replay_subpageandagc_driver_frame_replay_gpu_write_before_deltawithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer(Vulkan SDK 1.4.363), onmainand on this branch. Both logs show the loader inserting the layer and nowas not foundline, and neither log has aVUID-error.commitis unchanged, but the new test is also registered there.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch:#ifdef __linux__line of the samecommitfunction to add macOS, and the BUILD.md line next to the new sentence. That is a textual conflict only.main, which is a textual conflict only.mainand could not be compared automatically. None of their diffs changescommit, the Windows placeholder commit or page rounding intools/FrameReplay.cpp. #17338 and #19557 round ranges to pages only to register the Linux write watch.docs/dev/BUILD.md.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T08:04:07Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
1ecb8949154223cc6b343cbdef183d8bd656bf9a(basemain).Results
commitand its calleragc_driver_frame_replay_subpageCommands and output
Only the reader commands listed under What I ran were run. No test command was run.
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/FrameReplay.cpp:302setsSecondto0x1010, whileFirstis0x20(line 301). On Windows the host page is 4 KiB on x64, so the two ranges round to different host pages and the test does not reach the case the description names, a later range in a page that is already committed. Keeping both in one page would need only a small change:Not verified
allocate,pattern,copyFrame,FrameCaptureReader,at,readFile,check) were not read at head. Only the diff hunks oftests/FrameReplay.cppwere read.WindowsMappings::Commit: the description says a range in an already committed page only changes that page's protection. The reader search at head did not find its definition, so this was not checked.commitsets every touched host page to read-write (0x04) on Windows, including bytes outside the captured range. The effect on neighbouring ranges was not checked.agc_driver_frame_replay_subpageon Linux as well as Windows (tests/cmake/agc_driver_frame_replay_tests.cmake:2,:23). No Linux run was reported.ctestresult, and the negative control come from the description. They were not reproduced here.To get this to a good state
Nothing is required. The optional point is under Findings.
Sources
commitat headImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T23:00:51Z.
Review: APPROVED
Reviewed — looks good
The changed code implements Windows page-rounded commits for replayed ranges; all four changed files and their added lines were read, and no concrete defect was found in the inspected code.
What I ran
No commands were run. Reviewed head
da111246be6a0456a853a7a0fd838fed31e12af0using the supplied diff andrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Builds, tests, Linux behavior, and console behavior were not independently verified. The author reports Windows 11 testing and passing replay tests. No files were excluded from the review; all four changed files listed in the manifest were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-18T14:29:11Z.
Review: COMMENTED
Tested on NVIDIA, since the description's run is on an AMD iGPU.
Setup: Windows 11 Pro (build 26300), AMD Ryzen 5 3400G, NVIDIA GeForce RTX 2060 (driver 621.24), WinLibs GCC 15.2.0, Release. Base:
main1118567b8bwith #22373 (a test-build fix only). "This PR" is the same tree with headda111246bemerged.All
^agc_driver_frame_replaytests, 3 runs each, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1(ctest -V, validation layer 1.4.363):not foundlinesVUID-mainThe extra test is the new
agc_driver_frame_replay_subpage, which passes in every run. No new validation errors.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T01:12:48Z.
Review: APPROVED
Reviewed — looks good
The Windows page rounding change and its regression test are consistent with the stated sub-page replay failure; no blocking defect was found in the changed code read.
What I ran
Reviewed head
bfa37d58c46743d17e325d39c50b8d3d92b4878einboykopovar/AnyPS5. Read the prepared description, commits, diff, manifest, and all four changed files; inspected the affected replay logic and test registration withrepo_read.pyreader tools. No build or test commands were run. The description reports Windows 11 tests and notes Linux was not run; those results were not independently verified.Results
files.jsonwas unavailableFindings
Blocking
None.
Non-blocking
None.
Not verified
The runtime behavior, reported test outcomes, and validation on Linux were not independently verified.
files.jsonwas unavailable, so the excluded-file list could not be checked.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T13:32:31Z.
Review: APPROVED
Reviewed — looks good
The change rounds Windows replay commits to host-page boundaries and adds coverage for multiple sub-page ranges that share committed pages.
What I ran
Reviewed head
4960cbb5ff4318ab23bfa29992192edd1e65cc3c. No commands or tests were run in this review session; the test results in the PR description are author-reported.Read all changed files:
core/libs/prx/libSceAgcDriver/tools/FrameReplay.cpp,core/libs/prx/libSceAgcDriver/tests/FrameReplay.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_frame_replay_tests.cmake, anddocs/dev/BUILD.md. All four are listed as included inreview/manifest.json; no excluded-file list was available.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported Windows test suite and negative control were not independently rerun. Linux runtime behavior was not tested in this review session.
To get this to a good state
Nothing is required.
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.