Disable surfaceless QOffscreenSurface with Mesa

With Intel at least Mesa is unable to handle surfaceless contexts in
glReadPixels(). This cripples QOpenGLFramebufferObject::toImage() and
potentially others too.

Task-number: QTBUG-46605
Change-Id: I07c1015eca67b8add14496ec0df0e0c17ac3d896
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2015-06-22 10:58:12 +02:00
parent f0fecf7b61
commit 8aaf8d33e1

View File

@ -55,7 +55,18 @@ QEGLPbuffer::QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffs
, m_display(display)
, m_pbuffer(EGL_NO_SURFACE)
{
if (q_hasEglExtension(display, "EGL_KHR_surfaceless_context"))
bool hasSurfaceless = q_hasEglExtension(display, "EGL_KHR_surfaceless_context");
// Disable surfaceless contexts on Mesa for now. As of 10.6.0 and Intel at least, some
// operations (glReadPixels) are unable to work without a surface since they at some
// point temporarily unbind the current FBO and then later blow up in some seemingly
// safe operations, like setting the viewport, that apparently need access to the
// read/draw surface in the Intel backend.
const char *vendor = eglQueryString(display, EGL_VENDOR); // hard to check for GL_ strings here, so blacklist all Mesa
if (vendor && strstr(vendor, "Mesa"))
hasSurfaceless = false;
if (hasSurfaceless)
return;
EGLConfig config = q_configFromGLFormat(m_display, m_format, false, EGL_PBUFFER_BIT);