Skip to content

Commit 20542f9

Browse files
author
Jani Hautakangas
committed
Workaround to VideoCore III scissor bug.
Some versions of VideoCore III drivers seem to pollute and use stencil buffer when using glScissors. Workaround is to clear stencil buffer before disabling scissoring. Task-number: QT-5308 Reviewed-by: Samuel Rødal
1 parent b9a3d4b commit 20542f9

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,8 @@ void QGL2PaintEngineExPrivate::updateClipScissorTest()
20592059
currentScissorBounds = bounds;
20602060

20612061
if (bounds == QRect(0, 0, width, height)) {
2062+
if (ctx->d_func()->workaround_brokenScissor)
2063+
clearClip(0);
20622064
glDisable(GL_SCISSOR_TEST);
20632065
} else {
20642066
glEnable(GL_SCISSOR_TEST);

src/opengl/qgl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,8 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
17161716
workaround_brokenTextureFromPixmap = false;
17171717
workaround_brokenTextureFromPixmap_init = false;
17181718

1719+
workaround_brokenScissor = false;
1720+
17191721
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
17201722
vertexAttributeArraysEnabledState[i] = false;
17211723
}

src/opengl/qgl_egl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ void QGLContext::makeCurrent()
192192
if (!d->workaroundsCached) {
193193
d->workaroundsCached = true;
194194
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
195-
if (renderer && (strstr(renderer, "SGX") || strstr(renderer, "MBX"))) {
195+
if (!renderer)
196+
return;
197+
if ((strstr(renderer, "SGX") || strstr(renderer, "MBX"))) {
196198
// PowerVR MBX/SGX chips needs to clear all buffers when starting to render
197199
// a new frame, otherwise there will be a performance penalty to pay for
198200
// each frame.
@@ -229,6 +231,13 @@ void QGLContext::makeCurrent()
229231
d->workaround_brokenFBOReadBack = true;
230232
}
231233
}
234+
} else if (strstr(renderer, "VideoCore III")) {
235+
// Some versions of VideoCore III drivers seem to pollute and use
236+
// stencil buffer when using glScissors even if stencil test is disabled.
237+
// Workaround is to clear stencil buffer before disabling scissoring.
238+
239+
// qDebug() << "Found VideoCore III driver, enabling brokenDisableScissorTest";
240+
d->workaround_brokenScissor = true;
232241
}
233242
}
234243
}

src/opengl/qgl_p.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ class QGLContextPrivate
415415
uint workaround_brokenTextureFromPixmap : 1;
416416
uint workaround_brokenTextureFromPixmap_init : 1;
417417

418+
uint workaround_brokenScissor : 1;
419+
418420
QPaintDevice *paintDevice;
419421
QColor transpColor;
420422
QGLContext *q_ptr;

0 commit comments

Comments
 (0)