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:
committed by
Daniel Stone
parent
88abc6ab74
commit
439e5fdd5f
+15
-5
@@ -3618,8 +3618,8 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
|
|||||||
EGLConfig context_config;
|
EGLConfig context_config;
|
||||||
EGLBoolean ret;
|
EGLBoolean ret;
|
||||||
|
|
||||||
static const EGLint context_attribs[] = {
|
EGLint context_attribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 0,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3634,12 +3634,22 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
|
|||||||
if (gr->has_configless_context)
|
if (gr->has_configless_context)
|
||||||
context_config = EGL_NO_CONFIG_KHR;
|
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,
|
gr->egl_context = eglCreateContext(gr->egl_display, context_config,
|
||||||
EGL_NO_CONTEXT, context_attribs);
|
EGL_NO_CONTEXT, context_attribs);
|
||||||
if (gr->egl_context == NULL) {
|
if (gr->egl_context == NULL) {
|
||||||
weston_log("failed to create context\n");
|
/* and then fallback to OpenGLES 2 */
|
||||||
gl_renderer_print_egl_error_state();
|
context_attribs[1] = 2;
|
||||||
return -1;
|
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,
|
ret = eglMakeCurrent(gr->egl_display, egl_surface,
|
||||||
|
|||||||
Reference in New Issue
Block a user