More FBO problems on NVIDIA

I have two different projects with different code bases. Both of them attempt to create and use FBOs as render targets. One of them works, and one doesn’t, and I can’t find a difference that SHOULD matter. The biggest difference I can find is that one attaches the color buffer first; the second attaches the depth buffer first – but that “shouldn’t” matter, right?

Here is the code that works (from GLIntercept):

glGenFramebuffersEXT(1,0xaf7ad0)
glGetError()=GL_NO_ERROR 
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT,0x13fdc0)
glGetError()=GL_NO_ERROR 
glGetIntegerv(GL_TEXTURE_BINDING_2D,0x13fdb4)
glGetError()=GL_NO_ERROR 
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,1)
glGetError()=GL_NO_ERROR 
glGenTextures(1,0xaf7ac8)
glBindTexture(GL_TEXTURE_2D,1)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,1024,1024,0,GL_BGRA,GL_UNSIGNED_BYTE,0x0000)
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,1,0)
glGenerateMipmapEXT(GL_TEXTURE_2D)
glGetError()=GL_NO_ERROR 
glGenTextures(1,0xaf7acc)
glBindTexture(GL_TEXTURE_2D,2)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D,GL_DEPTH_TEXTURE_MODE,GL_LUMINANCE)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_MODE,GL_COMPARE_R_TO_TEXTURE)
glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,1024,1024,0,GL_DEPTH_COMPONENT,GL_FLOAT,0x0000)
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,2,0)
glGetError()=GL_NO_ERROR 
glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)=GL_FRAMEBUFFER_COMPLETE_EXT 

Here is the code that fails (again from GLIntercept):

wglGetCurrentContext()=0x20000 
glGetError()=GL_NO_ERROR 
glGenFramebuffersEXT(1,0x27c8a774)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,1)
glGetError()=GL_NO_ERROR 
glGenTextures(1,0x27c8a6e0)
glBindTexture(GL_TEXTURE_2D,1)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D,GL_DEPTH_TEXTURE_MODE,GL_LUMINANCE)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_MODE,GL_COMPARE_R_TO_TEXTURE)
glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT24,1024,1024,0,GL_DEPTH_COMPONENT,GL_FLOAT,0x0000)
glGetError()=GL_NO_ERROR 
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,1,0)
glGetError()=GL_NO_ERROR 
glGetError()=GL_NO_ERROR 
glGenTextures(1,0x13dbf0)
glBindTexture(GL_TEXTURE_2D,2)
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,1024,1024,0,GL_BGRA,GL_UNSIGNED_BYTE,0x0000)
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,2,0)
glGetError()=GL_NO_ERROR 
glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)=GL_FRAMEBUFFER_UNSUPPORTED_EXT 

Please, those of you with eyes sharper than mine, what’s wrong with the second code?

Maybe your video card/driver does not support GL_DEPTH_COMPONENT24 texture internal format?
In first code you are using GL_DEPTH_COMPONENT internal format for depth texture.

I also tried with GL_DEPTH_COMPONENT (no 24) but no luck.
However, it turned out that the problem was a missing glGenerateMipmapEXT() – without it, the framebuffer is considered incomplete, for reasons I don’t quite understand.

That’s a driver bug. The mipmap-completeness of the texture attachment should not affect the completeness of the framebuffer.

See issue 43) in the FBO spec.

Try using the GL_GENERATE_MIPMAP instead when you first setup your FBO. Can you try and use a compressed format also? This bug sounds similar to the one I just reported to Nvidia, and there is a fix coming. If its like mine, you need to use compressed texture formats…

No, a compressed format would be counter-productive, as this is a render target.
“glad” to know it’s a driver bug, although it’s always annoying when you have to spend the time tracking it down
AND our customers can’t be bothered to upgrade their drivers, so we’ll have to live with this using work-arounds.