[PR #446] [MERGED] Wayland: VSync off draws uncapped in a window #2570

Closed
opened 2026-11-02 15:57:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/446
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/wayland-uncapped-windowed


📝 Commits (1)

  • a8e0dea Wayland: VSync off draws uncapped in a window

📊 Changes

1 file changed (+6 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+6 -1)

📄 Description

Fixes #441

What was wrong

Horizon chooses the present mode the way vanilla does (GpuSurface.PresentMode.getSupportedVsyncMode: VSync on → FIFO; off → the first supported of IMMEDIATE, MAILBOX, FIFO; see window::vsync_present_mode), and the Present Mode option in Horizon's graphics settings can override it. That choice was right. What capped the frame rate was the renderer calling Window::pre_present_notify() before every present. On Wayland, winit uses that call to request a wl_surface.frame callback and holds the next RedrawRequested until the callback arrives. The compositor sends one callback per composited frame, so a windowed game ran at the monitor's refresh rate (165 Hz for rdbt) whatever the present mode was.

In fullscreen, Hyprland (rdbt's likely session) can scan out directly and lets an IMMEDIATE surface tear. Frame callbacks then come back almost at once, which explains the 1000+ FPS. On X11, macOS and Windows, winit's pre_present_notify does nothing, which is why only Linux/Wayland players saw this.

Vanilla's GLFW window has no frame-callback throttle. With VSync off it presents as fast as the Max Framerate limit allows, windowed or fullscreen.

Fix

pre_present_notify() is now called only when the surface is configured for Fifo (VSync on, or Present Mode = FIFO). VSync-on behaviour is unchanged. With VSync off (Immediate / Mailbox), redraws are no longer held for frame callbacks.

What the compositor allows: Horizon already falls back as vanilla does. With VSync off it uses Immediate if the surface offers it, then Mailbox, then Fifo. Mesa's Wayland WSI offers Mailbox on every compositor and Immediate where the compositor supports wp_tearing_control (Hyprland does). If a driver's windowed Wayland surface offers only Fifo, the frame rate stays capped at the refresh rate, and that cap comes from the surface: no client can get around it.

Verified

  • cargo fmt --check, cargo clippy -p horizon-client --all-targets -- -D warnings: clean.
  • The change has no effect on macOS (winit's pre_present_notify is empty there), so the Mac mini can't reproduce or check it. Needs a Wayland check: windowed, VSync OFF, Max Framerate Unlimited; F3 should show more than the refresh rate. rdbt on Hyprland, or vscreen on the desktop.
  • Parity harnesses: run once on an integration branch together with the other rdbt fixes (results are in the thread's report).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/446 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/wayland-uncapped-windowed` --- ### 📝 Commits (1) - [`a8e0dea`](https://github.com/horizon-rust/horizon/commit/a8e0dead355c23d0f38ad0a431a5888ea9eeb7d9) Wayland: VSync off draws uncapped in a window ### 📊 Changes **1 file changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+6 -1) </details> ### 📄 Description Fixes #441 ## What was wrong Horizon chooses the present mode the way vanilla does (`GpuSurface.PresentMode.getSupportedVsyncMode`: VSync on → `FIFO`; off → the first supported of `IMMEDIATE`, `MAILBOX`, `FIFO`; see `window::vsync_present_mode`), and the Present Mode option in Horizon's graphics settings can override it. That choice was right. What capped the frame rate was the renderer calling `Window::pre_present_notify()` before **every** present. On Wayland, winit uses that call to request a `wl_surface.frame` callback and holds the next `RedrawRequested` until the callback arrives. The compositor sends one callback per composited frame, so a windowed game ran at the monitor's refresh rate (165 Hz for rdbt) whatever the present mode was. In fullscreen, Hyprland (rdbt's likely session) can scan out directly and lets an `IMMEDIATE` surface tear. Frame callbacks then come back almost at once, which explains the 1000+ FPS. On X11, macOS and Windows, winit's `pre_present_notify` does nothing, which is why only Linux/Wayland players saw this. Vanilla's GLFW window has no frame-callback throttle. With VSync off it presents as fast as the Max Framerate limit allows, windowed or fullscreen. ## Fix `pre_present_notify()` is now called only when the surface is configured for `Fifo` (VSync on, or Present Mode = FIFO). VSync-on behaviour is unchanged. With VSync off (`Immediate` / `Mailbox`), redraws are no longer held for frame callbacks. What the compositor allows: Horizon already falls back as vanilla does. With VSync off it uses `Immediate` if the surface offers it, then `Mailbox`, then `Fifo`. Mesa's Wayland WSI offers `Mailbox` on every compositor and `Immediate` where the compositor supports `wp_tearing_control` (Hyprland does). If a driver's windowed Wayland surface offers only `Fifo`, the frame rate stays capped at the refresh rate, and that cap comes from the surface: no client can get around it. ## Verified - `cargo fmt --check`, `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean. - The change has no effect on macOS (winit's `pre_present_notify` is empty there), so the Mac mini can't reproduce or check it. **Needs a Wayland check:** windowed, VSync OFF, Max Framerate Unlimited; F3 should show more than the refresh rate. rdbt on Hyprland, or vscreen on the desktop. - Parity harnesses: run once on an integration branch together with the other rdbt fixes (results are in the thread's report). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:16 +07:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2570
No description provided.