This is an automated email from the git hooks/post-receive script.

git pushed a commit to reference refs/pull/147/head
in repository efl.

View the commit online.

commit 64938038248139f98c19c208948c0de2682505d3
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 29 18:31:09 2026 -0600

    evas:gl_x11: ask for the EGLDisplay once and keep it
    
    eng_best_visual_get() gets an EGLDisplay and initialises it, then
    eng_window_new() gets the same one and initialises it again. EGL hands
    back the same EGLDisplay for the same native display either way, so
    remembering it changes nothing about what we use.
    
    It changes what we ask for. With libglvnd 1.7 in the way, asking again
    for a display that has already been initialised drops the
    EGL_DEVICE_EXT attribute on it: eglQueryDisplayAttribEXT keeps returning
    EGL_TRUE but writes a NULL device from then on, and it stays that way
    for the rest of the process. Reduced outside EFL: one
    eglGetPlatformDisplay plus any number of eglInitialize calls keeps the
    device, a second eglGetPlatformDisplay after the first eglInitialize
    loses it.
    
    That was enough to make evasglQueryDrmDevice() unable to name the GPU it
    renders on - it returned EINA_FALSE on a perfectly ordinary Panfrost
    setup, which would have left a compositor stuck on dmabuf version 3 with
    no way to tell a driver limitation from this.
    
    An entry is dropped where the display is terminated, as the X11 display
    can be closed next and a new one opened at the same address, which must
    not be handed the old EGLDisplay. The entries are plain allocations: the
    module stays loaded across eina_shutdown() and the next eina_init(), and
    an Eina_List kept in it would be walked after its nodes were freed. The
    Evas GL tests, which open and free a gl_x11 canvas each, crash on the
    second one that way.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/modules/evas/engines/gl_x11/evas_x_main.c | 64 +++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 4 deletions(-)

diff --git a/src/modules/evas/engines/gl_x11/evas_x_main.c b/src/modules/evas/engines/gl_x11/evas_x_main.c
index 06e05f8e4d..54e8d52db4 100644
--- a/src/modules/evas/engines/gl_x11/evas_x_main.c
+++ b/src/modules/evas/engines/gl_x11/evas_x_main.c
@@ -185,22 +185,77 @@ _visuals_hash_index_get_from_info(Evas_Engine_Info_GL_X11 *info)
 
 #ifdef GL_GLES
 
+/* One EGLDisplay per X11 display, remembered until it is terminated.
+ *
+ * EGL says asking twice for the same native display hands back the same
+ * EGLDisplay, so caching changes nothing about what we return. It changes what
+ * we ask for: with libglvnd 1.7 in the way, asking again for a display that is
+ * already initialised loses the EGL_DEVICE_EXT attribute on it - the query
+ * still reports success but hands back a NULL device from then on. We ask
+ * twice as a matter of course, once from eng_best_visual_get() and once per
+ * window from eng_window_new(), which was enough to make
+ * evasglQueryDrmDevice() unable to name the GPU it renders on.
+ *
+ * The nodes are plain allocations, not an Eina_List: this module outlives
+ * eina_shutdown() and the next eina_init(), and so does this list. */
+typedef struct _X11_Egl_Display X11_Egl_Display;
+struct _X11_Egl_Display
+{
+   X11_Egl_Display *next;
+   Display         *x11_display;
+   EGLDisplay       egldisp;
+};
+
+static X11_Egl_Display *_x11_egl_displays = NULL;
+
 static EGLDisplay *
 _x11_eglGetDisplay(Display *x11_display)
 {
    EGLDisplay (*eglsym_eglGetPlatformDisplay)
          (EGLenum platform, void *native_display, const EGLAttrib *attrib_list) = NULL;
    EGLDisplay *egldisp = EGL_NO_DISPLAY;
+   X11_Egl_Display *xed;
+
+   for (xed = _x11_egl_displays; xed; xed = xed->next)
+     if (xed->x11_display == x11_display) return xed->egldisp;
 
    eglsym_eglGetPlatformDisplay = dlsym(RTLD_DEFAULT, "eglGetPlatformDisplay");
    if (eglsym_eglGetPlatformDisplay)
+     egldisp = eglsym_eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
+                                            (EGLNativeDisplayType) x11_display, NULL);
+   if (!egldisp)
+     egldisp = eglGetDisplay((EGLNativeDisplayType) x11_display);
+   if (!egldisp) return EGL_NO_DISPLAY;
+
+   xed = calloc(1, sizeof(*xed));
+   if (xed)
      {
-        egldisp = eglsym_eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
-                                               (EGLNativeDisplayType) x11_display, NULL);
-        if (egldisp) return egldisp;
+        xed->x11_display = x11_display;
+        xed->egldisp = egldisp;
+        xed->next = _x11_egl_displays;
+        _x11_egl_displays = xed;
      }
 
-   return eglGetDisplay((EGLNativeDisplayType) x11_display);
+   return egldisp;
+}
+
+/* Called before eglTerminate(): the X11 display may be closed next, and a new
+ * one opened at the same address must get an EGLDisplay of its own. */
+static void
+_x11_eglDisplayForget(EGLDisplay egldisp)
+{
+   X11_Egl_Display **pxed = &_x11_egl_displays;
+   X11_Egl_Display *xed;
+
+   while ((xed = *pxed))
+     {
+        if (xed->egldisp == egldisp)
+          {
+             *pxed = xed->next;
+             free(xed);
+          }
+        else pxed = &xed->next;
+     }
 }
 
 #endif
@@ -672,6 +727,7 @@ eng_window_free(Outbuf *gw)
         if (context) eglDestroyContext(gw->egl_disp, context);
         eina_hash_free(_evas_gl_visuals);
         _evas_gl_visuals = NULL;
+        _x11_eglDisplayForget(gw->egl_disp);
         eglTerminate(gw->egl_disp);
         eglReleaseThread();
         _tls_context_set(EGL_NO_CONTEXT);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to