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>
This commit is contained in:
Laszlo Agocs 2015-07-29 13:10:06 +02:00
parent 25981d9b7f
commit 4a552d95f6

View File

@ -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);