summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
diff options
context:
space:
mode:
authorGiulio Camuffo <giulio.camuffo@jollamobile.com>2015-05-13 23:04:18 +0300
committerGiulio Camuffo <giulio.camuffo@jollamobile.com>2015-05-14 16:40:41 +0000
commit007d73ef9e64a99e560cc932f519f8cb00121ba8 (patch)
treef917ec20817545a9ae2d3125b6db598b9f180892 /src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
parent77a7900aaa790f7bb5e0105f38dbd539f04e219f (diff)
Fix threaded OpenGL rendering on Mesa and possibly other EGLs
eglBindAPI's docs says "defines the current rendering API for EGL in the thread it is called from". We were instead just calling it in the thread the context was created in, not in the thread used for rendering. Change-Id: Iba8ffe75a6f4f8b9d1bba59c0e7cce34499e9c48 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp')
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
index a062a2f9..18ed1d61 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
@@ -260,21 +260,22 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis
switch (m_format.renderableType()) {
case QSurfaceFormat::OpenVG:
- eglBindAPI(EGL_OPENVG_API);
+ m_api = EGL_OPENVG_API;
break;
#ifdef EGL_VERSION_1_4
# if !defined(QT_OPENGL_ES_2)
case QSurfaceFormat::DefaultRenderableType:
# endif
case QSurfaceFormat::OpenGL:
- eglBindAPI(EGL_OPENGL_API);
+ m_api = EGL_OPENGL_API;
break;
#endif
case QSurfaceFormat::OpenGLES:
default:
- eglBindAPI(EGL_OPENGL_ES_API);
+ m_api = EGL_OPENGL_ES_API;
break;
}
+ eglBindAPI(m_api);
m_context = eglCreateContext(m_eglDisplay, m_config, m_shareEGLContext, eglContextAttrs.constData());
@@ -358,6 +359,15 @@ QWaylandGLContext::~QWaylandGLContext()
bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
{
+ // in QWaylandGLContext() we called eglBindAPI with the correct value. However,
+ // eglBindAPI's documentation says:
+ // "eglBindAPI defines the current rendering API for EGL in the thread it is called from"
+ // Since makeCurrent() can be called from a different thread than the one we created the
+ // context in make sure to call eglBindAPI in the correct thread.
+ if (eglQueryAPI() != m_api) {
+ eglBindAPI(m_api);
+ }
+
QWaylandEglWindow *window = static_cast<QWaylandEglWindow *>(surface);
EGLSurface eglSurface = window->eglSurface();