diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt
index b49e6392d8..c81c1831c0 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt
@@ -483,6 +483,8 @@ class SessionService : Service() {
val windowCheckMs = if (SessionState.performanceMode) 100 else 0
guest.add("DROIDDECK_WSI_BYPASS_CHECK_MS=$windowCheckMs")
guest.add("WINE_OFFSCREEN_CHECK_MS=$windowCheckMs")
+ // With a frame limit, gamescope's limiter also holds the games to it instead of only pacing the screen.
+ guest.add("DROIDDECK_GAME_FRAME_LIMIT=" + (if (SessionState.performanceMode) 1 else 0))
if (SessionPrefs.compositorFpsLimit(SessionState.fpsLimit, SessionState.performanceMode) == SessionPrefs.FPS_UNPACED) {
// gamescope turns buffers around slower than an unpaced game draws; more images keep it drawing.
guest.add("GAMESCOPE_WSI_MIN_IMAGE_COUNT=8")
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 03204a9ffa..6de9cdb354 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -258,7 +258,7 @@
Auto uses at least 16:9.
Frame limit
Performance mode
- With no frame limit, games run as fast as they can: frames go back to the game without waiting for the screen. With a frame limit, frames stay paced to it. Either way, gamescope and Wine skip repeated window checks. Uses more power and runs warmer without a limit. Applies next session.
+ With no frame limit, games run as fast as they can: frames go back to the game without waiting for the screen. With a frame limit, games are held to it instead of drawing frames the screen never shows. Either way, gamescope and Wine skip repeated window checks. Uses more power and runs warmer without a limit. Applies next session.
Caps the whole session. The display switches to a refresh rate the cap divides evenly.
HDR
HDR10 output
diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session
index bc3febb332..755a9fce89 100755
--- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session
+++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session
@@ -70,6 +70,31 @@ steam_update_stuck() {
[ "$steam_updates" -ge 3 ]
}
+# gamescope's --framerate-limit lasts only until its first frame, which recomputes the limit
+# from the per-app value set over gamescope_control, and Steam resets that value to 0 while it
+# starts. Watch gamescope's limiter state file (first byte 1 = limiter on) and set the value
+# again whenever it is off; the limiter then makes the WSI layer hold Vulkan games (DXVK and
+# VKD3D included) to it. Shell builtins only, so the once-a-second check starts no process.
+hold_games_to_frame_limit() {
+ local fps=$1 file=$2 parent=$3 state sent=0 nap napfd=
+ command -v gamescopectl >/dev/null || { echo "== gamescope: no gamescopectl, the frame limit paces the screen only"; return 0; }
+ nap=$(mktemp -u "${XDG_RUNTIME_DIR:-/tmp}/droiddeck-nap.XXXXXX") && mkfifo "$nap" 2>/dev/null \
+ && exec {napfd}<>"$nap"; rm -f "$nap"
+ while kill -0 "$parent" 2>/dev/null; do
+ if [ -f "$file" ]; then
+ state=
+ IFS= read -r -n1 -d '' state < "$file"
+ if [ "$state" != $'\x01' ] && gamescopectl debug_set_fps_limit "$fps" >/dev/null 2>&1; then
+ sent=$((sent + 1))
+ if [ "$sent" = 1 ]; then echo "== gamescope: games held to $fps fps"
+ elif [ "$sent" -le 4 ]; then echo "== gamescope: the frame limit was reset, set it again"
+ fi
+ fi
+ fi
+ if [ -n "$napfd" ]; then read -r -t 1 -u "$napfd" _; else sleep 1; fi
+ done
+}
+
run_gamescope() (
local status_file child_status compositor_status
status_file=$(mktemp "${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steam-exit.XXXXXX") || exit 73
@@ -238,6 +263,13 @@ if [ -z "${BL_INSIDE:-}" ]; then
fi
if [ "${BL_FPS:-0}" -gt 0 ]; then
args+=(-r "$BL_FPS")
+ # -r alone only paces what reaches the screen: a game without vsync keeps drawing
+ # hundreds of frames that are thrown away. Performance mode also holds the games to it.
+ if [ "${DROIDDECK_GAME_FRAME_LIMIT:-0}" = 1 ]; then
+ game_frame_limit=$BL_FPS
+ else
+ echo "== gamescope: frame limit $BL_FPS paces the screen only"
+ fi
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
args+=(-r "$BL_REFRESH")
fi
@@ -258,6 +290,11 @@ if [ -z "${BL_INSIDE:-}" ]; then
echo "== gamescope: mangoapp on ($(command -v mangoapp), config $MANGOHUD_CONFIGFILE)"
fi
export BL_INSIDE=1
+ # A fixed path: left to itself gamescope creates a new limiter state file on every start.
+ rm -f "${XDG_RUNTIME_DIR:-/tmp}"/gamescope-limiter-*
+ export GAMESCOPE_LIMITER_FILE="${XDG_RUNTIME_DIR:-/tmp}/droiddeck-gamescope-limiter"
+ rm -f "$GAMESCOPE_LIMITER_FILE"
+ [ -n "${game_frame_limit:-}" ] && hold_games_to_frame_limit "$game_frame_limit" "$GAMESCOPE_LIMITER_FILE" $$ &
if [ "$mode" = steam ]; then
if /usr/local/bin/droiddeck-pipewire start; then
eval "$(/usr/local/bin/droiddeck-pipewire env)"