diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-07-29 13:10:06 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-08-05 18:18:56 +0000 |
commit | 4a552d95f69b1319caacc5d36bcf428b06f32e1c (patch) | |
tree | 5291a0686f61a274f21858182cd13a3c94830376 /src/widgets | |
parent | 25981d9b7f8e92c4fd32193264c1815ade8cd46f (diff) |
Avoid multisampled contexts in QOpenGLWidget
as it is not needed at all. Multisampled FBOs do not need multisampled
configs.
What's more, this fixes crashing Mesa with Intel and EGL, where creating
a pbuffer for a config with multisampling simply crashes. (and due to
other issues we disable surfaceless QOffscreenSurface for Intel so
the pbuffer cannot be avoided)
Task-number: QTBUG-47509
Change-Id: I3ae3fae8513a6dc64ca4ab11c61d4777c6c09cec
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index ea7a761bf1..b98e8a6a66 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -553,7 +553,8 @@ public: hasBeenComposed(false), flushPending(false), paintDevice(0), - updateBehavior(QOpenGLWidget::NoPartialUpdate) + updateBehavior(QOpenGLWidget::NoPartialUpdate), + requestedSamples(0) { requestedFormat = QSurfaceFormat::defaultFormat(); } @@ -595,6 +596,7 @@ public: QOpenGLPaintDevice *paintDevice; QSurfaceFormat requestedFormat; QOpenGLWidget::UpdateBehavior updateBehavior; + int requestedSamples; }; void QOpenGLWidgetPaintDevicePrivate::beginPaint() @@ -686,7 +688,7 @@ void QOpenGLWidgetPrivate::recreateFbo() delete resolvedFbo; resolvedFbo = 0; - int samples = context->format().samples(); + int samples = requestedSamples; QOpenGLExtensions *extfuncs = static_cast<QOpenGLExtensions *>(context->functions()); if (!extfuncs->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) samples = 0; @@ -742,6 +744,13 @@ void QOpenGLWidgetPrivate::initialize() return; } + // Do not include the sample count. Requesting a multisampled context is not necessary + // since we render into an FBO, never to an actual surface. What's more, attempting to + // create a pbuffer with a multisampled config crashes certain implementations. Just + // avoid the entire hassle, the result is the same. + requestedSamples = requestedFormat.samples(); + requestedFormat.setSamples(0); + QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext); ctx->setShareContext(shareContext); ctx->setFormat(requestedFormat); |