summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp1
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp16
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h1
3 files changed, 14 insertions, 4 deletions
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
index ccacf5739..8f3ce0936 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
@@ -45,7 +45,6 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
static const char *qwaylandegl_threadedgl_blacklist_vendor[] = {
- "Mesa Project",
0
};
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
index a062a2f98..18ed1d61e 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();
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
index 1c2db8aaf..bc92c9501 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
@@ -85,6 +85,7 @@ private:
QSurfaceFormat m_format;
DecorationsBlitter *m_blitter;
bool mUseNativeDefaultFbo;
+ uint m_api;
friend class DecorationsBlitter;
};