android: build the glamor Mesa stack from upstream 26.2.6 in this tree

Merged
UT
12d ago
+1864-22

Problem

Xwayland in the payload runs glamor on zink from a minimal Mesa that package-gamescope.sh took from GN_MESA_GLAMOR_STAGE. That stage came from a local build of GameNative/mesa build-xwayland (25.0-devel), which no CI ever built. Its zink leaks one fd per composited frame on kernels older than 6.0: the DMA_BUF_IOCTL_EXPORT_SYNC_FILE failure path returns without closing. On a Galaxy Tab S7 (kernel 4.19) the shipped 20261028.4 payload climbs about 300 fds/s and Xwayland hits 32767 fds within 113 s, then the game freezes. Upstream Mesa 26.2.6 has the fix.

Change

android/mesa-glamor/ builds the glamor stack from this repo:

  • fetch-mesa.sh downloads https://archive.mesa3d.org/mesa-26.2.6.tar.xz, checks sha256 b9436b3e1a8be76fbd4823dc884f90596ab7c6ac5e1867a305e66ffccfb31a92 (the extracted tarball is identical to the mesa-26.2.6 tag tree), and applies patches/ with patch -p1.
  • patches/0001 the gndrm loader/GBM changes (accept the gndrm socket fd, pick zink for it, find the GBM backend next to libgbm, build dril for a GBM-only build). Ported from the fork; the pipe-loader half is gone because upstream no longer has a dynamic pipe loader.
  • patches/0002 zink names its command buffers only when tracing or capturing. gn-vkshim passes vkSetDebugUtilsObjectNameEXT to Turnip with its own wrapper handles, and Turnip faults in the first eglCreateContext. This can go once the shim unwraps the handle.
  • build-mesa-glamor.sh, cross.txt.in and overlay/ are the build recipe as plain files: zink + softpipe, no LLVM, glvnd EGL vendor on the GBM platform, ELF TLS.

The workflow builds the stage after Xwayland (own venv, since Mesa needs meson >= 1.4), runs check-no-libandroid.sh on it and uploads it as mesa-glamor-stage-<sha>. The tarball and ccache are cached.

package-gamescope.sh now defaults to that stage, reads the libgallium-<version>.so name from it, and no longer stages libglapi.so.0 (upstream folded glapi into libgallium in 25.1). check-payload-closure.sh follows.

This replaces GameNative/mesa#40; nothing Mesa-side lives in a fork any more.

Verification

Galaxy Tab S7 (Android 11, kernel 4.19), shipped 20261028.4 with only the glamor files swapped, composited GL 800x600 decorated window held 150 s, then a two-window GDI hold for 150 s:

payloadXwayland fds
shipped 20261028.4climbs ~300/s, 32767 within 113 s
local build of this port75-92 for 7 minutes
stage from this PR's CI run (gamescope-glamor-ci-aa304b1-base20261028.4)78 -> 88 over the GL hold, 98 flat over the GDI hold; wrapper suite 12/12 pass, GDI hold 5741 frames

The CI-built stage has the same file list as the local one. check-no-libandroid.sh is clean on the test payload; check-payload-closure.sh reports only libnativewindow.so from libadrenotools_gamescope.so, which the shipped payload reports too.

For review

  • The two patches in android/mesa-glamor/patches/; everything else is build plumbing.
  • The stage file list (artifact) against what the packager copies: libEGL_mesa.so.0, libgallium-26.2.6.so, libgbm.so.1/libgbm.so, gbm/dri_gbm.so, dri/libdril_dri.so, 50_mesa.json.
  • The app still pins the current payload; a GamescopePayload bump comes after a release payload is built from this.