QGLFramebufferObject constructor generates OpenGL errors on Intel HD Graphics using Mesa 10.3.1
-
I have encountered an odd situation in which the QGLFramebufferObject constructor from Qt 4.8 consistently generates an OpenGL INVALID_OPERATION error only on Intel HD Graphics using Mesa. Has anyone else encountered this? The conditions to generate the error (discussed below) are exceptionally simple so I wonder if I have done something horribly wrong. Below I provide snippet of the code which can generate the error, a link to a fully working minimal demo, and additional information about my debugging efforts. Any comments would be appreciated.
The core part of the code (which you can "browse on GitHub":https://github.com/bkloppenborg/opengl-blit-test/blob/master/src/main.cpp although there is a lot of ancillary debugging stuff hanging around in the file) is very simple:
@int main(int argc, char* argv[])
{
QApplication app(argc, argv);unsigned int width = 128; unsigned int height = 128; unsigned int depth = 1; unsigned int samples = 4; // Select an OpenGL 3.3 core profile context QGLFormat gl_core_format; gl_core_format.setVersion(3, 2); gl_core_format.setProfile(QGLFormat::CoreProfile); gl_core_format.setAlpha(true); gl_core_format.setDoubleBuffer(true); gl_core_format.setSampleBuffers(true); gl_core_format.setSamples(samples); QGLFormat::setDefaultFormat(gl_core_format); QGLWidget gl; // Check that the context is valid if(!gl.isValid ()) { std::cout << "ERROR: No GL context!" << std::endl; return -1; } // do some off-screen rendering, the widget has never been made visible gl.makeCurrent (); // ABSOLUTELY CRUCIAL! QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION)))); qDebug() << endl << "OpenGL information:" << endl; qDebug() << " Driver Version String:" << versionString; qDebug() << " Current Context:" << gl.format(); gl.resize(width, height); qDebug() << endl << "Widget information:"; qDebug() << " Size: " << gl.size() << endl; gl.show(); CHECK_OPENGL_STATUS_ERROR(glGetError(), "Error comes from above"); QGLFramebufferObject * FBO = new QGLFramebufferObject(gl.size()); CHECK_OPENGL_STATUS_ERROR(glGetError(), "Failed to create buffer"); QRect region(0, 0, width, height); QGLFramebufferObject::blitFramebuffer (NULL, region, FBO, region); CHECK_OPENGL_STATUS_ERROR(glGetError(), "Failed to blit buffers"); cout << "BLIT successful." << endl; delete FBO; return 0;
}@
When executed on Ubuntu 14.04.1 using Mesa 10.1.3, the call to QGLFramebufferObject will generate an OpenGL INVALID_OPERATION error which is caught in the CHECK_OPENGL_STATUS_ERROR function immediately thereafter.
As a first order of debugging this, I verified the program compiles and executes, without any errors, on three other devices on two operating systems (NVidia 8600m on Ubuntu 14.04.1, ATI Radeon R9 280x on Ubuntu 14.04.1, and Intel Integrated Graphics 4000 on a Macbook pro).
After this, I checked the Intel Integrated Graphics system that failed in more detail. I verified that OpenGL was installed, functioning, and had the necessary extensions (see the "output from various glxInfo and glxGears here":https://github.com/bkloppenborg/opengl-blit-test#intel-core-i7-4770k-on-ubuntu-linux-14041-intel-hd-graphics-4000-using-mesa-1013-fails ). I have tried calling QGLFramebufferObject with only the default (width, height) arguments and custom storage formats. Although Qt indicates the framebuffer is complete (and direct OpenGL calls agree), the QGLFramebufferObject always generates an INVALID_OPERATION error. How might I debug this further?