gl-renderer: try to create a GLES3 context

GL drivers might allow using GLES3 features even in GLES2 contexts, but
that's not always the case. To make sure we can use GLES3, first try to
create a GLES3 context and then fallback to GLES2 on failure.

The reported GL version is used to determine which GLES version is
actually available.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Arnaud Vrac 2018-01-17 19:36:33 +01:00 committed by Daniel Stone
parent 88abc6ab74
commit 439e5fdd5f
1 changed files with 15 additions and 5 deletions

View File

@ -3618,8 +3618,8 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
EGLConfig context_config;
EGLBoolean ret;
static const EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 0,
EGL_NONE
};
@ -3634,12 +3634,22 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
if (gr->has_configless_context)
context_config = EGL_NO_CONFIG_KHR;
/* try to create an OpenGLES 3 context first */
context_attribs[1] = 3;
gr->egl_context = eglCreateContext(gr->egl_display, context_config,
EGL_NO_CONTEXT, context_attribs);
if (gr->egl_context == NULL) {
weston_log("failed to create context\n");
gl_renderer_print_egl_error_state();
return -1;
/* and then fallback to OpenGLES 2 */
context_attribs[1] = 2;
gr->egl_context = eglCreateContext(gr->egl_display,
context_config,
EGL_NO_CONTEXT,
context_attribs);
if (gr->egl_context == NULL) {
weston_log("failed to create context\n");
gl_renderer_print_egl_error_state();
return -1;
}
}
ret = eglMakeCurrent(gr->egl_display, egl_surface,