summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp36
-rw-r--r--src/opengl/qgl_egl.cpp1
-rw-r--r--src/opengl/qgl_p.h3
-rw-r--r--src/opengl/qglpixelbuffer_win.cpp29
-rw-r--r--src/opengl/qpaintengine_opengl.cpp4
5 files changed, 53 insertions, 20 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 0d1a66e..9e74e04 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -509,6 +509,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()
*/
@@ -1689,6 +1692,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;
}
@@ -2574,18 +2580,34 @@ 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)
{
- 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 6323ce2..623eeaf 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -401,6 +401,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 b55f383..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[])
@@ -242,8 +246,7 @@ static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f
bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
{
- QGLWidget dmy;
- dmy.makeCurrent(); // needed for wglGetProcAddress() to succeed
+ QGLTemporaryContext tempContext;
PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB =
(PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");
@@ -257,13 +260,12 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
if (!wglCreatePbufferARB) // assumes that if one can be resolved, all of them can
return false;
- dc = GetDC(dmy.winId());
+ 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");
@@ -292,7 +294,6 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
if (num_formats == 0) {
qWarning("QGLPixelBuffer: Unable to find a pixel format with pbuffer - giving up.");
- ReleaseDC(dmy.winId(), dc);
return false;
}
format = pfiToQGLFormat(dc, pixel_format);
@@ -305,26 +306,32 @@ 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;
if (!pbuf) {
qWarning("QGLPixelBuffer: Unable to create pbuffer [w=%d, h=%d] - giving up.", size.width(), size.height());
- ReleaseDC(dmy.winId(), dc);
return false;
}
}
- ReleaseDC(dmy.winId(), dc);
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;