AGC frame capture: flips from REWIND tails are not frame boundaries, so APS5_FRAME_CAPTURE never starts in GTA V (PPSA04264) gameplay #12235

Closed
opened 2026-10-28 04:13:46 +00:00 by Tehshortbus · 0 comments
Tehshortbus commented 2026-10-28 04:13:46 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Tehshortbus on 2026-10-28T04:13:46Z.


What happens

During GTA V gameplay, APS5_FRAME_CAPTURE with APS5_FRAME_CAPTURE_TRIGGER never starts: the title presents its frames through flips that executeRewindTail attaches to REWIND tails, and those never reach FrameRecorder::FrameBoundary. When boundaries are counted for them (local change below), the capture still cannot start, because start()'s WaitIdleFor(10 s) times out at every boundary and gives up after five attempts.

@Sam-mon7, since this is the recorder from #8740 and #11435/#11436 touch the same files, I'd like your view on how a fix should look before anyone writes one.

Title, test or build step

Grand Theft Auto V, PPSA04264 01.011.001, from the main menu into Story mode (the opening cinematic).

AnyPS5 commit

main 86fb985abb with #11580 (fedf3e91a7) merged locally (aa67f59bb1), only so that the title gets past #11425 into gameplay. #11580 changes only the shader recompiler.

System

CachyOS Linux (kernel 7.3.0-4-cachyos), GCC 16.2.1, Release, NVIDIA GeForce RTX 4070 SUPER (615.78.08), 3840x2160, warm shader cache.

Steps to reproduce

APS5_FRAME_CAPTURE=<dir>/capture APS5_FRAME_CAPTURE_TRIGGER=<dir>/trigger APS5_FRAME_CAPTURE_FRAMES=4 \
APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_DIR=<dir>/trace setarch x86_64 -R ./app.elf

Start Story mode, then echo 4 > <dir>/trigger once gameplay (the cinematic) is running.

Log

1. Boundaries stop when gameplay starts. On aa67f59bb1, the trigger was created during the cinematic and no [frame-capture] line and no capture directory ever appeared, in two runs. For a third run I added two local debug lines (not part of any change): one in FrameRecorder::FrameBoundary printing every 300th boundary, and one next to ++flipSubmissionsOfThread() in Driver::Submit (Submission.cpp:466) printing every 300th submission that carries a flip. Both counters stop together at 2100:

[flip-debug] 1800 flip submissions, this one queue 0 cpuFlip 0
[frame-capture-debug] boundary 1800 state 0
[flip-debug] 2100 flip submissions, this one queue 0 cpuFlip 0
[frame-capture-debug] boundary 2100 state 0

while the same run's trace keeps presenting (2614 presents by 91 s; 2193 presents by 61 s, when Story mode starts and VideoOut.Flip gives way to Driver.Packet):

# seconds presents p50 largest phase
6 51-61 467 16.7 VideoOut.Flip 12.7
7 61-71 148 60.7 Driver.Packet 45.9
8 71-81 143 70.5 Driver.Packet 66.1
9 81-91 130 75.9 Driver.Packet 72.7

The only other place that attaches flips to a submission is Driver::executeRewindTail (Submission.cpp:369, reserveOutputs(tail)). It runs on the queue worker, does not go through AgcDriver::Submit, and so neither increments the flip count that EntryPoints.cpp:24 compares nor calls FrameBoundary.

2. With tail flips counted, start() never finds the driver idle. With the local change below, boundaries continue into gameplay and the trigger is seen, but:

[frame-capture] the driver did not go idle within 10 s at frame boundary 2326 (attempt 1)
[frame-capture] the driver did not go idle within 10 s at frame boundary 2327 (attempt 2)
[frame-capture] the driver did not go idle within 10 s at frame boundary 2328 (attempt 3)
[frame-capture] the driver did not go idle within 10 s at frame boundary 2329 (attempt 4)
[frame-capture] the driver did not go idle within 10 s at frame boundary 2330 (attempt 5)
[frame-capture] giving up: no idle frame boundary

The title froze for those 50 s (audio kept playing) and recovered once the recorder gave up. Queue 0 spent the time in Driver.Rewind:

# seconds presents p50 largest phase
7 61-80 135 64.2 Driver.Rewind 75.1
8 80-91 1 10120.7 Driver.Rewind 9804.5
9 91-101 1 10048.3 Driver.Rewind 9685.2
10 101-120 2 9948.4 Driver.Rewind 9665.1
11 120-130 140 70.2 Driver.Packet 67.3

That is consistent with a queue 0 submission parked at a REWIND whose valid bit the title sets from the thread that is blocked in WaitIdleFor inside FrameBoundary. I have not confirmed which thread sets it.

The local change used for part 2 (12 lines; not proposed as is, since on its own it turns "never starts" into these freezes):

--- a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp
+++ b/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp
@@ void Driver::executeRewindTail(const Submission& stalled) {
         reserveOutputs(tail);
+        if (!tail.flips.empty()) rewindTailFlips.fetch_add(1, std::memory_order_acq_rel);
--- a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp
+++ b/core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp
@@ void Submit(const Packet* packet, std::uint32_t queue) try {
     recorder->Submit(*packet, queue, [&] { driver.Submit(packet, queue); });
-    if (driver.FlipSubmissions() != flips) recorder->FrameBoundary();
+    static std::atomic<std::uint64_t> seenTailFlips{0};
+    const auto tailFlips = driver.RewindTailFlips();
+    const bool tailFlipped = seenTailFlips.exchange(tailFlips, std::memory_order_acq_rel) != tailFlips;
+    if (driver.FlipSubmissions() != flips || tailFlipped) recorder->FrameBoundary();

plus Driver::RewindTailFlips() returning a new std::atomic<std::uint64_t> rewindTailFlips member.

What was checked

  • Before gameplay the recorder works on the same build: with no trigger (started at frame boundary 1: 48 ranges, 319.3 MiB snapshot in 3.7 s), with the trigger file present from launch (same line), and with APS5_FRAME_CAPTURE_AT_FLIP=1000 at the main menu (started at frame boundary 1000: 96 ranges, 1326.2 MiB snapshot in 2.0 s). So the trigger check itself is fine; only the REWIND-tail flips are missing.
  • No open pull request changes executeRewindTail's flips, FrameBoundary or start()'s idle wait; #11435 and #11436 change the replay side and add tracing.
  • Not checked: any title other than GTA V; Windows or AMD; whether GTA V ever reaches a frame boundary with no REWIND parked (every attempt above blocked the title, which may itself have kept it parked); and replaying any gameplay capture, since none could be made.

Questions:

  1. Should a REWIND tail that carries a flip end a frame, and if so, should the boundary be taken at the title's next Submit (as above), since start() cannot wait for idle on the queue worker?
  2. For starting during gameplay: is it acceptable for start() to treat "every queue idle or parked at a REWIND the CPU has not released" as idle, with the parked submission recorded so agc_frame_replay can issue its tail when the captured CPU write releases it? Or would you rather start() check without blocking and retry at the next boundary?

I'm happy to test any change on GTA V, or write the fix in whichever shape you prefer.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6072490466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/12235). Originally posted by [Tehshortbus](https://github.com/Tehshortbus) on 2026-10-28T04:13:46Z. --- ### What happens During GTA V gameplay, `APS5_FRAME_CAPTURE` with `APS5_FRAME_CAPTURE_TRIGGER` never starts: the title presents its frames through flips that `executeRewindTail` attaches to REWIND tails, and those never reach `FrameRecorder::FrameBoundary`. When boundaries are counted for them (local change below), the capture still cannot start, because `start()`'s `WaitIdleFor(10 s)` times out at every boundary and gives up after five attempts. @Sam-mon7, since this is the recorder from #8740 and #11435/#11436 touch the same files, I'd like your view on how a fix should look before anyone writes one. ### Title, test or build step Grand Theft Auto V, PPSA04264 01.011.001, from the main menu into Story mode (the opening cinematic). ### AnyPS5 commit `main` `86fb985abb` with #11580 (`fedf3e91a7`) merged locally (`aa67f59bb1`), only so that the title gets past #11425 into gameplay. #11580 changes only the shader recompiler. ### System CachyOS Linux (kernel 7.3.0-4-cachyos), GCC 16.2.1, Release, NVIDIA GeForce RTX 4070 SUPER (615.78.08), 3840x2160, warm shader cache. ### Steps to reproduce ```sh APS5_FRAME_CAPTURE=<dir>/capture APS5_FRAME_CAPTURE_TRIGGER=<dir>/trigger APS5_FRAME_CAPTURE_FRAMES=4 \ APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_DIR=<dir>/trace setarch x86_64 -R ./app.elf ``` Start Story mode, then `echo 4 > <dir>/trigger` once gameplay (the cinematic) is running. ### Log **1. Boundaries stop when gameplay starts.** On `aa67f59bb1`, the trigger was created during the cinematic and no `[frame-capture]` line and no capture directory ever appeared, in two runs. For a third run I added two local debug lines (not part of any change): one in `FrameRecorder::FrameBoundary` printing every 300th boundary, and one next to `++flipSubmissionsOfThread()` in `Driver::Submit` (`Submission.cpp:466`) printing every 300th submission that carries a flip. Both counters stop together at 2100: ```text [flip-debug] 1800 flip submissions, this one queue 0 cpuFlip 0 [frame-capture-debug] boundary 1800 state 0 [flip-debug] 2100 flip submissions, this one queue 0 cpuFlip 0 [frame-capture-debug] boundary 2100 state 0 ``` while the same run's trace keeps presenting (2614 presents by 91 s; 2193 presents by 61 s, when Story mode starts and `VideoOut.Flip` gives way to `Driver.Packet`): | # | seconds | presents | p50 | largest phase | |---|---|---|---|---| | 6 | 51-61 | 467 | 16.7 | VideoOut.Flip 12.7 | | 7 | 61-71 | 148 | 60.7 | Driver.Packet 45.9 | | 8 | 71-81 | 143 | 70.5 | Driver.Packet 66.1 | | 9 | 81-91 | 130 | 75.9 | Driver.Packet 72.7 | The only other place that attaches flips to a submission is `Driver::executeRewindTail` ([`Submission.cpp:369`](https://github.com/boykopovar/AnyPS5/blob/86fb985abb5721509f9558050eefb79665d81ad1/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp#L369), `reserveOutputs(tail)`). It runs on the queue worker, does not go through `AgcDriver::Submit`, and so neither increments the flip count that [`EntryPoints.cpp:24`](https://github.com/boykopovar/AnyPS5/blob/86fb985abb5721509f9558050eefb79665d81ad1/core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp#L24) compares nor calls `FrameBoundary`. **2. With tail flips counted, `start()` never finds the driver idle.** With the local change below, boundaries continue into gameplay and the trigger is seen, but: ```text [frame-capture] the driver did not go idle within 10 s at frame boundary 2326 (attempt 1) [frame-capture] the driver did not go idle within 10 s at frame boundary 2327 (attempt 2) [frame-capture] the driver did not go idle within 10 s at frame boundary 2328 (attempt 3) [frame-capture] the driver did not go idle within 10 s at frame boundary 2329 (attempt 4) [frame-capture] the driver did not go idle within 10 s at frame boundary 2330 (attempt 5) [frame-capture] giving up: no idle frame boundary ``` The title froze for those 50 s (audio kept playing) and recovered once the recorder gave up. Queue 0 spent the time in `Driver.Rewind`: | # | seconds | presents | p50 | largest phase | |---|---|---|---|---| | 7 | 61-80 | 135 | 64.2 | Driver.Rewind 75.1 | | 8 | 80-91 | 1 | 10120.7 | Driver.Rewind 9804.5 | | 9 | 91-101 | 1 | 10048.3 | Driver.Rewind 9685.2 | | 10 | 101-120 | 2 | 9948.4 | Driver.Rewind 9665.1 | | 11 | 120-130 | 140 | 70.2 | Driver.Packet 67.3 | That is consistent with a queue 0 submission parked at a REWIND whose valid bit the title sets from the thread that is blocked in `WaitIdleFor` inside `FrameBoundary`. I have not confirmed which thread sets it. The local change used for part 2 (12 lines; not proposed as is, since on its own it turns "never starts" into these freezes): ```diff --- a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp @@ void Driver::executeRewindTail(const Submission& stalled) { reserveOutputs(tail); + if (!tail.flips.empty()) rewindTailFlips.fetch_add(1, std::memory_order_acq_rel); --- a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cpp @@ void Submit(const Packet* packet, std::uint32_t queue) try { recorder->Submit(*packet, queue, [&] { driver.Submit(packet, queue); }); - if (driver.FlipSubmissions() != flips) recorder->FrameBoundary(); + static std::atomic<std::uint64_t> seenTailFlips{0}; + const auto tailFlips = driver.RewindTailFlips(); + const bool tailFlipped = seenTailFlips.exchange(tailFlips, std::memory_order_acq_rel) != tailFlips; + if (driver.FlipSubmissions() != flips || tailFlipped) recorder->FrameBoundary(); ``` plus `Driver::RewindTailFlips()` returning a new `std::atomic<std::uint64_t> rewindTailFlips` member. ### What was checked - Before gameplay the recorder works on the same build: with no trigger (`started at frame boundary 1: 48 ranges, 319.3 MiB snapshot in 3.7 s`), with the trigger file present from launch (same line), and with `APS5_FRAME_CAPTURE_AT_FLIP=1000` at the main menu (`started at frame boundary 1000: 96 ranges, 1326.2 MiB snapshot in 2.0 s`). So the trigger check itself is fine; only the REWIND-tail flips are missing. - No open pull request changes `executeRewindTail`'s flips, `FrameBoundary` or `start()`'s idle wait; #11435 and #11436 change the replay side and add tracing. - Not checked: any title other than GTA V; Windows or AMD; whether GTA V ever reaches a frame boundary with no REWIND parked (every attempt above blocked the title, which may itself have kept it parked); and replaying any gameplay capture, since none could be made. Questions: 1. Should a REWIND tail that carries a flip end a frame, and if so, should the boundary be taken at the title's next `Submit` (as above), since `start()` cannot wait for idle on the queue worker? 2. For starting during gameplay: is it acceptable for `start()` to treat "every queue idle or parked at a REWIND the CPU has not released" as idle, with the parked submission recorded so `agc_frame_replay` can issue its tail when the captured CPU write releases it? Or would you rather `start()` check without blocking and retry at the next boundary? I'm happy to test any change on GTA V, or write the fix in whichever shape you prefer. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#12235
No description provided.