fix(agc-driver): queue frame dumps at the dump scale #4320

Merged
oneandonlydean merged 1 commit from upstream-pr/4320 into main 2026-10-12 08:21:49 +00:00
oneandonlydean commented 2026-10-12 06:04:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T06:04:20Z.


What

With APS5_DUMP_FRAMES set, a run can end with Vulkan presentation: frame dump queue exceeded 64 MiB. It depends on timing: the same build aborted on one run and finished on the next.

A frame presented from guest memory is read back at the size of the display buffer (PresentSlot::dumpBuffer, 31.6 MiB for 3840x2160). WriteFrameDump copied all of it into FrameDumpWriter's queue and passed the scale along, so the reduction to APS5_DUMP_SCALE happened later, on the writer thread. The queue is limited to 64 MiB and a frame counts until its file is written, so two such frames fill it and the third one that arrives while the writer is still busy throws. A frame blitted from the resident image does not have this problem: it is reduced on the GPU (dumpScaler) and queued at the reduced size with scale 1. The dump code is from #76; the message started to appear in runs after #3777.

The change: WriteFrameDump reduces the readback by the slot's dump scale when the slot retires and queues the reduced pixels with scale 1, as the resident path does. The pixels kept are the same ones WriteFrameBmp kept before (every scale-th pixel in each direction), so the files do not change. At the default scale of 4 a 3840x2160 frame takes 1.98 MiB of the queue instead of 31.6 MiB, and the presenter copies those 1.98 MiB instead of the whole readback.

What this does not change: the limit itself. With APS5_DUMP_SCALE=1 nothing is reduced, a 3840x2160 frame is still 31.6 MiB on either path, and the third frame behind a busy writer still throws. At scale 4 the same happens once the writer is 32 frames behind. If the queue should make the presenter wait for the writer instead of throwing when it is full, that is a different change to FrameDumpWriter::Enqueue and I left it alone; say if you want it.

Tested

Linux (CachyOS, GCC, RTX 4090, NVIDIA driver), Release, configured with the CI flags (-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON), on main b42ef24e:

  • video_out_frame_dump_queue (new, not on Windows): registers a 3840x2160 display buffer in guest memory and flips it four times with APS5_DUMP_FRAMES=4 and APS5_DUMP_SCALE=4, through sceVideoOutSubmitFlip and the driver's presenter. frame_000.bmp is a named pipe the test does not read until the four flips are done, so the writer is held on the first file for certain. It then reads the four dumps and compares every pixel with ReadDisplayBuffer of the same buffer.
  • On main it fails 5 of 5 runs at the third flip with [videoout] presentation failed: Vulkan presentation: frame dump queue exceeded 64 MiB, the message from the game runs. With the change it passes 5 of 5.
  • The same test binary run by hand with APS5_DUMP_SCALE=1 still stops at the third frame with that message with the change (see above).
  • Like the other VideoOut flip tests it needs a window with Vulkan: with the default ANYPS5_VIDEO_OUT_TEST_DRIVER=offscreen it reports skipped, no display or Vulkan device, which is what the CI job will show. The runs above are with -DANYPS5_VIDEO_OUT_TEST_DRIVER=x11.
  • ctest -R "agc|video_out" with the x11 driver: 447 of 447 pass; on main 446 of 447, the new test being the one that fails.
  • python3 tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.

Not tested: a game run with GPU frame dumps (in ten earlier runs of a 2D title we test with, five with this change and five without, the message did not appear either way, so game runs do not show anything here); Windows (the change is not platform specific, but the test uses a named pipe and is not registered there); PresentPixels and APS5_NO_GPU_DUMP=1, which write their files directly and do not use the queue.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4825558012 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4320). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T06:04:20Z. --- ### What With `APS5_DUMP_FRAMES` set, a run can end with `Vulkan presentation: frame dump queue exceeded 64 MiB`. It depends on timing: the same build aborted on one run and finished on the next. A frame presented from guest memory is read back at the size of the display buffer (`PresentSlot::dumpBuffer`, 31.6 MiB for 3840x2160). `WriteFrameDump` copied all of it into `FrameDumpWriter`'s queue and passed the scale along, so the reduction to `APS5_DUMP_SCALE` happened later, on the writer thread. The queue is limited to 64 MiB and a frame counts until its file is written, so two such frames fill it and the third one that arrives while the writer is still busy throws. A frame blitted from the resident image does not have this problem: it is reduced on the GPU (`dumpScaler`) and queued at the reduced size with scale 1. The dump code is from #76; the message started to appear in runs after #3777. The change: `WriteFrameDump` reduces the readback by the slot's dump scale when the slot retires and queues the reduced pixels with scale 1, as the resident path does. The pixels kept are the same ones `WriteFrameBmp` kept before (every `scale`-th pixel in each direction), so the files do not change. At the default scale of 4 a 3840x2160 frame takes 1.98 MiB of the queue instead of 31.6 MiB, and the presenter copies those 1.98 MiB instead of the whole readback. What this does not change: the limit itself. With `APS5_DUMP_SCALE=1` nothing is reduced, a 3840x2160 frame is still 31.6 MiB on either path, and the third frame behind a busy writer still throws. At scale 4 the same happens once the writer is 32 frames behind. If the queue should make the presenter wait for the writer instead of throwing when it is full, that is a different change to `FrameDumpWriter::Enqueue` and I left it alone; say if you want it. ### Tested Linux (CachyOS, GCC, RTX 4090, NVIDIA driver), Release, configured with the CI flags (`-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON`), on `main` b42ef24e: - `video_out_frame_dump_queue` (new, not on Windows): registers a 3840x2160 display buffer in guest memory and flips it four times with `APS5_DUMP_FRAMES=4` and `APS5_DUMP_SCALE=4`, through `sceVideoOutSubmitFlip` and the driver's presenter. `frame_000.bmp` is a named pipe the test does not read until the four flips are done, so the writer is held on the first file for certain. It then reads the four dumps and compares every pixel with `ReadDisplayBuffer` of the same buffer. - On `main` it fails 5 of 5 runs at the third flip with `[videoout] presentation failed: Vulkan presentation: frame dump queue exceeded 64 MiB`, the message from the game runs. With the change it passes 5 of 5. - The same test binary run by hand with `APS5_DUMP_SCALE=1` still stops at the third frame with that message with the change (see above). - Like the other VideoOut flip tests it needs a window with Vulkan: with the default `ANYPS5_VIDEO_OUT_TEST_DRIVER=offscreen` it reports `skipped, no display or Vulkan device`, which is what the CI job will show. The runs above are with `-DANYPS5_VIDEO_OUT_TEST_DRIVER=x11`. - `ctest -R "agc|video_out"` with the x11 driver: 447 of 447 pass; on `main` 446 of 447, the new test being the one that fails. - `python3 tools/check_conventions.py --base origin/main` and `tools/check_test_registration.py` pass. Not tested: a game run with GPU frame dumps (in ten earlier runs of a 2D title we test with, five with this change and five without, the message did not appear either way, so game runs do not show anything here); Windows (the change is not platform specific, but the test uses a named pipe and is not registered there); `PresentPixels` and `APS5_NO_GPU_DUMP=1`, which write their files directly and do not use the queue. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code)
github-actions[bot] commented 2026-10-12 06:15:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T06:15:13Z.


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
#4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L595
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6118835764 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4320#issuecomment-6118835764). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T06:15:13Z. --- <!-- 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 | |---|---|---|---| | #4040 | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L595](https://github.com/boykopovar/AnyPS5/blob/8c4a295ffb7bc471a5bcee2287fd38e499d003a2/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L595) | | |
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!4320
No description provided.