[vlc-commits] [Git][videolan/vlc][master] egl: negotiate reference counting (fixes #25531)

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sun Oct 17 18:13:03 UTC 2021



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
64f2e3b4 by Rémi Denis-Courmont at 2021-10-17T17:59:02+00:00
egl: negotiate reference counting (fixes #25531)

According to the specification, EGL displays are not reference-counted
by default. As such, `eglTerminate()` will terminate a display even if
there are other users for it in the same process.

This becomes a fatal problem if platform display is shared by multiple
components, and the EGL display parameters are identical or deemed
compatible by the EGL driver. Typically, this will occur with the
window provider and the display.

To fix this, the Khronos group defined an EGL extension to negotiate
reference counting explicitly.

* On Android, this patch makes no differences as the EGL enables
  reference counting by default, regardless of the baseline
  specifications.
* On X11, this patch makes no differences because the module will
  create its own private Xlib `Display` as the platform display,
  such that the EGL display is not shareable.
* This patch matters on Wayland where the `wl_display` pointer must be
  shared between the window provider and display. Without this patch,
  Either the window provider or the display cannot use EGL.
* On Windows, the situation ought to be similar to Wayland, though this
  is much less of an issue, as EGL is not typically used.

This patch does **not** require reference counting if not available as
this would needlessly break on Android and X11, as well as with the
non-embedded XDG-shell window provider on Wayland.

- - - - -


1 changed file:

- modules/video_output/opengl/egl.c


Changes:

=====================================
modules/video_output/opengl/egl.c
=====================================
@@ -224,6 +224,16 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
     EGLSurface (*createSurface)(EGLDisplay, EGLConfig, void *, const EGLint *)
         = CreateWindowSurface;
     void *window;
+    EGLAttrib refs_name = EGL_NONE;
+    EGLAttrib refs_value = EGL_FALSE;
+
+#ifdef EGL_KHR_display_reference
+    if (CheckClientExt("EGL_KHR_display_reference"))
+    {
+        refs_name = EGL_TRACK_REFERENCES_KHR;
+        refs_value = EGL_TRUE;
+    }
+#endif
 
 #ifdef USE_PLATFORM_X11
     sys->x11 = NULL;
@@ -340,6 +350,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
         EGL_GREEN_SIZE, 5,
         EGL_BLUE_SIZE, 5,
         EGL_RENDERABLE_TYPE, api->render_bit,
+        refs_name, refs_value,
         EGL_NONE
     };
     EGLConfig cfgv[1];



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

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




More information about the vlc-commits mailing list