fix: gamescope issues in 1.4.1 (fps limit, lsfg, cursor, and GL titles on the shim)

JO
2h ago
+72-8

Description

Three gamescope fixes for 1.4.1. Replaces #2475, which carried only the first of them.

The cap now reaches the shim. It was disarmed whenever frame generation was armed (setFpsLimit(if (lsfg) 0 else limit)), so a session at cap 60 ×2 reached the shim as cap=0 and took its no-cap row (refresh / m acquires). The cap the user set never arrived, and the HUD showed a rate nobody asked for. Measured on Nova before: declared=mailbox source=generating cap=0 lsfg=1 acquire=30. After: two cap changes in one session read cap=60 acquire=60 and then cap=70 acquire=70.

The synced ceiling is the panel's leftover, min(cap × (m−1), refresh − cap), spent as a rate rather than floored to whole frames per source. At 60 Hz, cap 40, ×2 the panel leaves 20 generated against 40 source frames — one every other frame — and the old rule produced none, so generation did nothing above half the refresh while the panel still had room.

settingtotalbeforeafter
cap 70 ×2, 120 Hz70 + 50 = 12070 + 0 = 7070 + 50 = 120
cap 40 ×2, 60 Hz40 + 20 = 6040 + 0 = 4040 + 20 = 60

A GL guest now reaches the shim at all. A GL title's libGL in the container image is Mesa 24.3's libgl-xlib: zink renders on a headless Vulkan instance and the frame is copied into the X server with XShmPutImage. No VkSurfaceKHR is ever created, so the ICD shim sees no swapchain — no acquire cap, no generation, no release notes. Such a title was outside the whole present path.

The payload now carries a GL stack built for the guest (lib/gl/): Mesa zink with GLX + DRI3 and kopper, so the GLX client creates its surface from its own X window and rides the same ring, gate and release notes as a Vulkan guest. It lives in lib/gl/ because both Mesa stages emit libgallium-26.2.6.so and one would overwrite the other; lib/gl goes ahead of lib on LD_LIBRARY_PATH, and LIBGL_DRIVERS_PATH follows it because that libGL needs the x11-platform DRI module rather than the EGL/GBM one. MESA_GLX_FORCE_DIRECT=1 keeps a GLX client off the indirect path, which presents by copy and never creates a surface.

LIBGL_KOPPER_DISABLE is now set only for an X11 session, in XServerScreen, so a gamescope session never carries it. Previously it was set unconditionally and stripped again in the launcher, which also left it set for the session's own helper spawns.

Payload 20261121.1. The archive is not in this PR (it is gitignored and ships as a release asset); only the GamescopePayload.VERSION bump is.

Companion changes, all four of which have to be in the payload:

  • GameNative/gamescope#41 — the GL stack itself (GLX + kopper, EGL/GBM, and the monolithic libGLESv2 Xwayland's glamor runs on)
  • GameNative/xserver#5 — Xwayland built with GLX, so a kopper client has an extension to bind to
  • GameNative/gamenative-drm#71 — generation's leftover spent as a rate, not floored to whole frames
  • GameNative/gamenative-drm#72 — a mailbox slot freed at the compositor's release, and the gate's period booked in the panel's own periods. The guest's-present-mode refactor (#67) had a mailbox slot waiting for a display release note, and a frame the compositor coalesced away is never released and so never gets one: 40 % of an uncapped session's commits then waited out a bound instead. Uncounted, this is 200 → 330 fps on Odin 3 (Hades II, uncapped, 120 Hz); the gate half is what stops a 120 cap on a 120 Hz panel reading 80.

Recording

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Verified

Retroid Pocket Nova (Adreno 740, 120 Hz panel), SteamWorld Dig 2 under gamescope, payload built from the three companion changes:

Xwayland     glGetString = zink Vulkan 1.4(Turnip Adreno (TM) 740)
Dig2.exe     maps gamescope/lib/gl/libGL.so.1.2.0 + libgallium-26.2.6.so
gn-vkshim    ICD loaded pid=Dig2.exe
             proxy swapchain create: 3 images for asked=3 ceiling=8
             present mode: declared=fifo source=guest cap=60 acquire=60 generate=0
screen       game content at 60.0 fps, HUD "LIMITED BY: FPS CAP"

That is the first time a GL title has created a swapchain through the shim.

The cap half was confirmed separately on the same device by reading the shim's census across two cap changes in one session (cap=60 acquire=60, then cap=70 acquire=70), and the generation rate is covered by the unit tests in gamenative-drm#71.

Not verified

  • A later session on the same payload came up black — four swapchains created, GL healthy (DRI3 present=1, no err:wgl), but the guest idle at 0 % with no present mode: line and no frames. Not diagnosed, and not attributed to this change. Windowed-vs-fullscreen presentation and activation timing are the open candidates.
  • One 2D title, one device. Tear, pacing under load, generation at the cap, and a 3D GL title are unmeasured.
  • The payload's shim is built from the fix/lsfg-generation-rate branch rather than merged master.

Summary by cubic

Fixes two gamescope bugs in 1.4.1: the FPS cap was dropped whenever frame generation was on, and GL guest titles never presented through the shim.

The cap now reaches the shim unconditionally. Previously setFpsLimit(if (lsfg) 0 else limit) sent cap=0 with frame generation armed, so the shim took its no-cap row (refresh / m acquires). Measured on Nova: cap=60 acquire=60 and cap=70 acquire=70 across two cap changes. Generation's leftover is also spent as a rate rather than floored to whole frames, so a cap above half the refresh uses the cap room (cap 40 ×2 at 60 Hz yields 60 fps, not 40).

GL titles can now present through the shim, behind a per-container OpenGL Driver setting (Graphics tab, hidden on X11, default zink). The payload carries a guest kopper GL stack in lib/gl/ that makes a GLX client create VkSurfaceKHR from its own X window, riding the same ring, gate, and release notes as Vulkan guests; zink keeps the pre-kopper path (renders into the X server, presenting by copy) for containers whose titles worked before. LIBGL_KOPPER_DISABLE is now set only for X11 sessions in XServerScreen.

Payload 20261121.1 — the archive ships as a release asset; only the version bump is here. Requires GameNative/gamescope#41 (GL stack), GameNative/xserver#5 (Xwayland with GLX), and GameNative/gamenative-drm#71 (generation rate).

Not verified — one later session on this payload came up black: swapchains created and GL healthy, but the guest idle at 0 % with no present-mode line. Not diagnosed or attributed to this change. One 2D title and one device; the payload's shim was built from a fix branch rather than merged master.

Summary by CodeRabbit

  • New Features
    • Added a Gamescope OpenGL driver setting with Zink and Kopper options.
  • Bug Fixes
    • Gamescope sessions now respect the configured FPS limit even when LSFG is enabled.
    • Improved graphics library selection for Gamescope sessions; X11 sessions retain their existing graphics behavior.
  • Updates
    • Updated the bundled Gamescope components to a newer version.