fix(agc): capture GPU-only allocations in frame captures #21931
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21931"
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 klosixgaming-arch on 2026-11-16T22:08:40Z.
What
agc_frame_replaycould not replay a Cyberpunk 2077 (PPSA03974) title-screen capture on Windows or on Linux: it stops at the first dispatch withcompute shader 0x1aa4e53100: AGC graphics: storage texture has no committed guest pages. The storage image it builds is a 3200x1800 surface at0x2426ce0000(0x1770000 bytes), and the capture holds no range there.FrameRecorder::committedRangesskips every registered allocation whosereadableflag is clear. libkernel registers a direct mapping withreadable = (prot & 3) != 0, so GPU-only memory (SCE_KERNEL_PROT_GPU_READ | GPU_WRITE, no CPU bits) is never captured, althoughLinuxProtFromScemaps it read-write on the host and the driver reads and writes it there. This PR captures those allocations too. Their access getsReadableonly when the guest can read them, so the replay registers them as the title did (readableandwritablefalse,gputrue). Both the Windows and the Linux branches ofcommittedRangeschange; the late-range path (newRanges) uses the same function.BUILD.mdsays which allocations the snapshot holds.New test
agc_driver_frame_replay_gpu_only: a 1 MiB block registered GPU-only holds a pattern, a DMA copy moves it into a normal block during the captured frames, and the test checks that the capture holds the GPU-only block withGpuand withoutReadableaccess and that the replay reproduces the copy.Tested
Ubuntu 26.04.1 (Linux 7.0.0-43), NVIDIA GeForce RTX 2080 Ti (595.99.02), Xeon E5-2699 v3, GCC 15.2.0 Release. I first tested this change on top of
maine4caa07950. Then I rebased it ontomainec9f142628(no conflicts) and rebuilt. The "Rebased head" item and the conventions check ran on that rebased head; the rest ran on the first build.FrameRecorder.cppreverted tomain,agc_driver_frame_replay_gpu_onlyfails:FAILED: the capture left out the GPU-only range or recorded it as readable by the CPU. With the change it passes.ctest -R 'frame_(capture|replay)' -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(layer 1.4.341),VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1: 57/57 passed on this branch. Onmain55 of 56 passed andframe_capture_minimizedid not run, because that tree didn't have its executable built.Insert instance layer "VK_LAYER_KHRONOS_validation"is in both logs, there's nowas not found but was requested, and there are 0VUID-lines in both.APS5_FRAME_CAPTUREwithAPS5_FRAME_CAPTURE_TRIGGERcreated 5 s after the title appears: 10 frames, 430 calls, 71 memory deltas, 992 MiB on disk. The capture frommainfails as above. The capture from this branch replays:--repeat 4gave pass p50s of 200.5, 191.0, 187.7 and 204.8 ms, with no pace timeouts and identical pixels.ctest -R '^agc_driver_frame_replay' -Vwith the same validation setup: 48/48 passed, among themagc_driver_frame_replay_gpu_only. The layer was inserted in 47 of them, with nowas not found but was requestedand 0VUID-lines.python3 tools/check_conventions.py --base origin/main: passed.frame_(capture|replay)passes 57 of 57 with this PR on both, andframe_replay_gpu_onlyfails 3 of 3 withFrameRecorder.cppfrommain(comment). There,VirtualQueryreports the test's GPU-only block asMEM_COMMIT,MEM_PRIVATE,PAGE_READWRITE, so the host can read it as on Linux, and its access staysGpuwithoutReadable.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T20:40:37Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional. The change captures GPU-only allocations without giving the CPU read access, and the code I read matches the description. The Windows path is not verified, so this stays a comment.
What I ran
e5b0cd225c9fd32d93c2bc8774b3114520b0b4e3(basemain).repo_read.py:FrameRecorder.cpplines 680–764 (committedRanges, both branches),FrameReplay.cpplines 141–160 (allocate), and a search for theFrameRangeAccess::Readableandreadableuses in the driver.Results
Gpuand withoutReadablectestcheck_conventions.pyFindings
Blocking
None.
Non-blocking
None from the code I read.
Not verified
committedRanges(FrameRecorder.cpplines 691–708) for GPU-only memory: I did not confirm what page protection the host gives such a range there. Linux maps it read-write, per the description.ctestruns and the validation-layer runs: author-reported on the stated revision, not rerun here.FrameReplay.cpptest body beyond the diff hunks, and theBUILD.mdparagraph beyond the changed line (docs/dev/BUILD.md:265): read throughdiff.patchonly.FrameRecorder.cpp(committedRangesat head, plus the diff hunks),FrameReplay.cpp(allocateat head, plus the diff hunks),agc_driver_frame_replay_tests.cmakeanddocs/dev/BUILD.md(diff only). Excluded by rule: none.To get this to a good state
Nothing is required. Optional: state in the PR body what a GPU-only allocation looks like on Windows, or run
agc_driver_frame_replay_gpu_onlythere.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T05:03:16Z.
Review: APPROVED
Reviewed — looks good
Nothing in the reviewed change blocks merging; the code and test coverage support the stated fix.
What I ran
Reviewed head
082db2262ad59a74da6f8518151bbaad1ad7320d. No tests or build commands were run; the test results below are author-reported. I readdescription.md,commits.md,manifest.json,diff.patch, and all four changed files:core/libs/prx/libSceAgcDriver/Execution/src/FrameRecorder.cpp,core/libs/prx/libSceAgcDriver/tests/FrameReplay.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_frame_replay_tests.cmake, anddocs/dev/BUILD.md. No files were excluded bymanifest.json;files.jsonwas unavailable through the reader.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Builds, tests, Windows and Linux runtime behavior, and the reported Cyberpunk 2077 replay were not independently run.
files.jsoncould not be read; exclusion details beyond the complete four-filemanifest.jsonare not verified.To get this to a good state
Nothing is required.