PDA

View Full Version : fbo stencil attachment not working



angrybob
06-27-2005, 12:49 AM
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);
tex1->attach_to_fbo_color();
opengl::printerror("D");
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, stencilrb);
opengl::printerror("E");
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8_EXT, 512, 512);
opengl::printerror("F");
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, stencilrb);
opengl::printerror("G");
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthrb);
opengl::printerror("H");
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);
opengl::printerror("I");
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthrb);
opengl::printerror("J");

opengl::check_fbo();

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);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, stencilrb);

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??

V-man
06-27-2005, 06:07 AM
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.

Overmind
06-27-2005, 09:16 AM
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.

Won
06-27-2005, 12:40 PM
I believe it is explicitly an errata that NVIDIA disclosed with their release 75 FBOs. New extension growing pains, and all...W

Overmind
06-27-2005, 11:15 PM
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...

simongreen
06-28-2005, 07:28 AM
The ARB is working on a depth stencil extension to solve this problem, based on this:

http://www.nvidia.com/dev_content/nvopenglspecs/GL_NV_packed_depth_stencil.txt

gdewan
06-28-2005, 10:23 AM
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

angrybob
06-30-2005, 04:18 AM
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.