fbo stencil attachment not working

no one seemed to respond to this at gamedev so I’m reposting it here:

I’m using an Fx5200 and the latest linux drivers that support framebuffer objects. I can get fbo rendering to work fine using a texture for the color attachment and a renderbuffer for the depth attachement.But when I try attaching a renderbuffer to the stencil attachement it does not work. here is my code:

glGenFramebuffersEXT(1, &mainfb);
glGenRenderbuffersEXT(1, &depthrb);
glGenRenderbuffersEXT(1, &stencilrb);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mainfb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, stencilrb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8_EXT, 512, 512);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthrb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);


the opengl::printerror() calls just work out what error was generated if any, by the preceding commands. There are no errors generated by any commands except for the following two lines which both generate an invalid enumeration error:

glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8_EXT, 512, 512);

when I check the fbo for completeness afterwards it does say that it is complete but there is no stencil buffer.

Is this a driver bug or am I doing something wrong??

I don’t know about Linux, but for Windows there was some issue with binding a stencil buffer. The FBO would fail validation. I don’t know if this was fixed yet.

I think current hardware supports stencil buffer only “interleaved” with the depth buffer, that is, a single 32 bit buffer where 24 bit are depth and 8 bit are stencil. This is a problem with the current FBO spec, because it has to let us freely combine depth textures and stencil renderbuffers…

But an invalid enumeration error is almost certainly a problem in the driver, it should at least recognize what you’re trying to do and return unsupported.

I believe it is explicitly an errata that NVIDIA disclosed with their release 75 FBOs. New extension growing pains, and all…W

It’s just a matter of time until every graphics card supports seperate depth and stencil buffers… Until then, I hope we’ll get a workaround. For example creating a depth and a stencil renderbuffer and immidiately binding both to a framebuffer, so you really get a “combined” renderbuffer. And a software fallback as soon as you try to bind them seperately…

This would be at least a working solution to the problem. It’s consistent with the spec, but you have a limitation how you should use it in order to avoid software fallback… I don’t think a new extension is needed, because after some time, GPUs will be able to handle the general case…

The ARB is working on a depth stencil extension to solve this problem, based on this:


Link dead. In fact, all the links on http://developer.nvidia.com/object/nvidia_opengl_specs.html appear to be dead.

Addenda: Appears to be working now

well hopefully they’ll fix it by just being smart and detecting that you’ve bound a depth and a stencil buffer and using a combined one on gfx cards that dont support seperate ones.