fix(agc): capture GPU-only allocations in frame captures #21931

Merged
klosixgaming-arch merged 2 commits from upstream-pr/21931 into main 2026-11-26 02:51:41 +00:00
klosixgaming-arch commented 2026-11-16 22:08:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-11-16T22:08:40Z.


What

agc_frame_replay could not replay a Cyberpunk 2077 (PPSA03974) title-screen capture on Windows or on Linux: it stops at the first dispatch with compute shader 0x1aa4e53100: AGC graphics: storage texture has no committed guest pages. The storage image it builds is a 3200x1800 surface at 0x2426ce0000 (0x1770000 bytes), and the capture holds no range there.

FrameRecorder::committedRanges skips every registered allocation whose readable flag is clear. libkernel registers a direct mapping with readable = (prot & 3) != 0, so GPU-only memory (SCE_KERNEL_PROT_GPU_READ | GPU_WRITE, no CPU bits) is never captured, although LinuxProtFromSce maps it read-write on the host and the driver reads and writes it there. This PR captures those allocations too. Their access gets Readable only when the guest can read them, so the replay registers them as the title did (readable and writable false, gpu true). Both the Windows and the Linux branches of committedRanges change; the late-range path (newRanges) uses the same function. BUILD.md says 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 with Gpu and without Readable access 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 main e4caa07950. Then I rebased it onto main ec9f142628 (no conflicts) and rebuilt. The "Rebased head" item and the conventions check ran on that rebased head; the rest ran on the first build.

  • With FrameRecorder.cpp reverted to main, agc_driver_frame_replay_gpu_only fails: 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)' -V with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer 1.4.341), VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1: 57/57 passed on this branch. On main 55 of 56 passed and frame_capture_minimize did not run, because that tree didn't have its executable built. Insert instance layer "VK_LAYER_KHRONOS_validation" is in both logs, there's no was not found but was requested, and there are 0 VUID- lines in both.
  • Cyberpunk 2077 PPSA03974 02.120.000, title screen, APS5_FRAME_CAPTURE with APS5_FRAME_CAPTURE_TRIGGER created 5 s after the title appears: 10 frames, 430 calls, 71 memory deltas, 992 MiB on disk. The capture from main fails as above. The capture from this branch replays:
{"frames":10,"replay_s":3.255,"fps":3.073,"frame_ms":{"p50":198.262,"p90":292.588,"max":292.588,"each":[272,161,155,205,172,190,274,292,198]},"passes":[{"replay_s":3.255,"frames":10,"p50":198.262,"pace_timeouts":0,"synthesized":0}],"kept_reservations":0,"submits":60,"delta_mib":265.1,"park_restores":0,"pace_timeouts":0,"pace_wait_s":2.145,"stale_registrations":0,"failed_registrations":0,"skipped_mib":0.0,"threads":9,"released_waits":0,"of_them_from_earlier_writes":0,"of_them_synthesized":0,"unfinished":0,"frames_compared":2,"pixels_identical":1.000000,"max_channel_diff":0,"load_s":4.564,"journal_s":0.003}

--repeat 4 gave pass p50s of 200.5, 191.0, 187.7 and 204.8 ms, with no pace timeouts and identical pixels.

  • Rebased head: ctest -R '^agc_driver_frame_replay' -V with the same validation setup: 48/48 passed, among them agc_driver_frame_replay_gpu_only. The layer was inserted in 47 of them, with no was not found but was requested and 0 VUID- lines.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • Windows: not run by me. @sharveshprabhu ran it on Windows 11 26300 with a Radeon 780M and an RTX 5060 Laptop GPU: frame_(capture|replay) passes 57 of 57 with this PR on both, and frame_replay_gpu_only fails 3 of 3 with FrameRecorder.cpp from main (comment). There, VirtualQuery reports the test's GPU-only block as MEM_COMMIT, MEM_PRIVATE, PAGE_READWRITE, so the host can read it as on Linux, and its access stays Gpu without Readable.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 2080 Ti, driver 595.99.02, Ubuntu 26.04.1 (Linux 7.0.0-43)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5346072885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21931). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-11-16T22:08:40Z. --- ### What `agc_frame_replay` could not replay a Cyberpunk 2077 (PPSA03974) title-screen capture on Windows or on Linux: it stops at the first dispatch with `compute shader 0x1aa4e53100: AGC graphics: storage texture has no committed guest pages`. The storage image it builds is a 3200x1800 surface at `0x2426ce0000` (0x1770000 bytes), and the capture holds no range there. `FrameRecorder::committedRanges` skips every registered allocation whose `readable` flag is clear. libkernel registers a direct mapping with `readable = (prot & 3) != 0`, so GPU-only memory (`SCE_KERNEL_PROT_GPU_READ | GPU_WRITE`, no CPU bits) is never captured, although `LinuxProtFromSce` maps it read-write on the host and the driver reads and writes it there. This PR captures those allocations too. Their access gets `Readable` only when the guest can read them, so the replay registers them as the title did (`readable` and `writable` false, `gpu` true). Both the Windows and the Linux branches of `committedRanges` change; the late-range path (`newRanges`) uses the same function. `BUILD.md` says 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 with `Gpu` and without `Readable` access 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 `main` `e4caa07950`. Then I rebased it onto `main` `ec9f142628` (no conflicts) and rebuilt. The "Rebased head" item and the conventions check ran on that rebased head; the rest ran on the first build. - With `FrameRecorder.cpp` reverted to `main`, `agc_driver_frame_replay_gpu_only` fails: `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)' -V` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (layer 1.4.341), `VK_LOADER_DEBUG=layer`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`: 57/57 passed on this branch. On `main` 55 of 56 passed and `frame_capture_minimize` did not run, because that tree didn't have its executable built. `Insert instance layer "VK_LAYER_KHRONOS_validation"` is in both logs, there's no `was not found but was requested`, and there are 0 `VUID-` lines in both. - Cyberpunk 2077 PPSA03974 02.120.000, title screen, `APS5_FRAME_CAPTURE` with `APS5_FRAME_CAPTURE_TRIGGER` created 5 s after the title appears: 10 frames, 430 calls, 71 memory deltas, 992 MiB on disk. The capture from `main` fails as above. The capture from this branch replays: ```json {"frames":10,"replay_s":3.255,"fps":3.073,"frame_ms":{"p50":198.262,"p90":292.588,"max":292.588,"each":[272,161,155,205,172,190,274,292,198]},"passes":[{"replay_s":3.255,"frames":10,"p50":198.262,"pace_timeouts":0,"synthesized":0}],"kept_reservations":0,"submits":60,"delta_mib":265.1,"park_restores":0,"pace_timeouts":0,"pace_wait_s":2.145,"stale_registrations":0,"failed_registrations":0,"skipped_mib":0.0,"threads":9,"released_waits":0,"of_them_from_earlier_writes":0,"of_them_synthesized":0,"unfinished":0,"frames_compared":2,"pixels_identical":1.000000,"max_channel_diff":0,"load_s":4.564,"journal_s":0.003} ``` `--repeat 4` gave pass p50s of 200.5, 191.0, 187.7 and 204.8 ms, with no pace timeouts and identical pixels. - Rebased head: `ctest -R '^agc_driver_frame_replay' -V` with the same validation setup: 48/48 passed, among them `agc_driver_frame_replay_gpu_only`. The layer was inserted in 47 of them, with no `was not found but was requested` and 0 `VUID-` lines. - `python3 tools/check_conventions.py --base origin/main`: passed. - Windows: not run by me. @sharveshprabhu ran it on Windows 11 26300 with a Radeon 780M and an RTX 5060 Laptop GPU: `frame_(capture|replay)` passes 57 of 57 with this PR on both, and `frame_replay_gpu_only` fails 3 of 3 with `FrameRecorder.cpp` from `main` ([comment](https://github.com/boykopovar/AnyPS5/pull/21931#issuecomment-6939561460)). There, `VirtualQuery` reports the test's GPU-only block as `MEM_COMMIT`, `MEM_PRIVATE`, `PAGE_READWRITE`, so the host can read it as on Linux, and its access stays `Gpu` without `Readable`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 2080 Ti, driver 595.99.02, Ubuntu 26.04.1 (Linux 7.0.0-43) - [x] AI-assisted: yes
MarcZX10 commented 2026-11-17 20:40:37 +00:00 (Migrated from github.com)

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

  • Head: e5b0cd225c9fd32d93c2bc8774b3114520b0b4e3 (base main).
  • Read the console folder: description, commits, manifest, diff and file list.
  • Read the house rules sections "Readable reviews", "Accuracy and evidence" and "Standard PR response format".
  • Read at head with repo_read.py: FrameRecorder.cpp lines 680–764 (committedRanges, both branches), FrameReplay.cpp lines 141–160 (allocate), and a search for the FrameRangeAccess::Readable and readable uses in the driver.
  • No build, no tests, no writes to the repository.

Results

Check Result Note
Diff matches the stated goal passed GPU-only allocations are now kept, with Gpu and without Readable
Build and ctest not run Author-reported only
Windows capture path not verified Author says not run on Windows
check_conventions.py not run Author-reported only

Findings

Blocking

None.

Non-blocking

None from the code I read.

Not verified

  • The Windows branch of committedRanges (FrameRecorder.cpp lines 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.
  • Build, the ctest runs and the validation-layer runs: author-reported on the stated revision, not rerun here.
  • The FrameReplay.cpp test body beyond the diff hunks, and the BUILD.md paragraph beyond the changed line (docs/dev/BUILD.md:265): read through diff.patch only.
  • Files read: FrameRecorder.cpp (committedRanges at head, plus the diff hunks), FrameReplay.cpp (allocate at head, plus the diff hunks), agc_driver_frame_replay_tests.cmake and docs/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_only there.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5946256739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21931#pullrequestreview-5946256739). Originally posted by [MarcZX10](https://github.com/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 - Head: `e5b0cd225c9fd32d93c2bc8774b3114520b0b4e3` (base `main`). - Read the console folder: description, commits, manifest, diff and file list. - Read the house rules sections "Readable reviews", "Accuracy and evidence" and "Standard PR response format". - Read at head with `repo_read.py`: `FrameRecorder.cpp` lines 680–764 (`committedRanges`, both branches), `FrameReplay.cpp` lines 141–160 (`allocate`), and a search for the `FrameRangeAccess::Readable` and `readable` uses in the driver. - No build, no tests, no writes to the repository. ## Results | Check | Result | Note | |---|---|---| | Diff matches the stated goal | passed | GPU-only allocations are now kept, with `Gpu` and without `Readable` | | Build and `ctest` | not run | Author-reported only | | Windows capture path | not verified | Author says not run on Windows | | `check_conventions.py` | not run | Author-reported only | ## Findings ### Blocking None. ### Non-blocking None from the code I read. ## Not verified - The Windows branch of `committedRanges` (`FrameRecorder.cpp` lines 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. - Build, the `ctest` runs and the validation-layer runs: author-reported on the stated revision, not rerun here. - The `FrameReplay.cpp` test body beyond the diff hunks, and the `BUILD.md` paragraph beyond the changed line (`docs/dev/BUILD.md:265`): read through `diff.patch` only. - Files read: `FrameRecorder.cpp` (`committedRanges` at head, plus the diff hunks), `FrameReplay.cpp` (`allocate` at head, plus the diff hunks), `agc_driver_frame_replay_tests.cmake` and `docs/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_only` there.
MarcZX10 commented 2026-11-22 05:03:16 +00:00 (Migrated from github.com)

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 read description.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, and docs/dev/BUILD.md. No files were excluded by manifest.json; files.json was unavailable through the reader.

Results

Check Result Note
Changed code review passed All four changed files read
Author-reported validation not run Linux and Windows results not independently verified
Build and tests by reviewer not run No commands executed

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.json could not be read; exclusion details beyond the complete four-file manifest.json are not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010481412 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21931#pullrequestreview-6010481412). Originally posted by [MarcZX10](https://github.com/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 read `description.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`, and `docs/dev/BUILD.md`. No files were excluded by `manifest.json`; `files.json` was unavailable through the reader. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All four changed files read | | Author-reported validation | not run | Linux and Windows results not independently verified | | Build and tests by reviewer | not run | No commands executed | ## 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.json` could not be read; exclusion details beyond the complete four-file `manifest.json` are not verified. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!21931
No description provided.