diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2010-10-05 00:10:04 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2010-10-05 00:10:04 (GMT) |
commit | d2eb1ed680353dc326b68119c384d0f09d4aae62 (patch) | |
tree | cac4b62d51bd6732ab48527d71843496636a8844 /src/opengl | |
parent | c7bf2d79f37ac302dad9a5782645bd3f465bb47d (diff) | |
parent | c1f9978c9d61bcbdb2f280185a3abdea13d7f532 (diff) | |
download | Qt-d2eb1ed680353dc326b68119c384d0f09d4aae62.zip Qt-d2eb1ed680353dc326b68119c384d0f09d4aae62.tar.gz Qt-d2eb1ed680353dc326b68119c384d0f09d4aae62.tar.bz2 |
Merge commit 'c1f9978c9d61bcbdb2f280185a3abdea13d7f532' into master-from-4.7
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 36 | ||||
-rw-r--r-- | src/opengl/qgl_egl.cpp | 1 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 3 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer_win.cpp | 21 | ||||
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 4 |
5 files changed, 51 insertions, 14 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5c2d948..cb31491 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -515,6 +515,9 @@ QGLFormat::~QGLFormat() exchange the screen contents with the buffer. The result is flicker-free drawing and often better performance. + Note that single buffered contexts are currently not supported + with EGL. + \sa doubleBuffer(), QGLContext::swapBuffers(), QGLWidget::swapBuffers() */ @@ -1696,6 +1699,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) 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; } @@ -2578,19 +2584,35 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, } } -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) - // Only try to use texture_from_pixmap under X11/EGL +#if defined(Q_WS_X11) + // Try to use texture_from_pixmap const QX11Info *xinfo = qt_x11Info(paintDevice); if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType && xinfo && xinfo->screen() == pixmap.x11Info().screen() && target == GL_TEXTURE_2D && QApplication::instance()->thread() == QThread::currentThread()) { - 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_egl.cpp b/src/opengl/qgl_egl.cpp index ebd1169..c79c4cd 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -143,6 +143,7 @@ void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) format.setRgba(true); // EGL doesn't support colour index rendering format.setStereo(false); // EGL doesn't support stereo buffers format.setAccumBufferSize(0); // EGL doesn't support accululation buffers + format.setDoubleBuffer(true); // We don't support single buffered EGL contexts // Clear the EGL error state because some of the above may // have errored out because the attribute is not applicable diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 73c0d65..78f888a 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -402,6 +402,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; diff --git a/src/opengl/qglpixelbuffer_win.cpp b/src/opengl/qglpixelbuffer_win.cpp index 1da0aad..c61d9bf 100644 --- a/src/opengl/qglpixelbuffer_win.cpp +++ b/src/opengl/qglpixelbuffer_win.cpp @@ -172,6 +172,10 @@ typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, con #define WGL_SAMPLES_ARB 0x2042 #endif +#ifndef GL_SAMPLES_ARB +#define GL_SAMPLES_ARB 0x80A9 +#endif + QGLFormat pfiToQGLFormat(HDC hdc, int pfi); static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f, int attribs[]) @@ -258,11 +262,10 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge dc = wglGetCurrentDC(); Q_ASSERT(dc); + has_render_texture = false; // sample buffers doesn't work in conjunction with the render_texture extension - if (f.sampleBuffers()) { - has_render_texture = false; - } else { + if (!f.sampleBuffers()) { PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); @@ -303,7 +306,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), has_render_texture ? pb_attribs : 0); - if(!pbuf) { + if (!pbuf) { // try again without the render_texture extension pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), 0); has_render_texture = false; @@ -315,12 +318,20 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge dc = wglGetPbufferDCARB(pbuf); ctx = wglCreateContext(dc); - if (!dc || !ctx) { qWarning("QGLPixelBuffer: Unable to create pbuffer context - giving up."); return false; } + // Explicitly disable the render_texture extension if we have a + // multi-sampled pbuffer context. This seems to be a problem only with + // ATI cards if multi-sampling is forced globally in the driver. + wglMakeCurrent(dc, ctx); + GLint samples = 0; + glGetIntegerv(GL_SAMPLES_ARB, &samples); + if (has_render_texture && samples != 0) + has_render_texture = false; + HGLRC share_ctx = shareWidget ? shareWidget->d_func()->glcx->d_func()->rc : 0; if (share_ctx && !wglShareLists(share_ctx, ctx)) qWarning("QGLPixelBuffer: Unable to share display lists - with share widget."); diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 58778ea..2f17aa6 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -506,12 +506,12 @@ struct QDrawQueueItem ////////// GL program cache: start -typedef struct { +struct GLProgram { int brush; // brush index or mask index int mode; // composition mode index bool mask; GLuint program; -} GLProgram; +}; typedef QMultiHash<const QGLContext *, GLProgram> QGLProgramHash; |