Exercise the release Mesa and Xvfb GLX graphics paths
@@ -46,3 +46,5 @@ The cold AArch64 LLVM build SDK installed eight signed packages, including GCC's
4646Keep the completed LLVM runtime build tree until its development archive is packaged. Install the signed runtime in the development SDK and set `VINIX_LLVM_BUILD` to the runtime's CMake build directory inside the same worker environment. The recipe compares the built shared object to the installed runtime and asks Ninja for the headers and `llvm-config` using the existing objects. With the variable unset, the source recipe builds those targets independently. Both recipe fixtures reused a configured tree, packaged headers and a versioned `llvm-config`, and rejected a different runtime file. See `xorg/llvm/reuse-dev-fixture-02`, receipt SHA-256 `8123239e3d4ac7ed770df0f1be8d03bf9e214029e22596438a5b3f105033e9b6`. The release builds and LLVM guest checks are separate gates.
4747
4848The Mesa 24.2.8 recipe compiles Gallium once and uses one Meson installation to produce `mesa` and `mesa-gallium-sdk`. EGL, GLES and GBM stay in the runtime archive. The SDK archive carries OSMesa and XA for builds that request them. Both architecture plans resolve the split outputs to the same recipe, and the install fixture confirmed that the two outputs own disjoint paths. See `foundation/release-split-plan-01`, receipt SHA-256 `124659b0ae78559071f072e3845c4c5903da1b2f9a0b523931e422b21ac3b585`. The real Mesa binaries still need the LLVM dependencies and their guest graphics checks.
49+
50+For those checks, install `vinix-release-x11` and `busybox-init` from the signed feed into a clean root and audit it. Build `egl.v` and `glx.v` against that SDK and place the executables at `/vinix-egl-check` and `/vinix-glx-check` in a disposable guest root. Boot `graphics.sh` using `tests/disk-root.py`. The fixture reads back the expected pixel from current Mesa's surfaceless EGL and again from an authenticated indirect GLX connection to `Xvfb-glx` using the legacy DRI directory.
@@ -0,0 +1,79 @@
1+// Exercise the current Gallium runtime without an X server or hardware GPU.
2+module main
3+
4+#include <EGL/egl.h>
5+#include <EGL/eglext.h>
6+#include <GLES2/gl2.h>
7+#flag -lEGL
8+#flag -lGLESv2
9+
10+fn C.eglGetPlatformDisplay(u32, voidptr, voidptr) voidptr
11+fn C.eglInitialize(voidptr, &int, &int) u32
12+fn C.eglBindAPI(u32) u32
13+fn C.eglChooseConfig(voidptr, &int, &voidptr, int, &int) u32
14+fn C.eglCreatePbufferSurface(voidptr, voidptr, &int) voidptr
15+fn C.eglCreateContext(voidptr, voidptr, voidptr, &int) voidptr
16+fn C.eglMakeCurrent(voidptr, voidptr, voidptr, voidptr) u32
17+fn C.eglDestroyContext(voidptr, voidptr) u32
18+fn C.eglDestroySurface(voidptr, voidptr) u32
19+fn C.eglTerminate(voidptr) u32
20+fn C.eglGetError() int
21+fn C.glClearColor(f32, f32, f32, f32)
22+fn C.glClear(u32)
23+fn C.glReadPixels(int, int, int, int, u32, u32, voidptr)
24+fn C.glGetError() u32
25+fn C.glGetString(u32) &u8
26+
27+fn render() ! {
28+ display := C.eglGetPlatformDisplay(C.EGL_PLATFORM_SURFACELESS_MESA, unsafe { nil }, unsafe { nil })
29+ mut major := 0
30+ mut minor := 0
31+ if isnil(display) || C.eglInitialize(display, &major, &minor) == 0 {
32+ return error('surfaceless EGL initialization failed: 0x${C.eglGetError():x}')
33+ }
34+ defer { C.eglTerminate(display) }
35+ mut config := voidptr(0)
36+ mut count := 0
37+ config_attributes := [int(C.EGL_SURFACE_TYPE), C.EGL_PBUFFER_BIT, C.EGL_RENDERABLE_TYPE,
38+ C.EGL_OPENGL_ES2_BIT, C.EGL_RED_SIZE, 8, C.EGL_GREEN_SIZE, 8, C.EGL_BLUE_SIZE, 8,
39+ C.EGL_ALPHA_SIZE, 8, C.EGL_NONE]!
40+ if C.eglBindAPI(C.EGL_OPENGL_ES_API) == 0
41+ || C.eglChooseConfig(display, &config_attributes[0], &config, 1, &count) == 0 || count != 1 {
42+ return error('could not choose an RGBA GLES2 pbuffer configuration: 0x${C.eglGetError():x}')
43+ }
44+ size := [int(C.EGL_WIDTH), 1, C.EGL_HEIGHT, 1, C.EGL_NONE]!
45+ surface := C.eglCreatePbufferSurface(display, config, &size[0])
46+ if isnil(surface) {
47+ return error('could not create an EGL pbuffer: 0x${C.eglGetError():x}')
48+ }
49+ defer { C.eglDestroySurface(display, surface) }
50+ attributes := [int(C.EGL_CONTEXT_CLIENT_VERSION), 2, C.EGL_NONE]!
51+ context := C.eglCreateContext(display, config, unsafe { nil }, &attributes[0])
52+ if isnil(context) {
53+ return error('could not create a GLES2 context: 0x${C.eglGetError():x}')
54+ }
55+ defer { C.eglDestroyContext(display, context) }
56+ if C.eglMakeCurrent(display, surface, surface, context) == 0 {
57+ return error('could not bind the GLES2 context: 0x${C.eglGetError():x}')
58+ }
59+ defer { C.eglMakeCurrent(display, unsafe { nil }, unsafe { nil }, unsafe { nil }) }
60+ renderer := C.glGetString(C.GL_RENDERER)
61+ if isnil(renderer) {
62+ return error('missing OpenGL renderer name')
63+ }
64+ C.glClearColor(0, 1, 0, 1)
65+ C.glClear(C.GL_COLOR_BUFFER_BIT)
66+ mut pixel := [4]u8{}
67+ C.glReadPixels(0, 0, 1, 1, C.GL_RGBA, C.GL_UNSIGNED_BYTE, &pixel[0])
68+ if C.glGetError() != C.GL_NO_ERROR || pixel != [u8(0), 255, 0, 255]! {
69+ return error('GLES2 readback did not match the clear color: ${pixel}')
70+ }
71+ println('EGL ${major}.${minor}, renderer ${unsafe { tos_clone(renderer) }}, RGBA ${pixel}.')
72+}
73+
74+fn main() {
75+ render() or {
76+ eprintln(err)
77+ exit(1)
78+ }
79+}
@@ -0,0 +1,64 @@
1+// Test the legacy GLX server and client together in the Vinix guest.
2+module main
3+
4+#include <X11/Xlib.h>
5+#include <X11/Xutil.h>
6+#include <GL/glx.h>
7+#flag -lGL
8+#flag -lX11
9+
10+@[typedef]
11+struct C.XVisualInfo {
12+ depth int
13+}
14+
15+fn C.XOpenDisplay(&char) voidptr
16+fn C.XDefaultScreen(voidptr) int
17+fn C.XRootWindow(voidptr, int) u64
18+fn C.XCreatePixmap(voidptr, u64, u32, u32, u32) u64
19+fn C.XFreePixmap(voidptr, u64) int
20+fn C.XFree(voidptr) int
21+fn C.XCloseDisplay(voidptr) int
22+fn C.glXChooseVisual(voidptr, int, &int) &C.XVisualInfo
23+fn C.glXCreateGLXPixmap(voidptr, &C.XVisualInfo, u64) u64
24+fn C.glXDestroyGLXPixmap(voidptr, u64)
25+fn C.glXCreateContext(voidptr, &C.XVisualInfo, voidptr, int) voidptr
26+fn C.glXMakeCurrent(voidptr, u64, voidptr) int
27+fn C.glXIsDirect(voidptr, voidptr) int
28+fn C.glXDestroyContext(voidptr, voidptr)
29+fn C.glClearColor(f32, f32, f32, f32)
30+fn C.glClear(u32)
31+fn C.glReadBuffer(u32)
32+fn C.glReadPixels(int, int, int, int, u32, u32, voidptr)
33+fn C.glGetError() u32
34+
35+fn main() {
36+ display := C.XOpenDisplay(unsafe { nil })
37+ assert display != unsafe { nil }
38+ defer { C.XCloseDisplay(display) }
39+ screen := C.XDefaultScreen(display)
40+ mut attributes := [int(C.GLX_RGBA), C.GLX_RED_SIZE, 8, C.GLX_GREEN_SIZE, 8, C.GLX_BLUE_SIZE, 8, 0]!
41+ visual := C.glXChooseVisual(display, screen, &attributes[0])
42+ assert visual != unsafe { nil }
43+ defer { C.XFree(visual) }
44+ pixmap := C.XCreatePixmap(display, C.XRootWindow(display, screen), 1, 1, u32(visual.depth))
45+ assert pixmap != 0
46+ defer { C.XFreePixmap(display, pixmap) }
47+ drawable := C.glXCreateGLXPixmap(display, visual, pixmap)
48+ assert drawable != 0
49+ defer { C.glXDestroyGLXPixmap(display, drawable) }
50+ context := C.glXCreateContext(display, visual, unsafe { nil }, C.False)
51+ assert context != unsafe { nil }
52+ defer { C.glXDestroyContext(display, context) }
53+ assert C.glXIsDirect(display, context) == C.False
54+ assert C.glXMakeCurrent(display, drawable, context) != C.False
55+ defer { C.glXMakeCurrent(display, 0, unsafe { nil }) }
56+ C.glClearColor(0, 1, 0, 1)
57+ C.glClear(C.GL_COLOR_BUFFER_BIT)
58+ C.glReadBuffer(C.GL_FRONT)
59+ mut pixel := [4]u8{}
60+ C.glReadPixels(0, 0, 1, 1, C.GL_RGBA, C.GL_UNSIGNED_BYTE, &pixel[0])
61+ assert C.glGetError() == C.GL_NO_ERROR
62+ assert pixel[0] == 0 && pixel[1] == 255 && pixel[2] == 0
63+ println('Indirect GLX rendered a green pixel in Xvfb.')
64+}
@@ -0,0 +1,38 @@
1+#!/bin/sh
2+set -eu
3+export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp
4+export DISPLAY=:71 XAUTHORITY=/tmp/vinix-glx.Xauthority LIBGL_ALWAYS_SOFTWARE=1
5+server=
6+phase=egl
7+finish() {
8+ status=$?
9+ if [ "$status" -ne 0 ]; then
10+ echo "Vinix graphics fixture failed at $phase"
11+ if [ -f /tmp/xvfb-glx.log ]; then cat /tmp/xvfb-glx.log; fi
12+ fi
13+ if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi
14+ /sbin/poweroff -f
15+}
16+trap finish EXIT
17+
18+test "$(uname -o)" = Vinix
19+LIBGL_DRIVERS_PATH=/usr/lib/mesa24/dri /vinix-egl-check
20+
21+phase=glx-server
22+export LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri
23+mkdir -p /tmp
24+xauth -q -f "$XAUTHORITY" add "$DISPLAY" MIT-MAGIC-COOKIE-1 0123456789abcdef0123456789abcdef
25+Xvfb-glx "$DISPLAY" -auth "$XAUTHORITY" -nolisten tcp -noreset -screen 0 128x128x24 \
26+ +extension GLX +iglx >/tmp/xvfb-glx.log 2>&1 &
27+server=$!
28+attempt=0
29+until xset q >/tmp/xset-glx.log 2>&1; do
30+ kill -0 "$server"
31+ attempt=$((attempt + 1))
32+ [ "$attempt" -lt 30 ]
33+ sleep 1
34+done
35+
36+phase=glx-client
37+LIBGL_ALWAYS_INDIRECT=1 /vinix-glx-check
38+echo 'VPAC FIXTURE GUEST PASS'