fix(agc): drop a presentation instead of waiting for a swapchain image #4684

Merged
XairRrR merged 2 commits from upstream-pr/4684 into main 2026-10-13 15:36:29 +00:00
XairRrR commented 2026-10-12 18:58:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-12T18:58:30Z.


What

Follow-up to #4106, as @fma-rc suggested there.

The presenter acquired the next swapchain image with a 5 s timeout before completing the guest's flip. With FIFO on Wayland, NVIDIA's driver hands out about one image per second while the window is hidden (on another workspace or occluded). vkAcquireNextImageKHR then blocked for about 1 s per flip, and the title ran at exactly 1 frame per second. Stack snapshots showed the presenter in drmSyncobjTimelineWait under AcquireImage in every snapshot taken during such a stall, and in none outside them.

The acquire no longer waits. VK_NOT_READY or VK_TIMEOUT drops that presentation, as an out-of-date swapchain already does, and the flip completes. The [present] line of APS5_PROFILE_DRAW counts the drops.

ANYPS5_PRESENT_MODE from #4106 stays the explicit switch. This changes the default path, so FIFO no longer ties the guest to a hidden window.

Tested

  • Arch Linux (kernel 7.2.9), Hyprland, GCC 16.2.1, NVIDIA RTX 4070 Ti SUPER (driver 615.78.08), Release with BUILD_TESTING=ON.
  • Branch built alone on main 2a5eca11c. Full ctest: 959/959. Conventions check passed.
  • Title: Uncharted: Legacy of Thieves Collection (PPSA05684), main menu, on its own bring-up branch. With the window moved to an empty workspace for 50 s: 7.5 fps and about 65 drops per 10 s while hidden (1 fps before), and no drops while visible.

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
  • Unblocks: PPSA05684 #4001
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4833751240 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4684). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-12T18:58:30Z. --- ### What Follow-up to #4106, as @fma-rc suggested there. The presenter acquired the next swapchain image with a 5 s timeout before completing the guest's flip. With FIFO on Wayland, NVIDIA's driver hands out about one image per second while the window is hidden (on another workspace or occluded). `vkAcquireNextImageKHR` then blocked for about 1 s per flip, and the title ran at exactly 1 frame per second. Stack snapshots showed the presenter in `drmSyncobjTimelineWait` under `AcquireImage` in every snapshot taken during such a stall, and in none outside them. The acquire no longer waits. `VK_NOT_READY` or `VK_TIMEOUT` drops that presentation, as an out-of-date swapchain already does, and the flip completes. The `[present]` line of `APS5_PROFILE_DRAW` counts the drops. `ANYPS5_PRESENT_MODE` from #4106 stays the explicit switch. This changes the default path, so FIFO no longer ties the guest to a hidden window. ### Tested - Arch Linux (kernel 7.2.9), Hyprland, GCC 16.2.1, NVIDIA RTX 4070 Ti SUPER (driver 615.78.08), Release with `BUILD_TESTING=ON`. - Branch built alone on main 2a5eca11c. Full ctest: 959/959. Conventions check passed. - Title: Uncharted: Legacy of Thieves Collection (PPSA05684), main menu, on its own bring-up branch. With the window moved to an empty workspace for 50 s: 7.5 fps and about 65 drops per 10 s while hidden (1 fps before), and no drops while visible. ### 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 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] Unblocks: PPSA05684 #4001 - [x] AI-assisted: yes
fma-rc commented 2026-10-13 03:54:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-13T03:54:43Z.


I ran this with Astro's Playroom (PPSA01325) on a hidden Hyprland workspace, RTX 5080 with NVIDIA 615.78.08, ANYPS5_PRESENT_MODE=fifo, on main 2a55cfe1e plus PR 4500 (the title needs it to enter the level).

Without the change the title made 414 frames in 420 s and was still on the title screen when the run ended. With 9d7ad5349 on top it reached the level at 78 s and made 122 frames in 20.3 s in gameplay, the same rate I measure with immediate.

The [present] line with the change reads 10 presents over 10 s (50 dropped: no free swapchain image; ...). One thing to look at: the per-present figures in that line are still divided by the presents that got an image, so it prints GPU busy 278.9 ms per present where the run without drops prints 52.2 ms.

I did not run it with the window visible.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6137868626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4684#issuecomment-6137868626). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-13T03:54:43Z. --- I ran this with Astro's Playroom (PPSA01325) on a hidden Hyprland workspace, RTX 5080 with NVIDIA 615.78.08, `ANYPS5_PRESENT_MODE=fifo`, on `main` `2a55cfe1e` plus PR 4500 (the title needs it to enter the level). Without the change the title made 414 frames in 420 s and was still on the title screen when the run ended. With `9d7ad5349` on top it reached the level at 78 s and made 122 frames in 20.3 s in gameplay, the same rate I measure with `immediate`. The `[present]` line with the change reads `10 presents over 10 s (50 dropped: no free swapchain image; ...)`. One thing to look at: the per-present figures in that line are still divided by the presents that got an image, so it prints `GPU busy 278.9 ms` per present where the run without drops prints 52.2 ms. I did not run it with the window visible.
XairRrR commented 2026-10-13 11:34:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-13T11:34:33Z.


Thanks for the Astro's Playroom run on a hidden workspace.

You're right about the [present] line. GPU busy and idle time cover every frame's GPU work, but they were divided only by the presentations that got an image. 95f34a050 divides those two figures by presented plus dropped frames, and the label now reads "per frame, presented or dropped". The per-present blit figures are unchanged. With no drops, nothing changes.

The branch is rebased on current main. Full ctest: 1036/1036, conventions pass.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144625736 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4684#issuecomment-6144625736). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-13T11:34:33Z. --- Thanks for the Astro's Playroom run on a hidden workspace. You're right about the `[present]` line. GPU busy and idle time cover every frame's GPU work, but they were divided only by the presentations that got an image. 95f34a050 divides those two figures by presented plus dropped frames, and the label now reads "per frame, presented or dropped". The per-present blit figures are unchanged. With no drops, nothing changes. The branch is rebased on current `main`. Full ctest: 1036/1036, conventions pass. AI-assisted: yes
adriadam10 commented 2026-10-13 15:16:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:16:07Z.


Checked the diff and the acquire path: the acquire fence is reset at the start of every AcquireImage, imageAcquired is not set on the VK_NOT_READY/VK_TIMEOUT early return, and Driver::Present already treats a false return as a dropped presentation. Scoped build and ctest of libSceAgcDriver pass (488/489; agc_driver_tessellation segfaults with and without this PR). Hidden-window behaviour confirmed by @fma-rc on Astro's Playroom; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148829721 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4684#issuecomment-6148829721). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:16:07Z. --- Checked the diff and the acquire path: the acquire fence is reset at the start of every `AcquireImage`, `imageAcquired` is not set on the `VK_NOT_READY`/`VK_TIMEOUT` early return, and `Driver::Present` already treats a `false` return as a dropped presentation. Scoped build and ctest of libSceAgcDriver pass (488/489; `agc_driver_tessellation` segfaults with and without this PR). Hidden-window behaviour confirmed by @fma-rc on Astro's Playroom; merging.
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!4684
No description provided.