summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/gz_es.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-16 23:45:08 -0500
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-16 23:45:08 -0500
commit10e03cd7571e905c17092e234a74eed217f1c83d (patch)
tree4ebe8848dbcfa7332f5b55a643cbd771db1824bf /tools/guest-diag/gz_es.c
parent9386fe4b948e0aba2f3455671a77e18452ddc924 (diff)
downloadopen-iov-10e03cd7571e905c17092e234a74eed217f1c83d.tar.gz
open-iov-10e03cd7571e905c17092e234a74eed217f1c83d.zip
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.
Diffstat (limited to 'tools/guest-diag/gz_es.c')
-rw-r--r--tools/guest-diag/gz_es.c106
1 files changed, 106 insertions, 0 deletions
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 <dlfcn.h>
+#include <stdio.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+
+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;
+}