feat(agc): capture frames at the driver boundary and replay them offline #8740

Merged
Sam-mon7 merged 7 commits from upstream-pr/8740 into main 2026-10-24 05:03:41 +00:00
Sam-mon7 commented 2026-10-20 23:11:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-20T23:11:00Z.


What

A frame capture at the AGC driver boundary and a tool that replays it through the driver with no title running, so a driver change can be run against a few real frames of a title in a minute or two instead of a full boot, load and route per run.

  • APS5_FRAME_CAPTURE=<dir> records, from process start, the shader registrations and ABI resolutions, video output registrations and unregistrations, and EOP flip reservations. At a frame boundary (APS5_FRAME_CAPTURE_AT_FLIP, or the file APS5_FRAME_CAPTURE_TRIGGER names appearing) it waits for the driver to go idle and snapshots every readable guest allocation of the allocation registry (zstd, all-zero 64 KiB blocks skipped). For the next APS5_FRAME_CAPTURE_FRAMES frames it records each submission, flip and suspend point with its thread and serial progress, preceded by the pages the write tracker saw the CPU write before it (GuestMemory::CollectWrittenBlocks), plus the blocks holding the code of each registered or resolved shader. At the end it stores the presented display buffers as reference images.
  • agc_frame_replay <capture> maps the memory back at its addresses, repeats the registrations and replays each captured thread's calls on its own thread in captured order; memory deltas and video output registration and unregistration complete before the next captured call starts. It paces GPU work to the in-flight depth the title had, and releases GPU waits that the title's CPU threads released without calling the driver, using the new AgcDriverAwaitedWaits (per-queue blocked wait fields, one atomic store per blocked wait). It prints one JSON line: frame times, released waits (recorded, earlier or derived), unfinished submissions, and the share of identical pixels against the reference images (--frames writes both images).
  • Off by default; with the switch unset the cost is one static pointer test per entry point and the per-queue wait fields above.
  • Limits are in the libSceAgcDriver debt file: Windows only; section/alias/file views replayed as private memory; title image pages tracked only for shader data; cross-thread order and some wait releases are reconstructed, and counted.

Changes since review

  • 59638297ce: an EOP flip ended a frame both at its reservation and at the submission that releases its token, so it counted twice; only the submission ends a frame now. agc_driver_frame_capture_eop captures three of six EOP frames and checks the counts (fails on the first commit).
  • 4acf448602, five replay fidelity fixes, each with a test:
    • memory deltas could be applied after a later call of another thread had started, and a wait release could run during delta application: deltas and video output registration now complete before the next captured call, and wait releases are serialized with them (agc_driver_frame_replay_order; agc_driver_frame_replay_blocking checks that a submission, flip or reservation that blocks until a later delta lands still completes);
    • shader deltas did not include the shader code itself (agc_driver_frame_replay_shader, agc_driver_frame_replay_shader_host);
    • concurrent automatic and explicit EOP token reservations could hand out the same token: both now reserve under one lock and the next automatic token stays above every explicit one (agc_driver_frame_replay_tokens);
    • closing and reopening a video output handle aborted the replay: unregistration is captured as its own call (UnregisterVideoOutput; agc_driver_frame_replay now closes and reopens its output before and during the capture, agc_frame_capture round-trips the new call);
    • restoring the snapshot over memory the replay process had already mapped could leave nonzero bytes where the capture skipped an all-zero block: those ranges are cleared before the restore (agc_driver_frame_replay_zero).
  • 430a251603, two capture fixes found replaying Demon's Souls:
    • the recorder took its ranges once, at the snapshot, so submissions from memory the title committed during the captured frames replayed without it: each memory delta now adds the allocations the registry gained since the last one as new ranges with their nonzero blocks (late_ranges in the header; agc_driver_frame_replay copies its second frame from a block committed during the capture);
    • the flip count that decides whether a submission ended a frame was global, so a submission that overlapped another thread's flipping one ended the frame too: the count is per thread (agc_driver_frame_capture_eop checks that a flip submitted on another thread leaves this thread's count unchanged). Both tests fail without the fix.

Tested

Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 4070 (driver 610.88), WinLibs GCC 15.2.

  • agc_frame_capture (format round trip, zero-block elision, truncated and corrupt files), agc_driver_frame_capture_eop, the six agc_driver_frame_replay_* state tests above, and agc_driver_frame_replay (two captured frames of CPU writes and DMA copies replayed in agc_frame_replay, copies compared, output closed and reopened): pass.
  • Focused tests with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R '^agc_(frame_capture|driver_frame_capture_eop|driver_frame_replay.*|driver_flip.*|driver_pm4.*|driver_wait_shutdown|driver_eop_interrupts|driver_graphics|driver_bda_device|driver_compute_table_calls|driver_dispatch_move|driver_draw_cache_reuse)$' -V: main 7e95bde794 25/25; this PR at 4acf448602 on eea640a5bf 34/34 (the same 25 plus the nine new tests), and again at 430a251603 34/34. Neither log has "was not found but was requested by env var VK_INSTANCE_LAYERS"; 0 VUID- lines in both (the loader inserts VK_LAYER_KHRONOS_validation, checked with VK_LOADER_DEBUG=all).
  • Demon's Souls (PPSA01341 01.007.000) in the Nexus, captured and replayed with the first commit plus #8394 (main did not boot it without that fix); not yet repeated with the fixes above:
    • 10-frame capture (400 submissions, 3.1 GiB on disk) replayed to completion in every run (0 unfinished).
    • 20-frame capture (800 submissions, 3.9 GiB) replayed to completion; 395 waits released, 12 of them derived; replayed display buffers match the captured frames visually (45% of pixels identical, differences in the background effects that depend on timing).
    • Repeatability: three replays of the 10-frame capture with unlocked clocks took 90.6, 117.4 and 108.4 s; with clocks locked (nvidia-smi -lgc 2400,3135 -lmc 10501) 80.3, 71.9 and 69.9 s (first run warms up), median frame 5.6, 5.3, 5.2 s.

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
  • 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 4070, driver 610.88, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4943811515 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-20T23:11:00Z. --- ### What A frame capture at the AGC driver boundary and a tool that replays it through the driver with no title running, so a driver change can be run against a few real frames of a title in a minute or two instead of a full boot, load and route per run. - `APS5_FRAME_CAPTURE=<dir>` records, from process start, the shader registrations and ABI resolutions, video output registrations and unregistrations, and EOP flip reservations. At a frame boundary (`APS5_FRAME_CAPTURE_AT_FLIP`, or the file `APS5_FRAME_CAPTURE_TRIGGER` names appearing) it waits for the driver to go idle and snapshots every readable guest allocation of the allocation registry (zstd, all-zero 64 KiB blocks skipped). For the next `APS5_FRAME_CAPTURE_FRAMES` frames it records each submission, flip and suspend point with its thread and serial progress, preceded by the pages the write tracker saw the CPU write before it (`GuestMemory::CollectWrittenBlocks`), plus the blocks holding the code of each registered or resolved shader. At the end it stores the presented display buffers as reference images. - `agc_frame_replay <capture>` maps the memory back at its addresses, repeats the registrations and replays each captured thread's calls on its own thread in captured order; memory deltas and video output registration and unregistration complete before the next captured call starts. It paces GPU work to the in-flight depth the title had, and releases GPU waits that the title's CPU threads released without calling the driver, using the new `AgcDriverAwaitedWaits` (per-queue blocked wait fields, one atomic store per blocked wait). It prints one JSON line: frame times, released waits (recorded, earlier or derived), unfinished submissions, and the share of identical pixels against the reference images (`--frames` writes both images). - Off by default; with the switch unset the cost is one static pointer test per entry point and the per-queue wait fields above. - Limits are in the libSceAgcDriver debt file: Windows only; section/alias/file views replayed as private memory; title image pages tracked only for shader data; cross-thread order and some wait releases are reconstructed, and counted. ### Changes since review - 59638297ce: an EOP flip ended a frame both at its reservation and at the submission that releases its token, so it counted twice; only the submission ends a frame now. `agc_driver_frame_capture_eop` captures three of six EOP frames and checks the counts (fails on the first commit). - 4acf448602, five replay fidelity fixes, each with a test: - memory deltas could be applied after a later call of another thread had started, and a wait release could run during delta application: deltas and video output registration now complete before the next captured call, and wait releases are serialized with them (`agc_driver_frame_replay_order`; `agc_driver_frame_replay_blocking` checks that a submission, flip or reservation that blocks until a later delta lands still completes); - shader deltas did not include the shader code itself (`agc_driver_frame_replay_shader`, `agc_driver_frame_replay_shader_host`); - concurrent automatic and explicit EOP token reservations could hand out the same token: both now reserve under one lock and the next automatic token stays above every explicit one (`agc_driver_frame_replay_tokens`); - closing and reopening a video output handle aborted the replay: unregistration is captured as its own call (`UnregisterVideoOutput`; `agc_driver_frame_replay` now closes and reopens its output before and during the capture, `agc_frame_capture` round-trips the new call); - restoring the snapshot over memory the replay process had already mapped could leave nonzero bytes where the capture skipped an all-zero block: those ranges are cleared before the restore (`agc_driver_frame_replay_zero`). - 430a251603, two capture fixes found replaying Demon's Souls: - the recorder took its ranges once, at the snapshot, so submissions from memory the title committed during the captured frames replayed without it: each memory delta now adds the allocations the registry gained since the last one as new ranges with their nonzero blocks (`late_ranges` in the header; `agc_driver_frame_replay` copies its second frame from a block committed during the capture); - the flip count that decides whether a submission ended a frame was global, so a submission that overlapped another thread's flipping one ended the frame too: the count is per thread (`agc_driver_frame_capture_eop` checks that a flip submitted on another thread leaves this thread's count unchanged). Both tests fail without the fix. ### Tested Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 4070 (driver 610.88), WinLibs GCC 15.2. - `agc_frame_capture` (format round trip, zero-block elision, truncated and corrupt files), `agc_driver_frame_capture_eop`, the six `agc_driver_frame_replay_*` state tests above, and `agc_driver_frame_replay` (two captured frames of CPU writes and DMA copies replayed in `agc_frame_replay`, copies compared, output closed and reopened): pass. - Focused tests with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -R '^agc_(frame_capture|driver_frame_capture_eop|driver_frame_replay.*|driver_flip.*|driver_pm4.*|driver_wait_shutdown|driver_eop_interrupts|driver_graphics|driver_bda_device|driver_compute_table_calls|driver_dispatch_move|driver_draw_cache_reuse)$' -V`: main 7e95bde794 25/25; this PR at 4acf448602 on eea640a5bf 34/34 (the same 25 plus the nine new tests), and again at 430a251603 34/34. Neither log has "was not found but was requested by env var VK_INSTANCE_LAYERS"; 0 `VUID-` lines in both (the loader inserts VK_LAYER_KHRONOS_validation, checked with `VK_LOADER_DEBUG=all`). - Demon's Souls (PPSA01341 01.007.000) in the Nexus, captured and replayed with the first commit plus #8394 (main did not boot it without that fix); not yet repeated with the fixes above: - 10-frame capture (400 submissions, 3.1 GiB on disk) replayed to completion in every run (0 unfinished). - 20-frame capture (800 submissions, 3.9 GiB) replayed to completion; 395 waits released, 12 of them derived; replayed display buffers match the captured frames visually (45% of pixels identical, differences in the background effects that depend on timing). - Repeatability: three replays of the 10-frame capture with unlocked clocks took 90.6, 117.4 and 108.4 s; with clocks locked (`nvidia-smi -lgc 2400,3135 -lmc 10501`) 80.3, 71.9 and 69.9 s (first run warms up), median frame 5.6, 5.3, 5.2 s. ### Checklist - [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) - [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 4070, driver 610.88, Windows 11 Pro 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-20 23:12:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T23:12:28Z.

Code review location: core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp; line 128

@@ -103,11 +120,36 @@ extern "C" void AgcDriverSuspendPoint_nid_postfix() try {
 }
 
 extern "C" std::uint32_t AgcDriverReserveEopFlip_nid_postfix(const AgcDriver::FlipInfo& info) {
-    return AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info);
+    const auto token = AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info);
+    if (auto* const recorder = AgcDriver::FrameRecorder::Active(); recorder != nullptr && token != 0) {
+        recorder->ReserveEopFlip(info, token);
+        recorder->FrameBoundary();
+    }
+    return token;

Could you verify the EOP path does not count one displayed frame twice? ReserveEopFlip records a pending token here, and later Driver::Submit consumes that token into submission.flips; the Submit wrapper also calls FrameBoundary() when FlipSubmissions() changes. For EOP-driven titles both events appear to represent the same flip, so APS5_FRAME_CAPTURE_FRAMES=N may stop after about N/2 displayed frames (and the first capture boundary may fire at reservation time). Could you deduplicate these signals or add a focused regression test that exercises reserve + submit and asserts the captured frame count?

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4331316961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740#discussion_r4331316961). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T23:12:28Z. **Code review location:** `core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp`; line 128 ~~~~diff @@ -103,11 +120,36 @@ extern "C" void AgcDriverSuspendPoint_nid_postfix() try { } extern "C" std::uint32_t AgcDriverReserveEopFlip_nid_postfix(const AgcDriver::FlipInfo& info) { - return AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info); + const auto token = AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info); + if (auto* const recorder = AgcDriver::FrameRecorder::Active(); recorder != nullptr && token != 0) { + recorder->ReserveEopFlip(info, token); + recorder->FrameBoundary(); + } + return token; ~~~~ --- Could you verify the EOP path does not count one displayed frame twice? `ReserveEopFlip` records a pending token here, and later `Driver::Submit` consumes that token into `submission.flips`; the `Submit` wrapper also calls `FrameBoundary()` when `FlipSubmissions()` changes. For EOP-driven titles both events appear to represent the same flip, so `APS5_FRAME_CAPTURE_FRAMES=N` may stop after about N/2 displayed frames (and the first capture boundary may fire at reservation time). Could you deduplicate these signals or add a focused regression test that exercises reserve + submit and asserts the captured frame count?
Sam-mon7 commented 2026-10-20 23:18:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-20T23:18:38Z.

Code review location: core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp; line 128

@@ -103,11 +120,36 @@ extern "C" void AgcDriverSuspendPoint_nid_postfix() try {
 }
 
 extern "C" std::uint32_t AgcDriverReserveEopFlip_nid_postfix(const AgcDriver::FlipInfo& info) {
-    return AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info);
+    const auto token = AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info);
+    if (auto* const recorder = AgcDriver::FrameRecorder::Active(); recorder != nullptr && token != 0) {
+        recorder->ReserveEopFlip(info, token);
+        recorder->FrameBoundary();
+    }
+    return token;

Confirmed, thanks. reserveOutputs puts the flip of an EOP release with a reserved token into submission.flips, so the Submit wrapper ended the same displayed frame a second time after ReserveEopFlip had already ended it, and a capture could start between the reservation and the submission that flips.

Fixed in 59638297ce: the reservation is still recorded (the replay needs its token) but no longer ends a frame. A frame now ends only at a CPU flip or at a submission that flips (a flip packet, or the EOP release of a reserved token).

Added agc_driver_frame_capture_eop: it reserves and submits six EOP flips with APS5_FRAME_CAPTURE_FRAMES=3 and asserts that the capture starts after the first flipping submission and holds three frames with exactly one reservation and one submission each. On the previous commit it fails with "the capture started between a reservation and the submission that flips it"; with the fix it passes (3/3 runs, also with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, no VUID- lines). BUILD.md and ENVIRONMENT.md now describe frame boundaries this way.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4331357811 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740#discussion_r4331357811). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-20T23:18:38Z. **Code review location:** `core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp`; line 128 ~~~~diff @@ -103,11 +120,36 @@ extern "C" void AgcDriverSuspendPoint_nid_postfix() try { } extern "C" std::uint32_t AgcDriverReserveEopFlip_nid_postfix(const AgcDriver::FlipInfo& info) { - return AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info); + const auto token = AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info); + if (auto* const recorder = AgcDriver::FrameRecorder::Active(); recorder != nullptr && token != 0) { + recorder->ReserveEopFlip(info, token); + recorder->FrameBoundary(); + } + return token; ~~~~ --- Confirmed, thanks. `reserveOutputs` puts the flip of an EOP release with a reserved token into `submission.flips`, so the `Submit` wrapper ended the same displayed frame a second time after `ReserveEopFlip` had already ended it, and a capture could start between the reservation and the submission that flips. Fixed in 59638297ce: the reservation is still recorded (the replay needs its token) but no longer ends a frame. A frame now ends only at a CPU flip or at a submission that flips (a flip packet, or the EOP release of a reserved token). Added `agc_driver_frame_capture_eop`: it reserves and submits six EOP flips with `APS5_FRAME_CAPTURE_FRAMES=3` and asserts that the capture starts after the first flipping submission and holds three frames with exactly one reservation and one submission each. On the previous commit it fails with "the capture started between a reservation and the submission that flips it"; with the fix it passes (3/3 runs, also with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, no `VUID-` lines). BUILD.md and ENVIRONMENT.md now describe frame boundaries this way.
MarcZX10 commented 2026-10-20 23:22:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T23:22:21Z.

Review: APPROVED


The updated EOP boundary handling addresses the double-counting issue: reservations remain recorded for replay, and only the submission that carries the token advances the frame boundary. The new regression checks both the captured frame count and that capture does not start between reservation and submission. The author reports three Linux runs with Vulkan validation; hosted build/runtime jobs for this head were skipped, so those checks are not available here.

Small documentation nit: in docs/dev/BUILD.md, the sentence listing agc_frame_capture and agc_driver_frame_capture_eop needs “and” between the test descriptions.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5593041508 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740#pullrequestreview-5593041508). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T23:22:21Z. **Review:** APPROVED --- The updated EOP boundary handling addresses the double-counting issue: reservations remain recorded for replay, and only the submission that carries the token advances the frame boundary. The new regression checks both the captured frame count and that capture does not start between reservation and submission. The author reports three Linux runs with Vulkan validation; hosted build/runtime jobs for this head were skipped, so those checks are not available here. Small documentation nit: in docs/dev/BUILD.md, the sentence listing agc_frame_capture and agc_driver_frame_capture_eop needs “and” between the test descriptions.
MarcZX10 commented 2026-10-20 23:37:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T23:37:30Z.


Thanks for checking the EOP path and adding the focused test. I reviewed the updated Submit/ReserveEopFlip changes and agc_driver_frame_capture_eop: the reservation remains captured for replay, but the frame boundary now comes from the flipping submission, and the test checks that capture begins at the reservation and contains exactly three reservations plus three submissions. That resolves the double-count/start-between concern I raised. The hosted platform/runtime jobs are still skipped, so I’m acknowledging this specific issue rather than treating it as full validation of the entire PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304242010 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740#issuecomment-6304242010). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T23:37:30Z. --- Thanks for checking the EOP path and adding the focused test. I reviewed the updated `Submit`/`ReserveEopFlip` changes and `agc_driver_frame_capture_eop`: the reservation remains captured for replay, but the frame boundary now comes from the flipping submission, and the test checks that capture begins at the reservation and contains exactly three reservations plus three submissions. That resolves the double-count/start-between concern I raised. The hosted platform/runtime jobs are still skipped, so I’m acknowledging this specific issue rather than treating it as full validation of the entire PR.
MarcZX10 commented 2026-10-21 00:13:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T00:13:41Z.

Code review location: core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp; line 128

@@ -103,11 +120,36 @@ extern "C" void AgcDriverSuspendPoint_nid_postfix() try {
 }
 
 extern "C" std::uint32_t AgcDriverReserveEopFlip_nid_postfix(const AgcDriver::FlipInfo& info) {
-    return AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info);
+    const auto token = AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info);
+    if (auto* const recorder = AgcDriver::FrameRecorder::Active(); recorder != nullptr && token != 0) {
+        recorder->ReserveEopFlip(info, token);
+        recorder->FrameBoundary();
+    }
+    return token;

Thanks for the regression details. I checked the updated implementation and test wiring; this addresses the double-boundary concern I raised. The thread remains visible because GitHub denies my account permission to resolve it. The hosted runtime jobs for this head are skipped, so I am treating your local 3/3 Vulkan-validated runs as reported evidence, not hosted CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4331688029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740#discussion_r4331688029). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T00:13:41Z. **Code review location:** `core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp`; line 128 ~~~~diff @@ -103,11 +120,36 @@ extern "C" void AgcDriverSuspendPoint_nid_postfix() try { } extern "C" std::uint32_t AgcDriverReserveEopFlip_nid_postfix(const AgcDriver::FlipInfo& info) { - return AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info); + const auto token = AgcDriver::DriverDetail::Driver::Get().ReserveEopFlip(info); + if (auto* const recorder = AgcDriver::FrameRecorder::Active(); recorder != nullptr && token != 0) { + recorder->ReserveEopFlip(info, token); + recorder->FrameBoundary(); + } + return token; ~~~~ --- Thanks for the regression details. I checked the updated implementation and test wiring; this addresses the double-boundary concern I raised. The thread remains visible because GitHub denies my account permission to resolve it. The hosted runtime jobs for this head are skipped, so I am treating your local 3/3 Vulkan-validated runs as reported evidence, not hosted CI.
oneandonlydean commented 2026-10-21 19:16:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T19:16:49Z.


@Sam-mon7 thanks for this. I looked into the Linux failures in our full CI run. agc_driver_frame_capture_eop, agc_driver_frame_replay, agc_driver_frame_replay_order and agc_driver_frame_replay_blocking each stop after about 0.02 s with guest arena: unmapped protection value. Windows is green.

The cause is the protection value passed to GuestArenaCommit_nid_postfix on non-Windows builds. In the #else branch of #ifdef _WIN32, the PR passes 3, which is POSIX PROT_READ | PROT_WRITE. The guest arena takes Windows PAGE_* values on every platform, though. On Linux, GuestArenaCommit_nid_postfix calls PlaceAt, and PosixProtection() in core/libs/prx/libc/src/GuestArena.cpp maps only 0x01..0x40 to POSIX flags and throws for anything else. That's also how the Linux code on main calls it: DirectMemory.cpp converts with WinProtFromPosix(prot) first.

It happens in four places:

  • core/libs/prx/libSceAgcDriver/tests/FrameCaptureEop.cpp:65
  • core/libs/prx/libSceAgcDriver/tests/FrameReplay.cpp:88
  • core/libs/prx/libSceAgcDriver/tests/FrameReplayState.cpp:25
  • core/libs/prx/libSceAgcDriver/tools/FrameReplay.cpp:228

The last one is the replay tool itself, so a replay on Linux would throw the same way, not only the tests.

The fix is to pass 0x04 (the value of PAGE_READWRITE) on all platforms and drop the #ifdef at those four sites. A named constant such as constexpr std::uint32_t ArenaReadWrite = 0x04; would keep it readable on Linux, where PAGE_READWRITE isn't defined.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6324442822 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8740#issuecomment-6324442822). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T19:16:49Z. --- @Sam-mon7 thanks for this. I looked into the Linux failures in our full CI run. `agc_driver_frame_capture_eop`, `agc_driver_frame_replay`, `agc_driver_frame_replay_order` and `agc_driver_frame_replay_blocking` each stop after about 0.02 s with `guest arena: unmapped protection value`. Windows is green. The cause is the protection value passed to `GuestArenaCommit_nid_postfix` on non-Windows builds. In the `#else` branch of `#ifdef _WIN32`, the PR passes `3`, which is POSIX `PROT_READ | PROT_WRITE`. The guest arena takes Windows `PAGE_*` values on every platform, though. On Linux, `GuestArenaCommit_nid_postfix` calls `PlaceAt`, and `PosixProtection()` in `core/libs/prx/libc/src/GuestArena.cpp` maps only `0x01`..`0x40` to POSIX flags and throws for anything else. That's also how the Linux code on `main` calls it: `DirectMemory.cpp` converts with `WinProtFromPosix(prot)` first. It happens in four places: - `core/libs/prx/libSceAgcDriver/tests/FrameCaptureEop.cpp:65` - `core/libs/prx/libSceAgcDriver/tests/FrameReplay.cpp:88` - `core/libs/prx/libSceAgcDriver/tests/FrameReplayState.cpp:25` - `core/libs/prx/libSceAgcDriver/tools/FrameReplay.cpp:228` The last one is the replay tool itself, so a replay on Linux would throw the same way, not only the tests. The fix is to pass `0x04` (the value of `PAGE_READWRITE`) on all platforms and drop the `#ifdef` at those four sites. A named constant such as `constexpr std::uint32_t ArenaReadWrite = 0x04;` would keep it readable on Linux, where `PAGE_READWRITE` isn't defined.
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!8740
No description provided.