mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
* feat(display): zero-copy presentation toggle and compositor display buffers Adds a Zero-copy presentation switch under Steam Settings, Display, Session Display (on by default), and a display-buffer allocator in the compositor: a Vulkan driver that states displayBuffers asks it for the memory of the images it exports, so frames presented through the nested compositor are gralloc buffers that go on the display layer without a copy. Compressed buffers are offered only where the device's allocator matches the layout the drivers render to; everything else stays on the copy path. The private buffer protocol is renamed to droiddeck-ahb-v1. * fix(display): zero-copy frames keep the full refresh rate Two buffers set on the game layer inside one refresh replaced each other, and a frame that slipped into the next refresh made the compositor hold and drop the on-time frame behind it. The layer now queues buffers, and a refresh takes a second frame when the one before it took none. The pacing tool no longer counts its dump time in the frame rate. * Keep cropped scenes on the display layer and pace layer frames evenly Accept any in-bounds source crop for the display layer and map the draw geometry the same way the copy path does. Time layer frames against the display's frame timeline, and when the game's rate is a steady whole fraction of the refresh rate show each frame a fixed number of refreshes after the last so uneven arrivals no longer reach the screen. * List zero-copy in the settings map * Hold display buffers until the display releases them A buffer the game or gamescope rendered straight into went back to its client as soon as the next one was latched, with the display's release fence attached to the dma-buf. The KGSL driver does not wait on that fence, so the client could draw into a buffer the panel was still reading. Display buffers now wait for the release fence before the release event, and gamescope composites only into output images the host has released. * Keep the game picture copy-free when an overlay has no display layer When the display cannot give a second layer of its own to an overlay, the compositor tells gamescope how many planes it can show directly. gamescope then composes its overlays into the game picture, which still reaches the display without a copy. * feat(session): the panel refresh rate follows the session's frame rate The session learns the panel's refresh rates and reports the refresh rate and frame rate it wants. The panel moves to the highest rate the frame rate divides evenly, frame generation counts at its output rate, and a panel whose rate the system holds offers only that rate. * feat(session): the panel follows a frame rate the game holds on its own The compositor reports the game's frame rate once a second. A rate that holds for three seconds and divides a panel rate becomes the content rate when neither the app's limit nor the session's limiter is setting the pace, so a game capped in its own settings gets a panel rate its frames divide into. A rate that was dropped has to hold twice as long before it is used again. * Show generated frames on the game's display layer With frame generation on, the game's own frames stay on their display layer untouched and each generated frame is placed on the same layer between them, timed across the game's frame interval. The compositor pass is kept when effects, HDR routing or a cursor need it, or when the panel cannot show the multiplied rate. * Keep scaling, generated frames and HDR on the display layer A scaler or frame generation with zero-copy on now draws once into the display layer instead of falling back to the copied surface. HDR output goes to the layer when the panel supports it; on a panel without HDR the picture is tone-mapped on the same path, and the toggle is labelled to match what the panel can do. * Spread a frame limit the refresh rate does not divide evenly across refreshes * Cover the spare-tick and panel-rate paths in the compositor source tests * Pin the gamescope build with the display-plane, release, refresh and limiter patches * Give the layer and terminal-caller harnesses the black fill state they compile against * feat(display): switch HDR during a session without restarting the app The compositor now offers HDR whenever the device can present it, and the HDR setting only decides whether the session uses it. Both HDR switches set gamescope's hdr_enabled, the compositor's HDR output and zero-copy for the running session. gamescope patch 0139 lets hdr_enabled change after start. The 'Restart the app to apply.' hint is removed from every locale. * Remake the output images in the new format when HDR is switched during a session * Pin the gamescope build that switches HDR during a session * Apply a saved HDR opt-out at session start and keep HDR retries with their session * Serialise the HDR output switch with the gate opening * feat(display): keep the client's HDR setting and the session's in step The session publishes its HDR state with the other device controls and the client helper applies it to the client's own display setting. A change made in the client is reported back and goes through the same switch the drawer and Session Display use, so all three always show one value. * fix(desktop): keep the display-buffer socket when the runtime directory is cleared The desktop launcher removed everything in the runtime directory except the compositor's Wayland socket, which took the display-buffer socket with it, so no desktop program could ask for display buffers and every frame was copied. * fix(display): the client's HDR setting follows the session in every client mode The bridge only ran when a variable nothing sets was present, so the client's HDR setting and the session's never met. It now runs whenever the session publishes an HDR state, and a client that has no such setting is asked again only every ten seconds. * fix(display): harden display-buffer hand-off, layer fallbacks and HDR sync - Stop closing a buffer handle's descriptor the allocator still owns, and free an allocation whose reply could not be sent. - Rebuild the advertised buffer formats when zero-copy is switched during a session. - Fall back to the copy path when a layer buffer cannot be allocated, and hide the game layer when it is skipped for a frame. - Keep a release fence that has not signalled instead of rendering into a buffer the display still reads. - Ignore a refresh-target reset from a client that does not own the target. - Restart the content-rate measurement after a pause, clear it when the game stops, and lengthen engagement only for a rate that was released before. - Compare colour conversions by their values, and read padded cursor buffers at their row width. - Use the running session's mode for the HDR and zero-copy settings, probe the display before screen effects are pushed, retry a held panel mode, and ignore callbacks after the activity is destroyed. - Write a newer HDR value while an earlier write is settling, and reapply the value after the bridge is reinstalled.
142 lines
7.3 KiB
Bash
142 lines
7.3 KiB
Bash
#!/bin/bash
|
|
set -u
|
|
export XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=KDE XDG_SESSION_DESKTOP=KDE DESKTOP_SESSION=plasma
|
|
export KDE_FULL_SESSION=true KDE_SESSION_VERSION=6 KDE_APPLICATIONS_AS_SCOPE=0
|
|
export QT_QPA_PLATFORM="wayland;xcb" GDK_BACKEND=wayland,x11 SDL_VIDEODRIVER=wayland,x11
|
|
unset QT_QPA_PLATFORMTHEME
|
|
export QT_FORCE_STDERR_LOGGING=1
|
|
export MOZ_ENABLE_WAYLAND=1 MOZ_USE_XINPUT2=1
|
|
export SHELL=/bin/bash
|
|
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
|
|
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
|
|
export MOZ_SHM_NO_SEALS=1
|
|
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
|
|
export KWIN_USE_OVERLAYS=0
|
|
[ -e /etc/mpv/mpv.conf ] || { mkdir -p /etc/mpv && echo gpu-sw=yes >/etc/mpv/mpv.conf; } 2>/dev/null
|
|
for conf in client client-rt; do
|
|
mkdir -p "/etc/pipewire/$conf.conf.d" && printf 'context.properties = {\n module.rt = false\n}\n' >"/etc/pipewire/$conf.conf.d/droiddeck-rt.conf"
|
|
done 2>/dev/null
|
|
export DROIDDECK_NESTED_SCALE=1
|
|
export DROIDDECK_GLTHREAD=${mesa_glthread:-}
|
|
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2 mesa_glthread
|
|
if [ -n "${DD_DEBUG_DIR:-}" ]; then
|
|
mkdir -p "$DD_DEBUG_DIR" 2>/dev/null || true
|
|
exec >>"$DD_DEBUG_DIR/desktop.log" 2>&1
|
|
echo "== droiddeck-desktop $(date -u '+%Y-%m-%d %H:%M:%S UTC') ${DD_WIDTH:-1280}x${DD_HEIGHT:-720}"
|
|
fi
|
|
find "$XDG_RUNTIME_DIR" -mindepth 1 -maxdepth 1 ! -name 'wayland-0*' ! -name 'keymap.xkb' ! -name 'droiddeck-display-buffers' -exec rm -rf {} + 2>/dev/null
|
|
chmod 700 "$XDG_RUNTIME_DIR" 2>/dev/null
|
|
mkdir -p /tmp/.X11-unix /tmp/.ICE-unix && chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix 2>/dev/null
|
|
export DD_DESKTOP=1
|
|
ln -sf /usr/local/bin/droiddeck-steam-launch /usr/local/bin/steamdeck-steam 2>/dev/null
|
|
ln -sf /usr/local/bin/droiddeck-steam-shim /usr/local/bin/steam 2>/dev/null
|
|
python3 /usr/local/bin/droiddeck-desktop-games 2>&1 | sed 's/^/[games] /'
|
|
python3 /usr/local/bin/droiddeck-desktop-programs 2>&1 | sed 's/^/[programs] /'
|
|
# startplasma applies this file over the session environment, and keeps what an earlier session wrote.
|
|
kwriteconfig6 --file plasma-localerc --group Formats --key LANG "${LANG:-C.UTF-8}"
|
|
if [ -n "${LANGUAGE:-}" ]; then
|
|
kwriteconfig6 --file plasma-localerc --group Translations --key LANGUAGE "$LANGUAGE"
|
|
else
|
|
kwriteconfig6 --file plasma-localerc --group Translations --key LANGUAGE --delete
|
|
fi
|
|
cat > /usr/share/applications/droiddeck-steam-x64.desktop <<'ENTRY'
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Steam x86-64 (FEX, experimental)
|
|
Comment=Valve's x86-64 Linux client under FEX, in its own home with its own login
|
|
Exec=konsole -e /usr/local/bin/droiddeck-steam-x64
|
|
Icon=steam
|
|
Categories=System;
|
|
ENTRY
|
|
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'
|
|
( while sleep 30; do python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'; done ) &
|
|
python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'
|
|
/usr/local/bin/droiddeck-desktop-window-rules 2>&1 | sed 's/^/[rules] /'
|
|
( python3 /usr/local/bin/droiddeck-library-perms 2>&1 | sed 's/^/[perms] /' ) &
|
|
mkdir -p /usr/local/share/applications
|
|
cat > /usr/local/share/applications/droiddeck-ime.desktop <<'ENTRY'
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Android keyboard
|
|
Exec=/usr/local/bin/droiddeck-ime
|
|
NoDisplay=true
|
|
X-KDE-Wayland-VirtualKeyboard=true
|
|
ENTRY
|
|
input_method=$(kreadconfig6 --file kwinrc --group Wayland --key InputMethod 2>/dev/null)
|
|
case $input_method in
|
|
''|*/droiddeck-ime.desktop) kwriteconfig6 --file kwinrc --group Wayland --key InputMethod /usr/local/share/applications/droiddeck-ime.desktop ;;
|
|
esac
|
|
python3 /usr/local/bin/droiddeck-open --install 2>&1 | sed 's/^/[open] /'
|
|
export APPIMAGE_EXTRACT_AND_RUN=1
|
|
[ -e /etc/xdg/kiorc ] || printf '[Executable scripts]\nbehaviourOnLaunch=execute\n' >/etc/xdg/kiorc 2>/dev/null
|
|
desktop_dir=$(xdg-user-dir DESKTOP 2>/dev/null); [ -n "$desktop_dir" ] && [ "$desktop_dir" != "$HOME" ] || desktop_dir=$HOME/Desktop
|
|
if [ ! -e "$HOME/.config/droiddeck-desktop-icons" ]; then
|
|
mkdir -p "$desktop_dir" "$HOME/.config"
|
|
cp -f /usr/share/applications/droiddeck-return-gaming.desktop "$desktop_dir/Return.desktop" 2>/dev/null
|
|
cp -f /usr/share/applications/steamdeck-steam.desktop "$desktop_dir/steam.desktop" 2>/dev/null
|
|
chmod +x "$desktop_dir"/*.desktop 2>/dev/null
|
|
touch "$HOME/.config/droiddeck-desktop-icons"
|
|
fi
|
|
[ -f "$desktop_dir/Return.desktop" ] && cp -f /usr/share/applications/droiddeck-return-gaming.desktop "$desktop_dir/Return.desktop" 2>/dev/null
|
|
if command -v flatpak >/dev/null 2>&1 && [ ! -d /var/lib/pacman ]; then
|
|
FLATPAK_BWRAP=/usr/local/bin/droiddeck-bwrap flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo >/dev/null 2>&1 &
|
|
fi
|
|
skel_done=$HOME/.local/share/droiddeck/skel-copied
|
|
if [ -d /etc/skel ] && [ ! -e "$skel_done" ]; then
|
|
cp -rn /etc/skel/. "$HOME/" 2>/dev/null
|
|
mkdir -p "${skel_done%/*}" && : > "$skel_done"
|
|
fi
|
|
if [ -x /usr/lib/snapd/snap-confine ] && [ ! -d /var/lib/pacman ]; then
|
|
/usr/local/bin/droiddeck-snapd >/dev/null 2>&1 &
|
|
export XDG_DATA_DIRS=/var/lib/snapd/desktop:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
|
|
export PATH=$PATH:/snap/bin
|
|
fi
|
|
update-mime-database /usr/share/mime >/dev/null 2>&1 &
|
|
[ -f /usr/share/icons/hicolor/icon-theme.cache ] || gtk-update-icon-cache -q -t /usr/share/icons/hicolor 2>/dev/null &
|
|
[ -f /usr/share/glib-2.0/schemas/gschemas.compiled ] || glib-compile-schemas /usr/share/glib-2.0/schemas 2>/dev/null
|
|
if [ -f "$HOME/.droiddeck-desktop-debug" ]; then
|
|
mkdir -p "$HOME/.cache/droiddeck"
|
|
export MOZ_LOG="nsHttp:3,nsSocketTransport:3,nsHostResolver:4,NetworkLinkService:5,NetworkConnectivityService:5,nsIOService:5"
|
|
export MOZ_LOG_FILE="$HOME/.cache/droiddeck/firefox-net.log"
|
|
export QT_LOGGING_RULES="kwin_*.debug=true"
|
|
fi
|
|
if [ -f "$HOME/.droiddeck-remote-run" ]; then
|
|
mkdir -p "$HOME/.cache/droiddeck/run"
|
|
(
|
|
while sleep 1; do
|
|
for f in "$HOME"/.cache/droiddeck/run/*.sh; do
|
|
[ -f "$f" ] || continue
|
|
mv -f "$f" "$f.running" || continue
|
|
( echo "[run] $(basename "$f") started"; WAYLAND_DISPLAY=wayland-1 DISPLAY=:1 bash "$f.running" 2>&1 | sed "s/^/[run] /"; echo "[run] $(basename "$f") exited"; rm -f "$f.running" ) &
|
|
done
|
|
done
|
|
) &
|
|
fi
|
|
if [ "$(cat /usr/share/droiddeck/kwin-compositor 2>/dev/null)" = opengl ]; then
|
|
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND
|
|
export KWIN_COMPOSE=O2 MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
|
|
if [ -z "${KWIN_RENDER_NODES:-}" ]; then
|
|
for node in /dev/dri/renderD0 /dev/dri/renderD307 /dev/dri/renderD*; do
|
|
if [ -c "$node" ]; then export KWIN_RENDER_NODES="$node"; break; fi
|
|
done
|
|
fi
|
|
mkdir -p /run/droiddeck/kwin
|
|
printf '#!/bin/sh\nGALLIUM_THREAD=0 exec /usr/bin/kwin_wayland "$@"\n' > /run/droiddeck/kwin/kwin_wayland
|
|
chmod 755 /run/droiddeck/kwin/kwin_wayland
|
|
export PATH=/run/droiddeck/kwin:$PATH
|
|
fi
|
|
# Plasma uses the rootfs libpipewire; the bundle's module and plugin paths leave it without a shell.
|
|
if ! /usr/local/bin/droiddeck-pipewire start; then
|
|
echo "== pipewire: not running; screen capture has no picture"
|
|
fi
|
|
echo "== droiddeck-desktop: Plasma on $WAYLAND_DISPLAY"
|
|
dbus-run-session -- startplasma-wayland
|
|
rc=$?
|
|
/usr/local/bin/droiddeck-pipewire stop
|
|
echo "== droiddeck-desktop: Plasma ended ($rc)"
|
|
if [ "$rc" -eq 0 ] && [ -z "${DD_BOTTOM_DESKTOP:-}" ]; then
|
|
/usr/local/bin/droiddeck-steam-launch bigpicture
|
|
sleep 30
|
|
fi
|
|
exit $rc
|