xserver: Branch 'master'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 15 13:54:52 UTC 2020


 hw/xwayland/xwayland-glamor-gbm.c |   26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

New commits:
commit 65673b02ef28884da3267fe1be579c20e2cddfa6
Author: Tony Lindgren <tony at atomide.com>
Date:   Tue Dec 1 12:54:36 2020 +0200

    xwayland: fix GL version check for GLES only devices
    
    We currently bail out early for GLES only devices, and call
    epoxy_gl_version() too early for GLES only that will make GLES only
    devices return NULL for glGetString(GL_RENDERER).
    
    Let's also add a check to see if we need to recreate the context to
    avoid pointless warnings for GLES only devices as suggested by
    Olivier Fourdan <ofourdan at redhat.com>.
    
    Fixes: a506b4ec - xwayland: make context current to check GL version
    Signed-off-by: Tony Lindgren <tony at atomide.com>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 802e0f65d..f5718b80b 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -973,30 +973,32 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
             xwl_screen->egl_display, NULL, EGL_NO_CONTEXT, NULL);
     }
 
-    if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
-        ErrorF("Failed to create EGL context with GL\n");
-        goto error;
-    }
-
-    if (!eglMakeCurrent(xwl_screen->egl_display,
+    if (xwl_screen->egl_context != EGL_NO_CONTEXT &&
+        !eglMakeCurrent(xwl_screen->egl_display,
                         EGL_NO_SURFACE, EGL_NO_SURFACE,
                         xwl_screen->egl_context)) {
         ErrorF("Failed to make EGL context current with GL\n");
         goto error;
     }
 
-    /* glamor needs either big-GL 2.1 or GLES2 */
-    if (epoxy_gl_version() < 21) {
+    /* glamor needs either big-GL 2.1 or GLES2. Note that we can't rely only
+     * on calling epoxy_gl_version() here if eglBindAPI(EGL_OPENGL_API) above
+     * failed. Calling epoxy_gl_version() here makes GLES only devices fail
+     * below
+     */
+    if (xwl_screen->egl_context == EGL_NO_CONTEXT || epoxy_gl_version() < 21) {
         const EGLint gles_attribs[] = {
             EGL_CONTEXT_CLIENT_VERSION,
             2,
             EGL_NONE,
         };
 
-        /* Recreate the context with GLES2 instead */
-        eglMakeCurrent(xwl_screen->egl_display,EGL_NO_SURFACE,
-                       EGL_NO_SURFACE, EGL_NO_CONTEXT);
-        eglDestroyContext(xwl_screen->egl_display, xwl_screen->egl_context);
+        if (xwl_screen->egl_context != EGL_NO_CONTEXT) {
+            /* Recreate the context with GLES2 instead */
+            eglMakeCurrent(xwl_screen->egl_display,EGL_NO_SURFACE,
+                           EGL_NO_SURFACE, EGL_NO_CONTEXT);
+            eglDestroyContext(xwl_screen->egl_display, xwl_screen->egl_context);
+        }
 
         eglBindAPI(EGL_OPENGL_ES_API);
         xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,


More information about the xorg-commit mailing list