diff options
author | Tony Lindgren <tony@atomide.com> | 2020-12-01 12:54:36 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2020-12-14 15:57:35 +0100 |
commit | 65673b02ef28884da3267fe1be579c20e2cddfa6 (patch) | |
tree | 0727253682d7f3d6f2f8cf86b2ac90a04ce092f4 /hw | |
parent | 5d73a8b59e0d01d1ee4cb484e4b43563cec2eee9 (diff) |
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@redhat.com>.
Fixes: a506b4ec - xwayland: make context current to check GL version
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xwayland/xwayland-glamor-gbm.c | 26 |
1 files changed, 14 insertions, 12 deletions
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, |