From d67e6b93d108e6ac47ee34a50aa8ad95becab9ef Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Fri, 20 Nov 2026 23:05:11 +0800 Subject: [PATCH] android: build Xwayland with GLX, so a GL guest can reach the shim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A GL guest's libGL presents through GLX, and Mesa's kopper -- the zink path that hands its frames to the Vulkan WSI instead of copying them through XShmPutImage -- lives in the GLX frontend and initialises against the server's GLX extension. With `-Dglx=false` there is no such extension: wine's X11 driver fakes one under __ANDROID__ (hence WINE_X11FORCEGLX in the app's environment), and a kopper client has nothing to bind to, so the only GL path that worked was the shm copy — whose frames never create a VkSurface and therefore never meet the ICD's swapchain, cap, generation or release notes. Measured on the build: 1132 GLX strings in the binary, glxdri2 compiled in. The headers this needs are not all in the termux prefix: it ships glxproto.h, glxtokens.h and GL/internal/dri_interface.h but not GL/gl.h, GL/glx.h or GL/glext.h, so the build otherwise fails inside glx/createcontext.c. The script now checks for all four and names the missing one. Server-side GLX does not force a client to use it: a client that keeps presenting through XShmPutImage still can, so the existing GL path is unchanged by this. --- android/build-xwayland.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/android/build-xwayland.sh b/android/build-xwayland.sh index c9e12a8cd..a8cc14fec 100755 --- a/android/build-xwayland.sh +++ b/android/build-xwayland.sh @@ -22,6 +22,16 @@ RUNTIME="${GN_XWAYLAND_PREFIX:-/data/user/0/app.gamenative/files/gamescope}" NDK="${GN_XWAYLAND_NDK:-$HOME/Android/Sdk/ndk/27.3.13750724}" NDK_BIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" +# GLX needs the libGL headers, and the termux prefix ships the protocol ones +# (glxproto.h, glxtokens.h, dri_interface.h) without GL/gl.h, GL/glx.h and +# GL/glext.h. Name the missing file here rather than let the build fail deep inside +# glx/createcontext.c. +for hdr in gl.h glx.h glext.h internal/dri_interface.h; do + [ -f "$DEPS/include/GL/$hdr" ] || { + echo "error: $DEPS/include/GL/$hdr missing (needed by -Dglx=true)" >&2 + exit 1; } +done + # --- cross file --------------------------------------------------------------- # android/cross/aarch64-linux-android.txt is generated from the committed .txt.in # template and the settings above, so no absolute path is stored in the tree. @@ -89,8 +99,14 @@ fi # Xwayland runs the GPU path instead of shm-only. Gamescope no longer needs its # content-override hack for the guest's frames: they reach the X11 window as a # real dma-buf through the same device (see -# gamescope/android/08-xwayland-render-node.md). glx stays off (no GLX -# clients); the present extension itself is unconditional in this tree. +# gamescope/android/08-xwayland-render-node.md). The present extension itself is +# unconditional in this tree. +# +# glx is on: a GL guest's libGL presents through GLX, and Mesa's kopper -- the +# zink path that hands its frames to the Vulkan WSI instead of copying them +# through XShmPutImage -- lives in the GLX frontend and initialises against the +# server's GLX extension. With glx off, GL clients fall back to an shm copy and +# their frames never reach the ICD's swapchain. # xkb dirs point at the runtime payload layout; xkeyboard-config data is # staged by package-xwayland.sh. RECONF="" @@ -109,7 +125,7 @@ meson setup "$XS_DIR/build-android" "$XS_DIR" \ --cross-file "$XS_DIR/android/cross/aarch64-linux-android.txt" \ -Dprefix="$RUNTIME" \ -Dxvfb=false \ - -Dglamor=true -Dglx=false -Ddri3=true -Ddrm=true \ + -Dglamor=true -Dglx=true -Ddri3=true -Ddrm=true \ -Dlisten_tcp=false \ -Dlibdecor=false \ -Dmitshm=true \