feat(agc): select the swapchain present mode with ANYPS5_PRESENT_MODE #4106
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4106"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-11T23:26:38Z.
What
The presenter always creates its swapchain with
VK_PRESENT_MODE_FIFO_KHR.ANYPS5_PRESENT_MODEnow selectsfifo(default, unchanged),fifo_latest_ready,mailboxorimmediate. Any other value fails the start, and so does a mode the surface does not list invkGetPhysicalDeviceSurfacePresentModesKHR; there is no fallback. Both swapchain creation sites (constructor andResize) use the selected mode. Whenfifo_latest_readyis requested, the device enablesVK_KHR_present_mode_fifo_latest_ready(or the EXT one) if the driver reports the feature; with any other value or the variable unset, device creation is as onmain. Flip pacing does not depend on the present mode (it waits on the 59.94 Hz vblank timer inVideoOutDriver.cpp).Why: on Hyprland with the NVIDIA driver a window on a workspace that is not shown gets about one FIFO present per second, so a title left on another workspace runs at 1 FPS.
fifo_latest_readyandimmediatekeep it at its normal rate, which makes unattended test runs independent of what the desktop shows (fifo_latest_readyis defined as a FIFO variant that does not tear; tearing was not compared by eye).Tested
Arch Linux, RTX 5080 (NVIDIA 615.78.08), Hyprland, main
2ccbd376fwith this commit for the tests (rebased 2026-10-12 over a conflict inVulkanDevice.cppwith the sample-locations change; both blocks kept); the Balatro runs were on7a84b2226.agc_driver_present_modepasses on NVIDIA, RADV (gfx1036) and lavapipe, and so doagc_driver_flipandagc_driver_flip_compute. It covers the selection function only (default, the four names, wrong case, empty value, unsupported mode, empty list) and needs no GPU; without the change it does not compile. The swapchain wiring needs a window, so no ctest covers it. For that, Balatro (PPSA21402) with its window on a hidden workspace, frames counted over 15 s from the window title's frame counter:fifo15 frames,fifo_latest_ready900,immediate900 (immediateon the previous head, which differs only in when the extension is enabled).mailboxstops at start withthe surface does not support the requested present mode(this surface offers fifo, immediate and fifo_latest_ready; the mailbox refusal was run on the earlier head, on mainbca7a29d2).Windows: built with WinLibs GCC 15.2 (UCRT) in a Windows Server 2025 VM without a GPU;
agc_driver_present_mode,agc_driver_flipandagc_driver_flip_computepass there. An earlier head of this PR did not compile on Windows (the flip test target lacked the Vulkan-Headers include directory); that is fixed.Not tested: presentation on Windows, X11, AMD presentation, a driver without the extension.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-12T00:26:25Z.
Same symptom here, from another title: Uncharted: Legacy of Thieves Collection (PPSA05684), Arch Linux, RTX 4070 Ti SUPER, NVIDIA 615.78.08, Hyprland. The menu dropped to exactly one frame per second whenever its window was on a workspace that wasn't shown.
Stack snapshots taken during the stall (
eu-stackevery 5 s) showed the presenter blocked indrmSyncobjTimelineWaitundervkAcquireNextImageKHR, called fromVulkanDevice::AcquireImage(FIFO, 5 s timeout). It appeared in every snapshot taken during a stall and in none outside one. The driver hands out about one image per second while the window is hidden, and the guest's flip waits for that acquire.An alternative that fixes the default without an environment variable is not to wait in the acquire:
Driver::Presentalready handles afalsefromAcquireImagethe way it handles an out-of-date swapchain: it skips the presentation and still callsgpuReady, so the flip completes. Flip pacing stays on the vblank timer, as you note.Measured with FIFO, the game window moved to an empty workspace for 50 s, then back:
I counted the drops with an extra field in the
APS5_PROFILE_DRAW[present]line.This would complement your PR rather than replace it:
ANYPS5_PRESENT_MODEremains useful for choosingimmediateormailboxon purpose, while the non-blocking acquire keeps the default FIFO from tying the guest to the compositor. Happy to open it as a separate small PR if that's preferred, or you can fold it into this one.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-12T00:44:09Z.
A separate PR is the better fit. The non-blocking acquire changes the default path and comes with its own measurement, and this one stays the explicit switch. Your snapshots match what I saw under FIFO, one acquire per second while hidden. With
immediatethe hidden window keeps its full rate here (900 frames in 15 s), so the two changes do not overlap.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-12T00:55:54Z.
Pushed a fourth value,
fifo_latest_ready. It needsVK_KHR_present_mode_fifo_latest_ready(or the EXT one), which is enabled only when that value is requested and the driver reports the feature, so device creation with the variable unset is the same as onmain.On the RTX 5080 it fixes the hidden-workspace case like
immediatedoes. The extension defines it as a FIFO variant that does not tear; I have not compared the two by eye. Balatro on a hidden workspace, 15 s:fifo15 frames,fifo_latest_ready900. The description has the details.