fix(agc-driver): make the presenter wait for a full frame dump queue #8807

Merged
ycbuzi merged 3 commits from upstream-pr/8807 into main 2026-10-22 04:50:27 +00:00
ycbuzi commented 2026-10-21 01:41:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T01:41:57Z.


What

With APS5_DUMP_FRAMES, FrameDumpWriter::Enqueue threw frame dump queue exceeded 64 MiB as soon as the writer thread was more than 64 MiB behind, which failed the presentation and ended the title. #4320 made that rare at the default APS5_DUMP_SCALE=4 and left the limit itself alone ("if the queue should make the presenter wait for the writer instead of throwing when it is full, that is a different change"). At APS5_DUMP_SCALE=1 a 1920x1080 title reaches it within nine frames on this PC (8 MB a frame, one BMP written before the ninth frame arrives), a 3840x2160 one on its third frame.

Enqueue now waits on the writer's condition variable until the frame fits and the writer notifies after each file, so a slow disk slows the title down instead of stopping it. A single frame larger than the queue still throws. The disabled-dump early return moves before the check, as before nothing was queued in that case either.

The VideoOut frame dump queue test gets a wait mode, registered as video_out_frame_dump_wait with APS5_DUMP_SCALE=1: two 3840x2160 frames fill the queue, the third has to wait for the held first file, which a thread releases after two seconds, and the test checks that the four flips took at least 1.5 s and that every dump matches the display buffer. On main that run fails with the queue message at the third flip. docs/dev/GAME_TESTING.md says what the wait means for a dump.

Tested

Windows 11, MinGW GCC 15.2.0, RTX 4070, DOOM (PPSA99666, 1920x1080 display buffers) relinked with --windows --skip-sce-module, test plan game freedoom2.wad / frames 240, APS5_DUMP_FRAMES=240:

build APS5_DUMP_SCALE=1 APS5_DUMP_SCALE=4
main a841f2a (has #4320) aborts on the ninth frame: [videoout] presentation failed: Vulkan presentation: frame dump queue exceeded 64 MiB, 1 of 240 BMPs written 240 BMPs, exit 0
the same with this change to the writer 238 BMPs for 240 flips, exit 0, last frame at 61 s instead of 7: the title runs at the writer's pace while the queue is full (about four 8 MB frames a second on this disk) 240 BMPs, last frame at 6.8 and 7.0 s in two runs, exit 0: unchanged

The change was built into that tree's libSceAgcDriver.prx (the writer class is the same there apart from #4891's screenshot flag); the PR branch is on current main.

Not run: video_out_frame_dump_wait and its sibling need Linux with the x11 test driver (mkfifo), which this PC does not have; CI shows them as skipped with the offscreen driver, as #4320 described. python tools/check_conventions.py --base origin/main --head HEAD passes. When the presenter is slower than the title, flips are coalesced as before this change: on a loaded CPU one run presented 52 of 240 flips and dumped those 52. tools/pr_overlap.py: #7622 (host worker MXCSR) changes the line that starts the writer thread, right below this change, so whichever merges second rebases a one-line hunk; the other open PRs on VulkanDevice.cpp touch other regions, or could not be compared because they conflict with main.

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 (the limit #4320 left in place)
  • Unblocks: none
  • GPUs tested: RTX 4070 (Windows)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4945079840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8807). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T01:41:57Z. --- ### What With `APS5_DUMP_FRAMES`, `FrameDumpWriter::Enqueue` threw `frame dump queue exceeded 64 MiB` as soon as the writer thread was more than 64 MiB behind, which failed the presentation and ended the title. #4320 made that rare at the default `APS5_DUMP_SCALE=4` and left the limit itself alone ("if the queue should make the presenter wait for the writer instead of throwing when it is full, that is a different change"). At `APS5_DUMP_SCALE=1` a 1920x1080 title reaches it within nine frames on this PC (8 MB a frame, one BMP written before the ninth frame arrives), a 3840x2160 one on its third frame. `Enqueue` now waits on the writer's condition variable until the frame fits and the writer notifies after each file, so a slow disk slows the title down instead of stopping it. A single frame larger than the queue still throws. The disabled-dump early return moves before the check, as before nothing was queued in that case either. The VideoOut frame dump queue test gets a `wait` mode, registered as `video_out_frame_dump_wait` with `APS5_DUMP_SCALE=1`: two 3840x2160 frames fill the queue, the third has to wait for the held first file, which a thread releases after two seconds, and the test checks that the four flips took at least 1.5 s and that every dump matches the display buffer. On `main` that run fails with the queue message at the third flip. `docs/dev/GAME_TESTING.md` says what the wait means for a dump. ### Tested Windows 11, MinGW GCC 15.2.0, RTX 4070, DOOM (PPSA99666, 1920x1080 display buffers) relinked with `--windows --skip-sce-module`, test plan `game freedoom2.wad` / `frames 240`, `APS5_DUMP_FRAMES=240`: | build | `APS5_DUMP_SCALE=1` | `APS5_DUMP_SCALE=4` | | --- | --- | --- | | `main` a841f2a (has #4320) | aborts on the ninth frame: `[videoout] presentation failed: Vulkan presentation: frame dump queue exceeded 64 MiB`, 1 of 240 BMPs written | 240 BMPs, exit 0 | | the same with this change to the writer | 238 BMPs for 240 flips, exit 0, last frame at 61 s instead of 7: the title runs at the writer's pace while the queue is full (about four 8 MB frames a second on this disk) | 240 BMPs, last frame at 6.8 and 7.0 s in two runs, exit 0: unchanged | The change was built into that tree's `libSceAgcDriver.prx` (the writer class is the same there apart from #4891's screenshot flag); the PR branch is on current `main`. Not run: `video_out_frame_dump_wait` and its sibling need Linux with the x11 test driver (`mkfifo`), which this PC does not have; CI shows them as skipped with the offscreen driver, as #4320 described. `python tools/check_conventions.py --base origin/main --head HEAD` passes. When the presenter is slower than the title, flips are coalesced as before this change: on a loaded CPU one run presented 52 of 240 flips and dumped those 52. `tools/pr_overlap.py`: #7622 (host worker MXCSR) changes the line that starts the writer thread, right below this change, so whichever merges second rebases a one-line hunk; the other open PRs on `VulkanDevice.cpp` touch other regions, or could not be compared because they conflict with `main`. ### 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) - [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 (the limit #4320 left in place) - [x] Unblocks: none - [x] GPUs tested: RTX 4070 (Windows) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-21 01:45:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:45:10Z.

Review: APPROVED


Reviewed the exact diff. Enqueue now rejects a single frame larger than the queue, waits until capacity is available, and wakes blocked presenters after bytes are written or shutdown starts. The existing accounting includes frames being written as well as pending frames, so this remains a 64 MiB bound. The new test holds the writer on the first dump while the presenter fills the queue, then verifies it waits and that the dumped buffers remain correct. The reported Windows control demonstrates the failure on main at scale 1 and unchanged behavior at scale 4; hosted runtime jobs are skipped, so I rely on that reported run and the test design. No blocking issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5593971720 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8807#pullrequestreview-5593971720). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T01:45:10Z. **Review:** APPROVED --- Reviewed the exact diff. Enqueue now rejects a single frame larger than the queue, waits until capacity is available, and wakes blocked presenters after bytes are written or shutdown starts. The existing accounting includes frames being written as well as pending frames, so this remains a 64 MiB bound. The new test holds the writer on the first dump while the presenter fills the queue, then verifies it waits and that the dumped buffers remain correct. The reported Windows control demonstrates the failure on main at scale 1 and unchanged behavior at scale 4; hosted runtime jobs are skipped, so I rely on that reported run and the test design. No blocking issue found.
github-actions[bot] commented 2026-10-21 01:53:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T01:53:25Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7622 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L167-168

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 2434 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4072 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6044 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/tests/FrameDumpQueue.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6202 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6788 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6960 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7201 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 7275 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7881 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 7922 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8004 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8014 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8278 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8927 core/libs/prx/libSceVideoOut/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306059108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8807#issuecomment-6306059108). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T01:53:25Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7622](https://www.github.com/boykopovar/AnyPS5/pull/7622) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L167-168](https://github.com/boykopovar/AnyPS5/blob/110a18ba017df63c795aa78f2d03ed24a9d8e8b1/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L167-L168) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 674](https://www.github.com/boykopovar/AnyPS5/pull/674) | `core/libs/prx/libSceVideoOut/CMakeLists.txt` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 4040](https://www.github.com/boykopovar/AnyPS5/pull/4040) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 4072](https://www.github.com/boykopovar/AnyPS5/pull/4072) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 4472](https://www.github.com/boykopovar/AnyPS5/pull/4472) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceVideoOut/CMakeLists.txt` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5441](https://www.github.com/boykopovar/AnyPS5/pull/5441) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceVideoOut/CMakeLists.txt`<br>`core/libs/prx/libSceVideoOut/tests/FrameDumpQueue.cpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6202](https://www.github.com/boykopovar/AnyPS5/pull/6202) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6788](https://www.github.com/boykopovar/AnyPS5/pull/6788) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 6960](https://www.github.com/boykopovar/AnyPS5/pull/6960) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`<br>`core/libs/prx/libSceVideoOut/CMakeLists.txt` | | [PR 7275](https://www.github.com/boykopovar/AnyPS5/pull/7275) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 7881](https://www.github.com/boykopovar/AnyPS5/pull/7881) | `core/libs/prx/libSceVideoOut/CMakeLists.txt` | | [PR 7922](https://www.github.com/boykopovar/AnyPS5/pull/7922) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 8004](https://www.github.com/boykopovar/AnyPS5/pull/8004) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 8014](https://www.github.com/boykopovar/AnyPS5/pull/8014) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 8278](https://www.github.com/boykopovar/AnyPS5/pull/8278) | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | [PR 8927](https://www.github.com/boykopovar/AnyPS5/pull/8927) | `core/libs/prx/libSceVideoOut/CMakeLists.txt` |
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!8807
No description provided.