mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-11 19:11:08 +00:00
38 lines
2.0 KiB
Bash
38 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# Runs a program from the desktop on the GPU: in a gamescope of its own that draws straight into
|
|
# the app's compositor (wayland-0), not inside the desktop's KWin. KWin composites in software, and
|
|
# gives its windows no DMA-BUFs - a Vulkan program there fails at its swapchain
|
|
# (VK_ERROR_SURFACE_LOST, RPCS3's error). Here it gets the same path as a program started from the
|
|
# app's rail: full screen over the desktop until it exits, then the desktop is back.
|
|
# droiddeck-gpu <program> [args...]
|
|
set -u
|
|
[ $# -gt 0 ] || { echo "usage: droiddeck-gpu <program> [args...]" >&2; exit 64; }
|
|
if [ -n "${BL_DEBUG_DIR:-}" ]; then
|
|
exec >>"$BL_DEBUG_DIR/desktop.log" 2>&1
|
|
fi
|
|
width=${BL_WIDTH:-1280}
|
|
height=${BL_HEIGHT:-720}
|
|
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$width" -h "$height")
|
|
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
|
args+=(-r "$BL_FPS")
|
|
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
|
|
args+=(-r "$BL_REFRESH")
|
|
fi
|
|
[ "${BL_HDR:-0}" = 1 ] && args+=(--hdr-enabled)
|
|
echo "== droiddeck-gpu $(date -u +%H:%M:%S): $* (gamescope ${width}x${height} on wayland-0)"
|
|
# gamescope is a client of the app's compositor, beside the desktop's KWin; the program inside it reaches it
|
|
# through gamescope's own Xwayland, as in a Steam session.
|
|
export WAYLAND_DISPLAY=wayland-0
|
|
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
|
|
# GL on the GPU again (zink on Turnip, as the session sets it): the desktop itself draws GL in software.
|
|
# Qt Quick back on its GPU renderer and KWin's software compositing not passed on, too.
|
|
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND KWIN_COMPOSE
|
|
export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
|
|
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
|
|
# AppImages cannot mount under proot; the menu entries already say so, a hand-typed one may not.
|
|
export APPIMAGE_EXTRACT_AND_RUN=1
|
|
gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
|
|
rc=$?
|
|
echo "== droiddeck-gpu $(date -u +%H:%M:%S): exited $rc"
|
|
exit $rc
|