android: build the GL stack a guest needs to reach the shim (GLX + kopper, EGL/GBM, GLES2)
What this is
The GL stack a guest needs to reach the shim, built from this tree and staged into
the payload. Four commits, all under android/:
| commit | what |
|---|---|
877b0b9c | android/mesa-gl/build-mesa-gl.sh — Mesa zink with GLX + DRI3, one monolithic libGL.so.1.2.0 |
6c89b6da | package-gamescope.sh stages it into lib/gl/ |
8b083d8a | the same stage also builds EGL + GBM, so Xwayland's glamor has a usable EGL |
3738bbe9 | and a real libGLESv2, which is the path glamor actually runs on |
Why GL needed its own stack at all
The container image's libGL is Mesa 24.3's libgl-xlib: zink renders on a
headless Vulkan instance and the frame is copied into the X server with
XShmPutImage. No VkSurfaceKHR is ever created, so the ICD shim sees no
swapchain — no acquire cap, no generation, no release note. A GL title was outside
the whole present path.
-Dplatforms=x11 -Dglx=dri -Dopengl=true -Dgallium-drivers=zink -Dglvnd=disabled
gives the kopper frontend instead: the GLX client creates its surface from its X
window (VK_KHR_xcb_surface, which the shim already serves), so a GL guest rides
the same ring, the same gate and the same release notes as a Vulkan guest.
It is staged in lib/gl/, not lib/: both Mesa stages emit libgallium-26.2.6.so
and one would overwrite the other. The launcher puts lib/gl first on
LD_LIBRARY_PATH, so a GL guest resolves this libGL and this libgallium while
gamescope and Xwayland keep the glamor stage's copies. Same Mesa version in both,
so no process can end up with two gallium APIs.
The server half: glamor cannot use desktop GL here
Shipping the kopper libGL was not enough, and the reason is in Mesa, not in our
build: src/egl/main/eglcurrent.h gates EGL_OPENGL_API on
#if HAVE_OPENGL && !DETECT_OS_ANDROID — "OpenGL is not a valid/supported API on
Android". So in Xwayland eglBindAPI(EGL_OPENGL_API) returns EGL_BAD_PARAMETER,
the display advertises EGL_CLIENT_APIS="OpenGL_ES" only, and no config carries
EGL_OPENGL_BIT. try_big_gl_api can never succeed; try_gles_api is the only
path — which is also how Android Xwayland is normally configured.
Measured inside the server, one pass over every request glamor might make:
EGL_CLIENT_APIS=[OpenGL_ES ]
config[0..2] RENDERABLE_TYPE=0x0044 ES1=0 ES2=1 ES3=1 GL=0
eglBindAPI(OpenGL)=0 err=BAD_PARAMETER
GL 3.1 core → BAD_ATTRIBUTE · 3.3 core → BAD_ATTRIBUTE
GL 2.1 compat → BAD_MATCH · 1.0 compat / no attribs → BAD_ALLOC
GLES2 / GLES3 → SUCCESS
BAD_ATTRIBUTE on the profile mask is the tell: it is emitted only when
api != EGL_OPENGL_API, i.e. the thread was still bound to ES.
The GLES2 path was then handed libglvnd's dispatch stub from the termux prefix.
Its entry points resolve through libGLdispatch, whose vendor is registered by a
glvnd EGL vendor library — and this stage is glvnd=disabled, so there is none.
glGetString returned NULL, glamor stopped at "your GL is broken", fell back to
software, and every GL client then read DRI3 not available. Staging this stage's
own libGLESv2 (88 304 B, NEEDs only libgallium + libc) fixed it:
glGetString reports zink Vulkan 1.4(Turnip Adreno (TM) 740) and glamor
initialises on GLES2.
Verified
Retroid Pocket Nova (Adreno 740, 120 Hz panel), SteamWorld Dig 2 under gamescope,
payload built from this branch:
Xwayland glGetString = zink Vulkan 1.4(Turnip Adreno (TM) 740)
glamor initialised on GLES2, no "DRI3 not available"
Dig2.exe maps gamescope/lib/gl/libGL.so.1.2.0 + libgallium-26.2.6.so
gn-vkshim ICD loaded pid=Dig2.exe
proxy swapchain create: 3 images for asked=3 ceiling=8
present mode: declared=fifo source=guest cap=60 acquire=60 generate=0
screen game content at 60.0 fps, HUD "LIMITED BY: FPS CAP"
First time a GL title has created a swapchain through the shim.
Companion: GameNative/xserver#5 — the same build needs a server-side GLX
extension for a kopper client to bind to, and that is what the other PR turns on.
Neither half alone moves a GL title onto the shim.
Not verified
- One 2D title at a 60 cap on one device. Tear, pacing under load, and a 3D GL
title are unmeasured. MESA_GLX_FORCE_DIRECT=1is set by the launcher (app-side) so a GLX client does
not fall back to indirect rendering; that change is in the app repo, not here.