diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 2df12aeaa..bfcf81dbc 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -948,33 +948,49 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen) xwl_screen->egl_display, NULL, EGL_NO_CONTEXT, NULL); } - /* glamor needs either big-GL 2.1 or GLES2 */ - if (xwl_screen->egl_context && epoxy_gl_version() < 21) { - const EGLint gles_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, - 2, - EGL_NONE, - }; - - eglDestroyContext(xwl_screen->egl_display, xwl_screen->egl_context); - eglBindAPI(EGL_OPENGL_ES_API); - xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display, - NULL, EGL_NO_CONTEXT, - gles_attribs); - } - if (xwl_screen->egl_context == EGL_NO_CONTEXT) { - ErrorF("Failed to create EGL context\n"); + ErrorF("Failed to create EGL context with GL\n"); goto error; } if (!eglMakeCurrent(xwl_screen->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, xwl_screen->egl_context)) { - ErrorF("Failed to make EGL context current\n"); + 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) { + 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); + + eglBindAPI(EGL_OPENGL_ES_API); + xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display, + NULL, EGL_NO_CONTEXT, + gles_attribs); + + if (xwl_screen->egl_context == EGL_NO_CONTEXT) { + ErrorF("Failed to create EGL context with GLES2\n"); + goto error; + } + + if (!eglMakeCurrent(xwl_screen->egl_display, + EGL_NO_SURFACE, EGL_NO_SURFACE, + xwl_screen->egl_context)) { + ErrorF("Failed to make EGL context current with GLES2\n"); + goto error; + } + } + renderer = glGetString(GL_RENDERER); if (!renderer) { ErrorF("glGetString() returned NULL, your GL is broken\n");