[vlc-commits] [Git][videolan/vlc][master] glx: bind/restore GLX ctx before/after buffer swap

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Apr 30 06:01:05 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ee01aeaf by Jeffrey Knockel at 2026-04-30T05:44:30+00:00
glx: bind/restore GLX ctx before/after buffer swap

These changes fix an issue in which the GLX video output renders only
black with some drivers, such as with a software renderer (e.g.,
LIBGL_ALWAYS_SOFTWARE=true and GALLIUM_DRIVER=llvmpipe).

fix regression from 9b7514f9

- - - - -


1 changed file:

- modules/video_output/glx.c


Changes:

=====================================
modules/video_output/glx.c
=====================================
@@ -94,7 +94,20 @@ static void SwapBuffers (vlc_gl_t *gl)
 {
     vlc_gl_sys_t *sys = gl->sys;
 
-    glXSwapBuffers (sys->display, sys->win);
+    Display *previous_display = glXGetCurrentDisplay();
+    GLXContext previous_context = glXGetCurrentContext();
+    if (previous_display != sys->display || previous_context != sys->ctx) {
+        GLXWindow s_read = glXGetCurrentReadDrawable();
+        GLXWindow s_draw = glXGetCurrentDrawable();
+        glXMakeContextCurrent(sys->display, sys->win, sys->win, sys->ctx);
+        glXSwapBuffers (sys->display, sys->win);
+        if (previous_display)
+            glXMakeContextCurrent(previous_display, s_draw, s_read, previous_context);
+        else
+            glXMakeContextCurrent(sys->display, None, None, NULL);
+    }
+    else
+        glXSwapBuffers (sys->display, sys->win);
 }
 
 static void *GetSymbol(vlc_gl_t *gl, const char *procname)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ee01aeaf8dae4dd2b9ef08b8af76dbe4b9cfe012

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ee01aeaf8dae4dd2b9ef08b8af76dbe4b9cfe012
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list