From 08b9e51c47ecdf6c687b3aed8bee7d7711219d25 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 7 Mar 2014 16:05:13 +0100 Subject: egl: Choose GLES3 capable configs when needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing OpenGLES and majorVersion 3 in a QSurfaceFormat selects GLES3 in case it is supported. This works fine already now, but is not safe since the config choosing logic does not request a GLES3-capable configuration and so it may end up with a non-GLES3 compatible one. This is now corrected by passing the EGL_OPENGL_ES3_BIT_KHR bit when EGL_KHR_create_context is available. Change-Id: Iacee1e1819b944c0f7c1062666106abddf59272b Reviewed-by: Sean Harmer Reviewed-by: Jørgen Lind --- src/platformsupport/eglconvenience/qeglconvenience.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index 790467150f..7cf1f88b02 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -50,6 +50,10 @@ #include "qeglconvenience_p.h" +#ifndef EGL_OPENGL_ES3_BIT_KHR +#define EGL_OPENGL_ES3_BIT_KHR 0x0040 +#endif + QT_BEGIN_NAMESPACE QVector q_createConfigAttributesFromFormat(const QSurfaceFormat &format) @@ -239,6 +243,7 @@ EGLConfig QEglConfigChooser::chooseConfig() configureAttributes.append(surfaceType()); configureAttributes.append(EGL_RENDERABLE_TYPE); + bool needsES2Plus = false; switch (m_format.renderableType()) { case QSurfaceFormat::OpenVG: configureAttributes.append(EGL_OPENVG_BIT); @@ -250,7 +255,7 @@ EGLConfig QEglConfigChooser::chooseConfig() configureAttributes.append(EGL_OPENGL_BIT); else #endif // QT_NO_OPENGL - configureAttributes.append(EGL_OPENGL_ES2_BIT); + needsES2Plus = true; break; case QSurfaceFormat::OpenGL: configureAttributes.append(EGL_OPENGL_BIT); @@ -263,9 +268,15 @@ EGLConfig QEglConfigChooser::chooseConfig() } // fall through default: - configureAttributes.append(EGL_OPENGL_ES2_BIT); + needsES2Plus = true; break; } + if (needsES2Plus) { + if (m_format.majorVersion() >= 3 && q_hasEglExtension(display(), "EGL_KHR_create_context")) + configureAttributes.append(EGL_OPENGL_ES3_BIT_KHR); + else + configureAttributes.append(EGL_OPENGL_ES2_BIT); + } configureAttributes.append(EGL_NONE); EGLConfig cfg = 0; -- cgit v1.2.3