Merge lp:~albaguirre/qtmir/hook-done-current into lp:qtmir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Gerry Boland
Approved revision: 439
Merged at revision: 460
Proposed branch: lp:~albaguirre/qtmir/hook-done-current
Merge into: lp:qtmir
Diff against target: 54 lines (+9/-2)
2 files modified
src/platforms/mirserver/miropenglcontext.cpp (+7/-2)
src/platforms/mirserver/miropenglcontext.h (+2/-0)
To merge this branch: bzr merge lp:~albaguirre/qtmir/hook-done-current
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Unity8 CI Bot (community) continuous-integration Needs Fixing
Review via email: mp+285248@code.launchpad.net

Commit message

Hook MirOpenGLContext::doneCurrent to Screen::doneCurrent

Actually unbind the opengl/egl context when requested.

Description of the change

When the display configuration changes, the Qt compositor is stopped and ScreenWindows::setExposed(false) is called which eventually makes the renderer thread call MirOpenGLContext::doneCurrent - which does nothing.

After restarting the compositor, new rendering threads are created and eventually MirOpenGLContext::makeCurrent will be called on the new QPlatformSurface/ScreenWindow objects, which will eventually result in an eglMakeCurrent call.

Since doneCurrent does not unbind the context from the previous rendering thread, some drivers (for example mx4) will return EGL_BAD_ACCESS (with good reason, since the context is bound to another thread).

Hook MirOpenGLContext::doneCurrent so that it eventually calls Screen::doneCurrent() to properly unbind the context.

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

I need to convince myself that the window will either live longer than the glcontext, or will set m_currentWindow null correctly.

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Logically, I hope that the window outlives the gl context as if you are tearing down, you probably don't want to tear down a surface/window while there's a context active.

Revision history for this message
Gerry Boland (gerboland) wrote :

Yeah, I think this is ok, for all shell needs it for. Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mirserver/miropenglcontext.cpp'
2--- src/platforms/mirserver/miropenglcontext.cpp 2015-09-14 22:38:20 +0000
3+++ src/platforms/mirserver/miropenglcontext.cpp 2016-02-05 22:58:24 +0000
4@@ -36,8 +36,9 @@
5 // (i.e. individual display output buffers) to use as a common base context.
6
7 MirOpenGLContext::MirOpenGLContext(const QSharedPointer<MirServer> &server, const QSurfaceFormat &format)
8+ : m_currentWindow(nullptr)
9 #ifndef QT_NO_DEBUG
10- : m_logger(new QOpenGLDebugLogger(this))
11+ , m_logger(new QOpenGLDebugLogger(this))
12 #endif
13 {
14 auto display = server->the_display();
15@@ -131,6 +132,7 @@
16 // ultimately calls Mir's DisplayBuffer::make_current()
17 ScreenWindow *screenWindow = static_cast<ScreenWindow*>(surface);
18 if (screenWindow) {
19+ m_currentWindow = screenWindow;
20 screenWindow->makeCurrent();
21
22 #ifndef QT_NO_DEBUG
23@@ -148,7 +150,10 @@
24
25 void MirOpenGLContext::doneCurrent()
26 {
27- // FIXME: create a temporary GL context just to release? Would be better to get existing one.
28+ if (m_currentWindow) {
29+ m_currentWindow->doneCurrent();
30+ m_currentWindow = nullptr;
31+ }
32 }
33
34 QFunctionPointer MirOpenGLContext::getProcAddress(const QByteArray &procName)
35
36=== modified file 'src/platforms/mirserver/miropenglcontext.h'
37--- src/platforms/mirserver/miropenglcontext.h 2015-09-14 22:38:20 +0000
38+++ src/platforms/mirserver/miropenglcontext.h 2016-02-05 22:58:24 +0000
39@@ -25,6 +25,7 @@
40
41
42 class MirServer;
43+class ScreenWindow;
44
45 class MirOpenGLContext : public QObject, public QPlatformOpenGLContext
46 {
47@@ -49,6 +50,7 @@
48
49 private:
50 QSurfaceFormat m_format;
51+ ScreenWindow *m_currentWindow;
52 #ifndef QT_NO_DEBUG
53 QOpenGLDebugLogger *m_logger;
54 #endif

Subscribers

People subscribed via source and target branches