refactor: remove duplicate session frame limiter (#1616)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-26 11:25:31 -04:00
1 parent ee1b3b26e1
commit 5d945d7784
47 files changed
+94 -170

No files matched your search

@@ -16,7 +16,7 @@ if [ -n "${BL_LOG:-}" ] && [ -z "${BL_INSIDE:-}" ]; then
fi
exec > >({ dd of="$BL_LOG" oflag=append conv=notrunc iflag=count_bytes count="${BL_LOG_CAP:-268435456}" bs=65536 status=none; cat >/dev/null; }) 2>&1
echo "== droiddeck-session $(date) mode=$mode $*"
echo "== uid=$(id -u) size=${BL_WIDTH:-?}x${BL_HEIGHT:-?} fps=${BL_FPS:-0} icd=${VK_ICD_FILENAMES:-none}"
echo "== uid=$(id -u) size=${BL_WIDTH:-?}x${BL_HEIGHT:-?} icd=${VK_ICD_FILENAMES:-none}"
echo "== gamescope: $(gamescope --version 2>&1 | head -1) at $(command -v gamescope)"
echo "== rootfs: $(cat /.version 2>/dev/null || echo unversioned)"
fi
@@ -70,31 +70,6 @@ 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
@@ -261,16 +236,7 @@ if [ -z "${BL_INSIDE:-}" ]; then
args+=(-S stretch)
export BL_STRETCHED=1
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
if [ "${BL_REFRESH:-0}" -gt 0 ]; then
args+=(-r "$BL_REFRESH")
fi
[ "$mode" = steam ] && [ "${BL_STEAM_UI:-}" != desktop ] && args+=(-e)
@@ -294,7 +260,6 @@ if [ -z "${BL_INSIDE:-}" ]; then
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)"