Merge lp:~spacedout/qtubuntu/fix_opengl_sharing into lp:qtubuntu

Proposed by David Fries
Status: Work in progress
Proposed branch: lp:~spacedout/qtubuntu/fix_opengl_sharing
Merge into: lp:qtubuntu
Diff against target: 101 lines (+23/-13)
4 files modified
src/platforms/base/context.cc (+18/-4)
src/platforms/base/context.h (+3/-1)
src/platforms/base/integration.cc (+2/-7)
src/platforms/base/integration.h (+0/-1)
To merge this branch: bzr merge lp:~spacedout/qtubuntu/fix_opengl_sharing
Reviewer Review Type Date Requested Status
Gerry Boland (community) Needs Fixing
Loïc Molinari Pending
Francis Ginther why hasn't jenkins reviewed this yet? Pending
PS Jenkins bot continuous-integration Pending
Review via email: mp+163466@code.launchpad.net

Commit message

All of OpenGL, OpenGLES, and Qt5 support sharing a context, but the ubuntu-touch Qt5 abstraction does not, this adds that support, otherwise programs can't offload tasks to another thread to execute.

Description of the change

All of OpenGL, OpenGLES, and Qt5 support sharing a context, but the ubuntu-touch Qt5 abstraction does not, this adds that support, otherwise programs can't offload tasks to another thread to execute.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

Jenkins will not perform a ci build on this until it is reviewed and top approved by a Canonical employee. Your best bet for finding a reviewer is through the #ubuntu-touch IRC channel on freenode.

If this is approved and still fails to be tested by jenkins, please ping me again.

Revision history for this message
Francis Ginther (fginther) wrote :

Oh, one more thing. You'll need to provide a commit message through launchpad as jenkins enforces this as part of this project's workflow. Copy-n-paste of the current Description should be suitable.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

The code looks good. I'll test on the device and approve if everything's fine.

Revision history for this message
David Fries (spacedout) wrote :

On Tue, May 21, 2013 at 05:10:37PM -0000, Loïc Molinari wrote:
> The code looks good. I'll test on the device and approve if everything's fine.

Depending on how you plan to test it I wanted to pass along a tip.

There is a related issue I'll mention that I've only worked around.
The problem is while I could create a new window for the new context,
it would be resized to the full screen, even though show() was never
called. While the hidden window was not visible (the main window
continued to be updated and displayed), all touch events were directed
to the hidden window. My hack was to turn around and deliver them in
my code to the main window object so things would continue to work.

The upcoming Qt 5.1 has an QOffscreenSurface that would be nice to
support directly, but that's independent of this.

--
David Fries <email address hidden> PGP pub CB1EE8F0
http://fries.net/~david/

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

Most of this seems implemented by now:
http://bazaar.launchpad.net/~phablet-team/qtubuntu/trunk/view/head:/src/platforms/base/context.cc

isSharing is not implemented in trunk though, yet these shared contexts are being used by the oxide browser. So not sure that needed either

review: Needs Fixing

Unmerged revisions

132. By David Fries

Enable sharing OpenGL contexts

Sharing OpenGL contexts are required to offload OpenGL tasks to another
thread such as uploading textues or drawing into a framebuffer to use
as a texture.

131. By David Fries

QUbuntuBaseIntegration allocate in const remove typecast

The base QPlatformIntegration doesn't have the non-const version of
createPlatformOpenGLContext and this routine doesn't require it,
so simplifying the code and removing a typecast along the way.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/base/context.cc'
2--- src/platforms/base/context.cc 2013-02-14 16:31:33 +0000
3+++ src/platforms/base/context.cc 2013-05-13 06:45:33 +0000
4@@ -37,7 +37,10 @@
5 }
6 #endif
7
8-QUbuntuBaseContext::QUbuntuBaseContext(QUbuntuBaseScreen* screen) {
9+QUbuntuBaseContext::QUbuntuBaseContext(QUbuntuBaseScreen* screen,
10+ QPlatformOpenGLContext *share) :
11+ sharingContext_(false) {
12+ DLOG("QUbuntuBaseContext::QUbuntuBaseContext (screen=%p, share=%p)", screen, share);
13 DASSERT(screen != NULL);
14 eglDisplay_ = screen->eglDisplay();
15 screen_ = screen;
16@@ -48,10 +51,21 @@
17 attribs.append(2);
18 attribs.append(EGL_NONE);
19 ASSERT(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE);
20- ASSERT((eglContext_ = eglCreateContext(
21- eglDisplay_, screen->eglConfig(), EGL_NO_CONTEXT, attribs.constData())) != EGL_NO_CONTEXT);
22+ EGLContext shareContext = EGL_NO_CONTEXT;
23+ if (share) {
24+ shareContext = static_cast<QUbuntuBaseContext*>(share)->eglContext();
25+ sharingContext_ = true;
26+ }
27
28- DLOG("QUbuntuBaseContext::QUbuntuBaseContext (this=%p, screen=%p)", this, screen);
29+ eglContext_ = eglCreateContext(eglDisplay_, screen->eglConfig(), shareContext, attribs.constData());
30+ if (eglContext_ == EGL_NO_CONTEXT && sharingContext_) {
31+ // re-try without a shared context
32+ sharingContext_ = false;
33+ DLOG("QUbuntuBaseContext::QUbuntuBaseContext sharing context failed");
34+ eglContext_ = eglCreateContext(
35+ eglDisplay_, screen->eglConfig(), EGL_NO_CONTEXT, attribs.constData());
36+ }
37+ ASSERT(eglContext_ != EGL_NO_CONTEXT);
38 }
39
40 QUbuntuBaseContext::~QUbuntuBaseContext() {
41
42=== modified file 'src/platforms/base/context.h'
43--- src/platforms/base/context.h 2013-02-14 16:31:33 +0000
44+++ src/platforms/base/context.h 2013-05-13 06:45:33 +0000
45@@ -21,7 +21,7 @@
46
47 class QUbuntuBaseContext : public QPlatformOpenGLContext {
48 public:
49- QUbuntuBaseContext(QUbuntuBaseScreen* screen);
50+ QUbuntuBaseContext(QUbuntuBaseScreen* screen, QPlatformOpenGLContext *share);
51 ~QUbuntuBaseContext();
52
53 // QPlatformOpenGLContext methods.
54@@ -29,6 +29,7 @@
55 void swapBuffers(QPlatformSurface* surface);
56 bool makeCurrent(QPlatformSurface* surface);
57 void doneCurrent();
58+ bool isSharing() const { return sharingContext_; }
59 bool isValid() const { return eglContext_ != EGL_NO_CONTEXT; }
60 void (*getProcAddress(const QByteArray& procName)) ();
61 EGLContext eglContext() const { return eglContext_; }
62@@ -37,6 +38,7 @@
63 QUbuntuBaseScreen* screen_;
64 EGLContext eglContext_;
65 EGLDisplay eglDisplay_;
66+ bool sharingContext_;
67 };
68
69 #endif //QUBUNTUBASECONTEXT_H
70
71=== modified file 'src/platforms/base/integration.cc'
72--- src/platforms/base/integration.cc 2013-02-14 16:31:33 +0000
73+++ src/platforms/base/integration.cc 2013-05-13 06:45:33 +0000
74@@ -70,13 +70,8 @@
75 QOpenGLContext* context) const {
76 DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext const (this=%p, context=%p)", this,
77 context);
78- return const_cast<QUbuntuBaseIntegration*>(this)->createPlatformOpenGLContext(context);
79-}
80-
81-QPlatformOpenGLContext* QUbuntuBaseIntegration::createPlatformOpenGLContext(
82- QOpenGLContext* context) {
83- DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext (this=%p, context=%p)", this, context);
84- return new QUbuntuBaseContext(static_cast<QUbuntuBaseScreen*>(context->screen()->handle()));
85+ return new QUbuntuBaseContext(static_cast<QUbuntuBaseScreen*>(context->screen()->handle()),
86+ context->shareHandle());
87 }
88
89 QStringList QUbuntuBaseIntegration::themeNames() const {
90
91=== modified file 'src/platforms/base/integration.h'
92--- src/platforms/base/integration.h 2013-02-14 16:31:33 +0000
93+++ src/platforms/base/integration.h 2013-05-13 06:45:33 +0000
94@@ -31,7 +31,6 @@
95 QPlatformNativeInterface* nativeInterface() const { return nativeInterface_; }
96 QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const;
97 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const;
98- QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context);
99 QPlatformFontDatabase* fontDatabase() const { return fontDb_; }
100 QStringList themeNames() const;
101 QPlatformTheme* createPlatformTheme(const QString& name) const;

Subscribers

People subscribed via source and target branches