View Full Version : FBO Packed depth/stencil gotcha
11-21-2007, 06:42 AM
I was using FBO's with packed Depth/Stencil and was not getting any results.
I check the specs and don't see anything obvious - code looks fine.
After a long time I figured that the StencilMask was set to 0, even tho the spec clearly states "Initially, all bits are enabled for writing"
So I though this was a driver bug, but it seems that if your main frame buffer does not have stencil, the stencil mask is set to zero. (which does seem kinda reasonable, but still a bit of a gotcha)
This is on Nvidia 162.18 drivers.
11-21-2007, 08:02 AM
Thanks for sharing that iformation with us. May save some trouble.
11-21-2007, 01:09 PM
That sounds like a bug.
The stencil ref, mask, backref, backmask should be kept as 32 bit values on specification, and re-clamped to the available number of stencil bits on each framebuffer bind.
So you should be able to create a window context with no stencil buffer, set the ref/mask to 255. Querying the ref/mask now will return 0. But then bind to a fbo with stencil attachment, and the ref/mask (and query) should be masked to the number of bits in the attachment, without you ever re-specifying the values.
02-06-2008, 05:21 AM
THANKYOU THANKYOU THANKYOU!!!!!
I spent FOUR HOURS trying to figure out why my stencil buffer wasn't working before I came across your post.
NVidia, I really hate you right now. Please fix this stupid bug. My main window doesn't have a depth buffer and fbo depth buffering worked fine, why should stencil buffering be any different?
02-06-2008, 06:39 AM
Just to be clear, you can easily work around this bug by doing a:
on startup once you have created your context.
02-06-2008, 09:03 AM
Not quite - creating the context and immediately calling glStencilMask won't work. However, calling glStencilMask after creating an fbo with a stencil buffer does work.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.