diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-08-17 08:29:03 (GMT) |
---|---|---|
committer | Toby Tomkins <toby.tomkins@nokia.com> | 2010-08-19 00:29:57 (GMT) |
commit | 3e095417325c6184203c346e850cfe1d1bb044a2 (patch) | |
tree | f31295291dddae76feb2f11825c920c9d771ed07 /src | |
parent | 0f7d34f1fc91fffd6f1264def27c6d353533050b (diff) | |
download | Qt-3e095417325c6184203c346e850cfe1d1bb044a2.zip Qt-3e095417325c6184203c346e850cfe1d1bb044a2.tar.gz Qt-3e095417325c6184203c346e850cfe1d1bb044a2.tar.bz2 |
Prevented Xorg crash in qtdemo when running corkboards example.
The crash happens in the Nvidia driver in glXReleaseTexImageEXT when
scrolling the corkboard using the mouse. To work around it we detect the
Nvidia driver versions where this is known to be a problem and skip
using the texture from pixmap extension in those cases.
Task-number: QTBUG-12914
Reviewed-by: Trond
(cherry picked from commit a76b8bf67696ae69888cc6237417e7c8f07f8da6)
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qgl.cpp | 30 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 3 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2fa33bf..f69b421 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1688,6 +1688,10 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) workaround_needsFullClearOnEveryFrame = false; workaround_brokenFBOReadBack = false; workaroundsCached = false; + + workaround_brokenTextureFromPixmap = false; + workaround_brokenTextureFromPixmap_init = false; + for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) vertexAttributeArraysEnabledState[i] = false; } @@ -2570,11 +2574,27 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, && xinfo && xinfo->screen() == pixmap.x11Info().screen() && target == GL_TEXTURE_2D) { - texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options); - if (texture) { - texture->options |= QGLContext::MemoryManagedBindOption; - texture->boundPixmap = pd; - boundPixmaps.insert(pd, QPixmap(pixmap)); + if (!workaround_brokenTextureFromPixmap_init) { + workaround_brokenTextureFromPixmap_init = true; + + const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION))); + const int pos = versionString.indexOf("NVIDIA "); + + if (pos >= 0) { + const QByteArray nvidiaVersionString = versionString.mid(pos + strlen("NVIDIA ")); + + if (nvidiaVersionString.startsWith("195") || nvidiaVersionString.startsWith("256")) + workaround_brokenTextureFromPixmap = true; + } + } + + if (!workaround_brokenTextureFromPixmap) { + texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options); + if (texture) { + texture->options |= QGLContext::MemoryManagedBindOption; + texture->boundPixmap = pd; + boundPixmaps.insert(pd, QPixmap(pixmap)); + } } } #endif diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 32feacd..ca0d3fa 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -393,6 +393,9 @@ public: uint workaround_brokenFBOReadBack : 1; uint workaroundsCached : 1; + uint workaround_brokenTextureFromPixmap : 1; + uint workaround_brokenTextureFromPixmap_init : 1; + QPaintDevice *paintDevice; QColor transpColor; QGLContext *q_ptr; |