Details
Description
If context sharing is enabled with
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
and default surface format is set using
QSurfaceFormat format; format.setVersion(3, 2); format.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(format);
and then you set the format of a QQuickWidget / QOpenGLWidget to the global shared context with
QQuickWidget foo; QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext(); foo.setFormat(globalSharedContext->format());
Then the shared OpenGL context for "foo" fails to be created. You get the error message: "QCocoaGLContext: Falling back to unshared context".
This is because the globalSharedContext "advertises" that it is version 4.1, whereas it's actually 3.2.
If you either modify the format of foo to be "3.2" (which would be used by default because of the defaultSurfaceFormat), or use "4.1" everywhere instead, everything works.
My assumption is the following:
Once the global context is created, its format is updated in updateFormatFromContext, which uses glGetString to parse out the version.
That version is always reported as 4.1 for a Core profile, regardless if either 3.2 Core or 4.1 Core is requested.
Internally for macOS though it does seem to make a difference, because sharing between 3.2 global context and 4.1 qquickwidget context is not possible.
Sharing between "3.2 and 3.2", and "4.1 and 4.1" works fine though, regardless of the fact that the advertised version by glGetString is "4.1".
Attachments
For Gerrit Dashboard: QTBUG-63180 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
205505,2 | [macOS] Determine OpenGL version of a context from its pixel format | 5.10 | qt/qtbase | Status: ABANDONED | -1 | 0 |
205549,1 | WIP: Fix QTBUG-63180 | 5.10 | qt/qtbase | Status: ABANDONED | -2 | 0 |
211517,2 | macOS: Fix OpenGL context sharing | 5.10.0 | qt/qtbase | Status: MERGED | +2 | 0 |
307310,5 | Remove workaround for incorrect version of surface format macOS | dev | qt/qtwebengine | Status: MERGED | +2 | 0 |