[vlc-devel] [PATCH] egl_x11: blacklist Nvidia

Thomas Guillem thomas at gllm.fr
Tue Dec 5 17:12:05 CET 2017


cf. comment.
---

I know I already proposed this patch but we just encountered a new issue with a
different driver on a different distribution.

As explained in the comment, it's safe to fallback to GLX just after
eglInitialize() (and after closing egl gracefully).

 modules/video_output/opengl/egl.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/opengl/egl.c
index 9162675447..cfe4354335 100644
--- a/modules/video_output/opengl/egl.c
+++ b/modules/video_output/opengl/egl.c
@@ -34,6 +34,7 @@
 #include <vlc_opengl.h>
 #include <vlc_vout_window.h>
 #ifdef USE_PLATFORM_X11
+# include <vlc_modules.h> /* eglx11 hack for nvidia */
 # include <vlc_xlib.h>
 #endif
 #ifdef USE_PLATFORM_WAYLAND
@@ -228,6 +229,13 @@ static void Close (vlc_object_t *obj)
  */
 static int Open (vlc_object_t *obj, const struct gl_api *api)
 {
+#ifdef EGL_EXT_platform_x11
+    /* cf. XXX nvidia comment */
+    if (!obj->obj.force
+     && var_Type(obj->obj.libvlc, "eglx11-nvidia-blacklisted") != 0)
+        return VLC_EGENERIC;
+#endif
+
     vlc_gl_t *gl = (vlc_gl_t *)obj;
     vlc_gl_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
@@ -337,6 +345,37 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
     EGLint major, minor;
     if (eglInitialize(sys->display, &major, &minor) != EGL_TRUE)
         goto error;
+
+#ifdef EGL_EXT_platform_x11
+    if (!obj->obj.force
+     && strcmp("NVIDIA", eglQueryString(sys->display, EGL_VENDOR)) == 0
+     && module_exists("glx"))
+    {
+        /* XXX: Nvidia's EGL implementation is known to be highly unstable
+         * using X11, on different drivers versions (375, 384), and different
+         * distributions.
+         *
+         * With 375 driver on Debian: using the same xcb connection (the same
+         * VLC window) with 2 different EGL contexts in a row (when the video
+         * size changes) could lead to a crash.
+         *
+         * With 384 driver on Ubuntu, glGetString() returns NULL the first time
+         * and crashes the second time (with a different EGL context).
+         *
+         * To work around these known issues and maybe others unidentified
+         * issues, we prefer to favor GLX over EGL_X11 when using a nvidia GPU.
+         *
+         * The EGL_VENDOR can only be known after the eglInitialize() call.
+         * It's not to late to fallback to GLX here since real problems seems
+         * to happen after calling a GL function and after a eglMakeCurrent()
+         * call.
+         */
+        msg_Dbg(gl, "Nvidia GPU: dropping egl_x11 in favor of glx");
+        var_Create(obj->obj.libvlc, "eglx11-nvidia-blacklisted", VLC_VAR_VOID);
+        goto error;
+    }
+#endif
+
     msg_Dbg(obj, "EGL version %s by %s",
             eglQueryString(sys->display, EGL_VERSION),
             eglQueryString(sys->display, EGL_VENDOR));
-- 
2.11.0



More information about the vlc-devel mailing list