From 10e03cd7571e905c17092e234a74eed217f1c83d Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Mon, 16 Nov 2026 23:45:08 -0500 Subject: vgsp: eng89s - admit the real CALL(0) 0x3800 draw; GZ_EGL harness The real 570.144 direct-GL draw window (12068 B @ push 0x402f9d8) carries no 0x3910/0x3914 write. Its draw is an op=4 IMMD to method 0x3800 (imm=0xd48=3400) plus CALL slots 44/57/58 (0x3960/0x39c8/0x39d0), and the window has no colour-target bind of its own, so RT-gated admission sent it down the compute-QMD lane. Recognize and admit the real marker: the walker, chunk check and window marker accept 0x3800/0x3960/0x39c8/0x39d0 (0x3910/ 0x3914 kept); the call-0 admission predicate scans the admitted window (a pre-window run header can swallow the window head); the draw chunk is forced first (draw_slice=1, order 0) and the window replayed verbatim. The booter's DRAW_IAB window predicate accepts the op=4 CALL(0) and the secondaries, the census names slot 0 (MME-CALL-ARGS slot=0 data=), and the final emitted window gets MME-EXEC-CALL slot=0 (the physical GR front-end executes the CALL; the kernel has no CALL interpreter, the 0x114 prelude uploads precede the window in the same launch). Guest harness: add tools/guest-diag/gz_es.c and an on-demand build in push_gl_tools.sh; GZ_EGL=1 switches gzdoom_pbuf_run.sh/mission-gz.sh to SDL offscreen + real NVIDIA EGL/GLES (default unchanged); push_gl_tools.sh creates the NVIDIA EGL vendor ICD only when missing. Receipts: c1025 GL-FLUSH admitted=1, DRAW-WRITE m=0x3800 op=4 data=0xd48, 3D mark admitted (CALL(0) 0x3800 draw marker), 3D stream chunked, 3D chunk launch draw=1, MME-CALL-ARGS slot=0 data=0xd48, MME-EXEC-CALL slot=0 op=4 imm=0xd48. Exact 0x402f9d8 post-fix replay still unverified (run wedged on an earlier draw window); stores/px remain open. --- tools/guest-diag/10_nvidia.json | 6 ++ tools/guest-diag/gz_es.c | 106 ++++++++++++++++++++++++++++++++++++ tools/guest-diag/gzdoom_pbuf_run.sh | 24 ++++++-- tools/guest-diag/mission-gz.sh | 22 ++++++-- tools/guest-diag/push_gl_tools.sh | 32 +++++++++++ 5 files changed, 179 insertions(+), 11 deletions(-) create mode 100644 tools/guest-diag/10_nvidia.json create mode 100644 tools/guest-diag/gz_es.c (limited to 'tools') diff --git a/tools/guest-diag/10_nvidia.json b/tools/guest-diag/10_nvidia.json new file mode 100644 index 0000000..2bfcca0 --- /dev/null +++ b/tools/guest-diag/10_nvidia.json @@ -0,0 +1,6 @@ +{ + "file_format_version" : "1.0.0", + "ICD" : { + "library_path" : "libEGL_nvidia.so.0" + } +} diff --git a/tools/guest-diag/gz_es.c b/tools/guest-diag/gz_es.c new file mode 100644 index 0000000..b371e4f --- /dev/null +++ b/tools/guest-diag/gz_es.c @@ -0,0 +1,106 @@ +// gz_es.c - give SDL2's offscreen driver a real NVIDIA EGL/GLES context. +// no X, no GLX, no llvmpipe. build: gcc -shared -fPIC -O2 -o gz_es.so gz_es.c -lEGL -lGLESv2 -ldl +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +static EGLDisplay dpy; +static EGLContext ctx; +static int (*real_make)(void *, void *); + +void *SDL_GL_CreateContext(void *win) +{ + PFNEGLGETPLATFORMDISPLAYEXTPROC gp = + (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress( + "eglGetPlatformDisplayEXT"); + PFNEGLQUERYDEVICESEXTPROC qd = + (PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress( + "eglQueryDevicesEXT"); + EGLint maj, min, nc = 0; + EGLConfig cfg; + EGLint ca[] = { EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_NONE }; + EGLint at[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + void (*load)(const char *) = dlsym(RTLD_NEXT, "SDL_GL_LoadLibrary"); + + if (load) + load(NULL); + if (!gp || !qd) { + fprintf(stderr, "[gzes] no EGL platform ext\n"); + return NULL; + } + { + EGLDeviceEXT devs[8]; + EGLint n = 0; + + if (qd(8, devs, &n) && n > 0) + dpy = gp(EGL_PLATFORM_DEVICE_EXT, devs[0], NULL); + } + if (dpy == EGL_NO_DISPLAY) + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (!eglInitialize(dpy, &maj, &min)) { + fprintf(stderr, "[gzes] eglInitialize 0x%x\n", eglGetError()); + return NULL; + } + if (!eglChooseConfig(dpy, ca, &cfg, 1, &nc) || nc < 1) { + fprintf(stderr, "[gzes] choose 0x%x\n", eglGetError()); + return NULL; + } + ctx = eglCreateContext(dpy, cfg, EGL_NO_CONTEXT, at); + if (ctx == EGL_NO_CONTEXT) { + fprintf(stderr, "[gzes] ctx 0x%x\n", eglGetError()); + return NULL; + } + if (!eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) { + fprintf(stderr, "[gzes] current 0x%x\n", eglGetError()); + return NULL; + } + fprintf(stderr, "[gzes] OK %s | %s ctx=%p\n", + glGetString(GL_RENDERER), glGetString(GL_VERSION), (void *)ctx); + return (void *)ctx; +} + +int SDL_GL_MakeCurrent(void *win, void *c) +{ + if (!real_make) + real_make = dlsym(RTLD_NEXT, "SDL_GL_MakeCurrent"); + if (!dpy || !c) + return real_make ? real_make(win, c) : -1; + return eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, + (EGLContext)c) ? 0 : -1; +} + +void SDL_GL_SwapWindow(void *win) +{ + (void)win; + glFlush(); +} + +void SDL_GL_GetDrawableSize(void *win, int *w, int *h) +{ + (void)win; + if (w) + *w = 640; + if (h) + *h = 480; +} + +void SDL_GL_GetWindowSize(void *win, int *w, int *h) +{ + SDL_GL_GetDrawableSize(win, w, h); +} + +void *SDL_GL_GetCurrentContext(void) +{ + return (void *)ctx; +} + +void SDL_GL_DeleteContext(void *c) +{ + (void)c; +} diff --git a/tools/guest-diag/gzdoom_pbuf_run.sh b/tools/guest-diag/gzdoom_pbuf_run.sh index 49c5c96..6d9e8b7 100755 --- a/tools/guest-diag/gzdoom_pbuf_run.sh +++ b/tools/guest-diag/gzdoom_pbuf_run.sh @@ -16,6 +16,9 @@ # GZ_ARGS extra GZDoom args appended after the base set # GZ_DETACH default 0; set 1 to setsid/nohup the run and return # DISPLAY default :0 +# GZ_EGL default 0; set 1 to use SDL's offscreen driver with a real +# NVIDIA EGL/GLES context via gz_es.so (no X, no GLX; the +# c1020/c1021 real-GL path). The pbuffer shims are not used. # # The base args are windowed GL: +set vid_fullscreen 0, 640x480, OpenGL # backend 0, +vid_rendermode 4 (GL mode), MAP01. The preload order matters: @@ -35,10 +38,21 @@ GZ_ARGS="${GZ_ARGS:-}" GZ_DETACH="${GZ_DETACH:-0}" GZ_RCFILE="${GZ_RCFILE:-/tmp/gz-rc}" DISPLAY="${DISPLAY:-:0}" +GZ_EGL="${GZ_EGL:-0}" SDL_VIDEODRIVER="${SDL_VIDEODRIVER:-offscreen}" -LD_PRELOAD="${LD_PRELOAD:-/tmp/sdl_cap.so /tmp/gz_pbuf.so}" +if [ "$GZ_EGL" = "1" ]; then + SDL_VIDEO_EGL_DRIVER="${SDL_VIDEO_EGL_DRIVER:-/usr/lib/x86_64-linux-gnu/libEGL.so.1}" + LD_PRELOAD="${LD_PRELOAD:-/tmp/gz_es.so}" + GZ_BACKEND="${GZ_BACKEND:-2}" + SHIMS="/tmp/gz_es.so" +else + SDL_VIDEO_EGL_DRIVER="${SDL_VIDEO_EGL_DRIVER:-}" + LD_PRELOAD="${LD_PRELOAD:-/tmp/sdl_cap.so /tmp/gz_pbuf.so}" + GZ_BACKEND="${GZ_BACKEND:-0}" + SHIMS="/tmp/sdl_cap.so /tmp/gz_pbuf.so" +fi -export DISPLAY SDL_VIDEODRIVER LD_PRELOAD GZCAP GZCAP_MAXF GZPBUF_W GZPBUF_H GZ_RCFILE +export DISPLAY SDL_VIDEODRIVER SDL_VIDEO_EGL_DRIVER LD_PRELOAD GZCAP GZCAP_MAXF GZPBUF_W GZPBUF_H GZ_RCFILE GZ_EGL if [ ! -x "$GZDOOM_BIN" ]; then echo "gzdoom_pbuf_run: GZDOOM_BIN not executable: $GZDOOM_BIN" >&2 @@ -48,7 +62,7 @@ if [ ! -f "$WAD" ]; then echo "gzdoom_pbuf_run: WAD not found: $WAD" >&2 exit 2 fi -for so in /tmp/sdl_cap.so /tmp/gz_pbuf.so; do +for so in $SHIMS; do if [ ! -f "$so" ]; then echo "gzdoom_pbuf_run: shim missing: $so" >&2 exit 2 @@ -61,7 +75,7 @@ CMD=( +set vid_fullscreen 0 +set vid_defwidth "$GZPBUF_W" +set vid_defheight "$GZPBUF_H" - +set vid_preferbackend 0 + +set vid_preferbackend "$GZ_BACKEND" +vid_rendermode 4 -nosound -nomusic @@ -76,7 +90,7 @@ if [ -n "$GZ_ARGS" ]; then CMD+=("${GZ_EXTRA[@]}") fi -echo "gzdoom_pbuf_run: DISPLAY=$DISPLAY SDL_VIDEODRIVER=$SDL_VIDEODRIVER" +echo "gzdoom_pbuf_run: DISPLAY=$DISPLAY SDL_VIDEODRIVER=$SDL_VIDEODRIVER GZ_EGL=$GZ_EGL" echo "gzdoom_pbuf_run: LD_PRELOAD=$LD_PRELOAD" echo "gzdoom_pbuf_run: GZCAP=$GZCAP GZCAP_MAXF=$GZCAP_MAXF GZPBUF_W=$GZPBUF_W GZPBUF_H=$GZPBUF_H" echo "gzdoom_pbuf_run: LOG=$GZLOG TIMEOUT=$TIMEOUT DETACH=$GZ_DETACH" diff --git a/tools/guest-diag/mission-gz.sh b/tools/guest-diag/mission-gz.sh index c4665d2..cb27503 100644 --- a/tools/guest-diag/mission-gz.sh +++ b/tools/guest-diag/mission-gz.sh @@ -8,6 +8,8 @@ # # Env knobs: GZ_SECS (default 240) GLF_FRAMES (default 0 = skip probe) # GLF_W/GLF_H GZCAP GZCAP_MAXF GZ_ATTEMPTS (default 2) +# GZ_EGL (default 0; 1 = SDL offscreen + real NVIDIA EGL via +# gz_es.so, no X - the c1020/c1021 real-GL path) # # 2026-11-16 (post-reboot c895-c898): the gl_frames probe is now OFF by default # (GLF_FRAMES=0). It is a diagnostic, not a render source, and in the batch it @@ -20,6 +22,8 @@ export DISPLAY=:0 GZCAP="${GZCAP:-/dev/shm/gzframes.bin}" GZCAP_MAXF="${GZCAP_MAXF:-1800}" GZ_ATTEMPTS="${GZ_ATTEMPTS:-2}" +GZ_EGL="${GZ_EGL:-0}" +export GZ_EGL x_up() { local t r @@ -39,11 +43,17 @@ echo "mission start $(date +%T)" rm -f /tmp/mission-done /tmp/gzframes.bin "$GZCAP" mkdir -p /tmp/gzshots -# 1. X up (the DDX ScreenInit is a per-start lottery) +# 1. X up (the DDX ScreenInit is a per-start lottery). The GZ_EGL path is +# offscreen EGL and does not need X at all. XOK=0 -XTRY=$(x_up) && XOK=1 -echo "XOK try=$XTRY $(date +%T)" -if [ "$XOK" = 0 ]; then echo "X-FAIL" > /tmp/mission-done; exit 1; fi +if [ "$GZ_EGL" = "1" ]; then + XOK=1 + echo "X skipped (GZ_EGL=1 offscreen EGL) $(date +%T)" +else + XTRY=$(x_up) && XOK=1 + echo "XOK try=$XTRY $(date +%T)" + if [ "$XOK" = 0 ]; then echo "X-FAIL" > /tmp/mission-done; exit 1; fi +fi bash /tmp/guest_mode.sh 2>/dev/null || true # 2. Optional GPU GL probe (diagnostic only; off by default) @@ -73,12 +83,12 @@ export GZ_RCFILE=/tmp/gz-rc GZRC=255 attempt=1 while [ "$attempt" -le "$GZ_ATTEMPTS" ]; do - if ! pgrep -x Xorg >/dev/null; then + if [ "$GZ_EGL" != "1" ] && ! pgrep -x Xorg >/dev/null; then echo "X dead before GZDoom attempt $attempt - restarting" >> /tmp/mission-gz.log x_up >/dev/null 2>&1 || { echo "X restart failed" >> /tmp/mission-gz.log; break; } fi rm -f "$GZ_RCFILE" - GZ_DETACH=1 TIMEOUT="$GZ_SECS" GZLOG=/tmp/mission-gz.log GZCAP="$GZCAP" \ + GZ_EGL="$GZ_EGL" GZ_DETACH=1 TIMEOUT="$GZ_SECS" GZLOG=/tmp/mission-gz.log GZCAP="$GZCAP" \ GZCAP_MAXF="$GZCAP_MAXF" \ GZPBUF_W="${GZPBUF_W:-640}" GZPBUF_H="${GZPBUF_H:-480}" \ bash /tmp/gzdoom_pbuf_run.sh diff --git a/tools/guest-diag/push_gl_tools.sh b/tools/guest-diag/push_gl_tools.sh index 986d2d6..4ea5665 100755 --- a/tools/guest-diag/push_gl_tools.sh +++ b/tools/guest-diag/push_gl_tools.sh @@ -25,15 +25,30 @@ if [ "${1:-}" = "--dry-run" ]; then shift fi +# gz_es.so is small and its source is tracked; build it on demand (host gcc, +# same libc family as the guest) so the GZ_EGL=1 path works from a fresh +# checkout. The other shims stay prebuilt in build/. +if [ ! -f "$BUILD/gz_es.so" ] && [ "$DRY_RUN" != "1" ]; then + mkdir -p "$BUILD" + if gcc -shared -fPIC -O2 -o "$BUILD/gz_es.so" "$HERE/gz_es.c" \ + -lEGL -lGLESv2 -ldl; then + echo "BUILD $BUILD/gz_es.so" + else + echo "BUILD-FAIL gz_es.so (EGL/GLESv2 dev headers needed)" >&2 + fi +fi + FIXED=( "$BUILD/gl_frames" "$BUILD/gz_pbuf.so" + "$BUILD/gz_es.so" "$BUILD/sdl_cap.so" "$BUILD/test_tri" "$HERE/guest_mode.sh" "$HERE/gzf2_video.py" "$HERE/gzdoom_pbuf_run.sh" "$HERE/mission-gz.sh" + "$HERE/10_nvidia.json" ) if [ "$#" -gt 0 ]; then @@ -72,4 +87,21 @@ for f in "${FILES[@]}"; do fi push_b64 "$f" "$DEST_DIR/$(basename "$f")" || rc=1 done + +# The EGL offscreen path (GZ_EGL=1) needs the NVIDIA EGL vendor ICD; some +# guest images lack it. Create it only when missing (never overwrite the +# driver's own file). +EGL_JSON=/usr/share/glvnd/egl_vendor.d/10_nvidia.json +if [ "$DRY_RUN" = "1" ]; then + echo "PUSH-DRY $EGL_JSON (if missing)" +elif sudo "$VMEXEC" exec --timeout 30 "test -f $EGL_JSON" >/dev/null 2>&1; then + echo "PUSH-SKIP existing $EGL_JSON" +elif sudo "$VMEXEC" exec --timeout 30 \ + "mkdir -p /usr/share/glvnd/egl_vendor.d && cp '$DEST_DIR/10_nvidia.json' '$EGL_JSON'" \ + >/dev/null 2>&1; then + echo "PUSHED $EGL_JSON" +else + echo "PUSH-FAIL $EGL_JSON" >&2 + rc=1 +fi exit "$rc" -- cgit v1.2.3