Skip to content

Vertical Sync setting, VRR and Android refresh rate (#67) - #72

Merged
schindlershadow merged 3 commits into
mainfrom
vrr-pacing
Nov 16, 2026
Merged

schindlershadow merged 3 commits into
mainfrom
vrr-pacing

Conversation

@schindlershadow

Copy link
Copy Markdown
Owner

Vertical sync is now a setting, which makes VRR displays work as intended; Android asks the display for a matching refresh rate; present timing can be logged.

  • Settings > Display > Vertical Sync (Off / On; saved as vsync, PSPRECOMP_VSYNC=0|1). Off is the old behaviour (Vulkan IMMEDIATE / MAILBOX, GL swap interval 0) and stays the default on PCs. On = Vulkan FIFO, GL swap interval -1 (adaptive) or 1: no tearing, and on a FreeSync / G-Sync / HDMI VRR display the refresh follows the game. It switches while running (the Vulkan layer rebuilds its swapchain at the next swap, the same path as the HDR switch). PSPRECOMP_VSYNC=0 used to mean on (any value did); now it means off.
  • Android: ANativeWindow_setFrameRate with the game's frame rate (looked up at run time in libnativewindow, then libandroid; Android 11+), again when the surface is recreated.
  • Measuring: PSPRECOMP_PRESENT_STATS=1 logs [PRESENT_STATS] (present-to-present mean / sd / median / p99 / max / uneven) every 5 s; test-script command vsync 0|1; battle_test.py BT_DISPLAY_MODE=fullscreen.
  • New runtime file psp_present_sync.cpp (ARCHITECTURE.md); docs in ENV_FLAGS.md, GRAPHICS.md, testing.md, steamdeck.md.

Tested:

  • 3440x1440 175 Hz VRR monitor (GNOME 50 Wayland, AMD, Vulkan), 150 fps fight: vsync off 6.67 ms per frame (sd 0.14-0.75 ms), vsync on 6.67 ms (sd 0.14-0.63 ms). FIFO on a fixed 175 Hz refresh would put the frames on a 5.71 ms grid, so the even 6.67 ms shows the refresh following the game.
  • Switching live mid-fight: Vulkan MAILBOX -> FIFO -> MAILBOX on that display, GL on this host (headless); no errors.
  • Android 15 emulator: asked the display for 90 Hz (ANativeWindow_setFrameRate -> 0), and SurfaceFlinger lists the game's SurfaceView with requestedFrameRate 90.00 Hz.
  • Not tested: GL with vsync on a real display, Windows, a fixed-refresh monitor, a real 120 Hz phone.

Closes #67

Release notes

  • New setting Display > Vertical Sync: no tearing, and with a FreeSync / G-Sync / VRR screen the display follows the game's frame rate.
  • Android: the phone's screen switches to a refresh rate that matches the game's frame rate (Android 11 and later).

🤖 Generated with Claude Code

schindlershadow and others added 3 commits November 16, 2026 13:09
- Settings > Display > Vertical Sync (Off / On, saved as vsync,
  PSPRECOMP_VSYNC=0|1; "0" used to mean on): On = Vulkan FIFO / GL swap
  interval -1 (adaptive) or 1, which on a FreeSync / G-Sync / HDMI VRR
  display lets the refresh follow the game. Switches while running: the
  Vulkan layer rebuilds its swapchain at the next swap (the HDR switch
  path), GL sets the swap interval on the presenting thread.
- Android asks the display for a refresh rate matching the game's frame
  rate (ANativeWindow_setFrameRate, looked up at run time, Android 11+),
  again whenever the surface is recreated.
- PSPRECOMP_PRESENT_STATS=1: [PRESENT_STATS] present-to-present timing
  every 5 s. Test-script command `vsync 0|1`; battle_test.py
  BT_DISPLAY_MODE=fullscreen.

New runtime file psp_present_sync.cpp (ARCHITECTURE.md), docs in
ENV_FLAGS.md, GRAPHICS.md, testing.md, steamdeck.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dlsym(RTLD_DEFAULT) does not reach it from the app's linker namespace, and
libandroid.so does not always re-export it (Android 15 emulator): open
libnativewindow.so first, then libandroid.so, and log why when neither
has it. Checked on the Android 15 emulator: "asked the display for 90 Hz
(ANativeWindow_setFrameRate -> 0)" and SurfaceFlinger lists the game's
SurfaceView with requestedFrameRate 90.00 Hz.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schindlershadow
schindlershadow merged commit 061a197 into main Nov 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable refresh rate (VRR) support and present pacing

1 participant