egl: Choose GLES3 capable configs when needed

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 <sean.harmer@kdab.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
Laszlo Agocs 2014-03-07 16:05:13 +01:00 committed by The Qt Project
parent a4f421d431
commit 08b9e51c47

View File

@ -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<EGLint> 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;