xwayland: make context current to check GL version
`glGetString(GL_VERSION)` will return NULL without a current context. Commitdabc7d8b
(“xwayland: Fall back to GLES2 if we don't get at least GL 2.1 in glamor”) would check the context is created, but it is made current just after, so the call to `epoxy_gl_version()` would return 0, hence defeating the version check. Make the context current prior to call `epoxy_gl_version()`. Fixes:dabc7d8b
- xwayland: Fall back to GLES2 if we don't get at least GL 2.1 in glamor Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/932 https://gitlab.freedesktop.org/xorg/xserver/merge_requests/324 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
parent
dabc7d8bf2
commit
a506b4ecb6
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue