Ensure QOpenGLWidget FBO is always initialized
QOpenGLWidget uses an FBO internally, that is glCleared whenever recreated. But for the clear to be visible across shared contexts we must also issue a glFlush. QOpenGLWidget defers this flush until the compositing step, in QOpenGLWidgetPrivate::beginCompose(), based on a flushPending variable. This variable is set either after invoking the user's paintGL() function, or when opening a QPainter on the QOpenGLWidget, via QOpenGLWidgetPaintDevice::ensureActiveTarget(). Unfortunately, if QOpenGLWidget::paintEvent() is overridden or intercepted (meaning we will not end up calling paintGL()), but the overridden paint event does not open a QPainter, we end up never setting flushPending to true, and end up composing an uninitialized FBO. This can lead to rendering issues, or even kernel panics with some unfortunate GL drivers. The fix is to ensure the glClear is always flushed before composing, by forcing a pending flush whenever the FBO is recreated. Fixes: QTBUG-70921 Change-Id: I72b596c09dcf54bd0f37668062daaad2d6f7f4bd Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
71bd06d516
commit
7f6497e623
@ -756,6 +756,7 @@ void QOpenGLWidgetPrivate::recreateFbo()
|
||||
|
||||
fbo->bind();
|
||||
context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
flushPending = true; // Make sure the FBO is initialized before use
|
||||
|
||||
paintDevice->setSize(deviceSize);
|
||||
paintDevice->setDevicePixelRatio(q->devicePixelRatioF());
|
||||
|
Loading…
x
Reference in New Issue
Block a user