From 20542f9546637bd649c928226249be0ffc91841b Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Wed, 19 Oct 2011 09:39:22 +0300 Subject: Workaround to VideoCore III scissor bug. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 ++ src/opengl/qgl.cpp | 2 ++ src/opengl/qgl_egl.cpp | 11 ++++++++++- src/opengl/qgl_p.h | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 047d589..999a074 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -2059,6 +2059,8 @@ void QGL2PaintEngineExPrivate::updateClipScissorTest() currentScissorBounds = bounds; if (bounds == QRect(0, 0, width, height)) { + if (ctx->d_func()->workaround_brokenScissor) + clearClip(0); glDisable(GL_SCISSOR_TEST); } else { glEnable(GL_SCISSOR_TEST); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3b3da43..af160d8 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1716,6 +1716,8 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) workaround_brokenTextureFromPixmap = false; workaround_brokenTextureFromPixmap_init = false; + workaround_brokenScissor = false; + for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) vertexAttributeArraysEnabledState[i] = false; } diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index a589118..07134cf 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -192,7 +192,9 @@ void QGLContext::makeCurrent() if (!d->workaroundsCached) { d->workaroundsCached = true; const char *renderer = reinterpret_cast(glGetString(GL_RENDERER)); - if (renderer && (strstr(renderer, "SGX") || strstr(renderer, "MBX"))) { + if (!renderer) + return; + if ((strstr(renderer, "SGX") || strstr(renderer, "MBX"))) { // PowerVR MBX/SGX chips needs to clear all buffers when starting to render // a new frame, otherwise there will be a performance penalty to pay for // each frame. @@ -229,6 +231,13 @@ void QGLContext::makeCurrent() d->workaround_brokenFBOReadBack = true; } } + } else if (strstr(renderer, "VideoCore III")) { + // Some versions of VideoCore III drivers seem to pollute and use + // stencil buffer when using glScissors even if stencil test is disabled. + // Workaround is to clear stencil buffer before disabling scissoring. + + // qDebug() << "Found VideoCore III driver, enabling brokenDisableScissorTest"; + d->workaround_brokenScissor = true; } } } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index c56b2db..d76f0b0 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -415,6 +415,8 @@ public: uint workaround_brokenTextureFromPixmap : 1; uint workaround_brokenTextureFromPixmap_init : 1; + uint workaround_brokenScissor : 1; + QPaintDevice *paintDevice; QColor transpColor; QGLContext *q_ptr; -- cgit v0.12