Files
DroidDeck/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex-update
T
MaxsTechReview 96e4bd4eab fix(fex): x86-64 programs on Wayland render on the GPU (#3174)
* fix(fex): x86-64 programs on Wayland render on the GPU

* fix(fex): address review on the Wayland and EGL thunks

Keep the GLES overlay on the 64-bit EGL thunk only, filter EGL extensions
whose entrypoints the guest lacks, accept EGLDeviceEXT displays, make the
Wayland display check thread-safe, bound event signature copies, reject a
second listener without freeing the first and guard wl_array_add growth.

The FEX updater now removes thunk libraries a new build no longer ships, so
an older 32-bit Wayland or EGL thunk cannot be enabled by the new config.

* fix(fex): check every EGL extension entrypoint and every host device

EGL_EXTENSIONS now hides an extension unless the guest exports all of its
entrypoints, using a table built from the EGL registry. eglGetDisplay asks
the host for its device count before matching EGLDeviceEXT handles.

* fix(fex): pick the eglGetDisplay platform the way Mesa does

A legacy eglGetDisplay handle now follows EGL_PLATFORM or EGL_DISPLAY first,
then Wayland detection, and only then the X11 mapping, so device handles no
longer depend on enumerating host devices.
2026-11-26 05:34:42 -05:00

82 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
FEX_TAG=fex-2610-r5
FEX_SHA256=0fc1ca2ba13817ad70d1ea157119a75c9c02446b57d166e6d676cce0807c19c4
FEX_URL=https://github.com/Droid-Deck/DroidDeck-Components/releases/download/$FEX_TAG/fex.tzst
fex_loads() {
local b out
for b in FEX FEXServer unsquashfs; do
out=$(/usr/lib/ld-linux-aarch64.so.1 --list "$1/usr/local/bin/$b" 2>&1) && ! grep -q "not found" <<<"$out" && continue
echo "== FEX check: $b: $(grep -E "not found|error" <<<"$out" | tr -s '\t ' ' ' | tr '\n' ';')" >&2
return 1
done
}
fex_install() {
local tag=$1 sha=$2 urls=$3 dst=/ tmp u f
tmp=$(mktemp -d)
for u in $urls; do
curl -fsSL --retry 2 --connect-timeout 20 --speed-limit 1024 --speed-time 60 "$u" -o "$tmp/fex.tzst" && echo "$sha $tmp/fex.tzst" | sha256sum -c --quiet >/dev/null 2>&1 && break
rm -f "$tmp/fex.tzst"
done
if [ ! -s "$tmp/fex.tzst" ]; then
echo "== FEX $tag: no source gave the archive with sha256 ${sha:0:12}" >&2
rm -rf "$tmp"
return 1
fi
if ! { mkdir "$tmp/root" && zstd -dc "$tmp/fex.tzst" | tar -C "$tmp/root" -x && fex_loads "$tmp/root"; }; then
rm -rf "$tmp"
return 1
fi
(cd "$tmp/root" && find . ! -type d) > "$tmp/files"
for d in usr/local/share/fex-emu/GuestThunks usr/local/share/fex-emu/GuestThunks_32 usr/local/lib/fex-emu/HostThunks usr/local/lib/fex-emu/HostThunks_32; do
[ -d "$tmp/root/$d" ] && [ -d "$dst$d" ] || continue
(cd "$dst" && find "$d" ! -type d) | while IFS= read -r f; do grep -qxF "./$f" "$tmp/files" || echo "$f"; done
done > "$tmp/stale"
mkdir "$tmp/old"
while IFS= read -r f; do
f=${f#./}
if [ -e "$dst$f" ] || [ -L "$dst$f" ]; then
cp -a --parents "$dst$f" "$tmp/old" || { echo "== FEX $tag: could not keep $dst$f aside" >&2; rm -rf "$tmp"; return 1; }
fi
done < <(cat "$tmp/files" "$tmp/stale")
if tar -C "$tmp/root" -c . | tar -C "$dst" -x &&
( while IFS= read -r f; do rm -f "$dst$f" || exit 1; done < "$tmp/stale" ) && fex_loads "$dst" &&
mkdir -p "${dst}usr/local/share/fex-emu" && echo "$tag" > "${dst}usr/local/share/fex-emu/.droiddeck-tag"; then
rm -rf "$tmp"
return 0
fi
echo "== FEX $tag: the installed copy did not load or its tag was not written; putting the previous files back" >&2
while IFS= read -r f; do
f=${f#./}
[ -e "$tmp/old/$dst$f" ] || [ -L "$tmp/old/$dst$f" ] || rm -f "$dst$f"
done < "$tmp/files"
tar -C "$tmp/old$dst" -c . | tar -C "$dst" -x || echo "== FEX $tag: could not put the previous files back" >&2
rm -rf "$tmp"
return 1
}
fex_ready() {
local have ok=
have=$(cat /usr/local/share/fex-emu/.droiddeck-tag 2>/dev/null || true)
[ -x /usr/local/bin/FEX ] && fex_loads / && ok=1
if [ -n "${DD_FEX_TAG:-}" ]; then
if [ -n "$ok" ] && [ "$have" = "$DD_FEX_TAG" ]; then FEX_NOW=$have FEX_FROM=catalog; return 0; fi
step "downloading FEX ($DD_FEX_TAG)"
if fex_install "$DD_FEX_TAG" "${DD_FEX_SHA256:-}" "${DD_FEX_URLS:-}"; then FEX_NOW=$DD_FEX_TAG FEX_FROM=catalog; return 0; fi
if [ -n "$ok" ]; then FEX_NOW=$have FEX_FROM="kept; $DD_FEX_TAG did not install"; return 0; fi
fi
if [ -n "$ok" ] && [ "$have" = "$FEX_TAG" ]; then FEX_NOW=$have FEX_FROM=built-in; return 0; fi
step "downloading FEX ($FEX_TAG)"
if fex_install "$FEX_TAG" "$FEX_SHA256" "$FEX_URL"; then FEX_NOW=$FEX_TAG FEX_FROM=built-in; return 0; fi
if [ -n "$ok" ]; then FEX_NOW=$have FEX_FROM="kept; $FEX_TAG did not install"; return 0; fi
return 1
}
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
set -eu
step() { echo "== STEP $*" >&2; }
fex_ready || exit 1
echo "$FEX_NOW ($FEX_FROM)"
fi