问题
I am getting a weird OpenGL error when running my application on my HD4000 (Windows 64bit, driver version 15.28.20.64.3347).
I boiled it down to a few OpenGL calls to reproduce it:
- Create two framebuffer objects.
- Create a texture and bind it as GL_COLOR_ATTACHMENT0 to both FBOs.
- Call glTexImage2D a second time on the texture
- Bind the first FBO and call glCheckFramebufferStatus (returns GL_FRAMEBUFFER_COMPLETE).
- Bind the second FBO and call glClear. The glClear gives an GL_INVALID_FRAMEBUFFER_OPERATION.
Step 3 and 4 are required to reproduce the error, which I find especially disturbing for the glCheckFramebufferStatus call. The problem also does not occur on other graphics cards (including the Nvidia card on the same machine).
If you call glCheckFramebufferStatus on the second FBO, it also returns GL_FRAMEBUFFER_COMPLETE. However, when inspecting the internal OpenGL state with apitrace, it says that the second FBO has now a color attachment with object name zero.
Re-binding the texture to the second FBO after the glCheckFramebufferStatus call resolves the error. This is working as a workaround for now, but I suppose that binding textures to various FBOs each frame is not a good idea.
Here is the C++ code that reproduces the error:
// Create a texture and bind it to two FBOs
GLuint textureName;
glGenTextures(1, &textureName);
glBindTexture(GL_TEXTURE_RECTANGLE, textureName);
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
GLuint fboNames[2];
glGenFramebuffers(2, fboNames);
glBindFramebuffer(GL_FRAMEBUFFER, fboNames[0]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, textureName, 0);
glBindFramebuffer(GL_FRAMEBUFFER, fboNames[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, textureName, 0);
glBindTexture(GL_TEXTURE_RECTANGLE, textureName);
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindFramebuffer(GL_FRAMEBUFFER, fboNames[0]);
// Removing this line resolves the error
glCheckFramebufferStatus(GL_FRAMEBUFFER); // Returns GL_FRAMEBUFFER_COMPLETE
glBindFramebuffer(GL_FRAMEBUFFER, fboNames[1]);
GLenum bufferTarget = GL_COLOR_ATTACHMENT0;
glDrawBuffers(1, &bufferTarget);
// Adding this line resolves the error
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_RECTANGLE, 1, 0);
glCheckFramebufferStatus(GL_FRAMEBUFFER); // Returns GL_FRAMEBUFFER_COMPLETE
//This call causes a GL_INVALID_FRAMEBUFFER_OPERATION error.
glClear(GL_COLOR_BUFFER_BIT);
Here is a minimal Visual Studio 2013 Project to reproduce it: https://www.dropbox.com/s/5142j26d839gkp9/HD4000Error.zip
Now, my question is: Am I doing something illegal with OpenGL here or is this simply a driver bug?
回答1:
We reported this issue to Intel and it seems that it was in fact a bug. It is fixed in the current driver version.
来源:https://stackoverflow.com/questions/21241786/invalid-framebuffer-operation-after-glcheckframebufferstatus