2
\$\begingroup\$

I've been using the glxinfo command (glxinfo -v) to explore the supported framebuffer configurations. There are two values relating to depth, "depth" and "depthsize." According the source, it appears that the "depth" value relates to the X config and the "depthsize" value relates to the OpenGL config.

Assuming that is correct, would the lack of a "depthsize=32" entry suggest that 32 bit depth buffers aren't supported? Or is my understanding of the glxinfo output flawed?

\$\endgroup\$

1 Answer 1

6
\$\begingroup\$

It's important to note that glxinfo -v only reports the supported values for the default OpenGL framebuffer, the one that represents the visible screen itself. It's common for other configurations (ones not reported by glxinfo) to be supported in offscreen framebuffer objects (FBOs).

As you've noticed, most video cards do not support a 32-bit depth buffer for the default framebuffer, but any recent card can be expected to support them as attachments to an FBO.

So if you want a better depth buffer, you want to create a separate FBO, and attach a 32-bit depth buffer to it, and then render into it, instead of directly to the screen. Once you've finished rendering, blit the final rendered image back to the screen.

Note that NVidia cards historically have not supported 32-bit fixed-point (ie: integer) z-buffers even in FBOs, but do support 32-bit floating point z-buffers there (and have been like this for about a decade). So if you want 32-bit z-buffers, specify their depth attachment as using GL_DEPTH_COMPONENT32F, not as GL_DEPTH_COMPONENT32.

EDIT:

Testing on an NVidia GeForce GTX 980, using the official NVidia drivers version 352.63, when creating an FBO the driver will not give me a 32-bit fixed point depth buffer. If I ask for one, it instead gives me a 24-bit fixed point depth buffer, exactly as other NVidia cards have done for many years.

If I ask for a 32-bit floating point depth buffer, then I do receive one, which also matches the normal behaviour of older NVidia cards.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks for your answer; this is exactly what I'm looking for. You said that historically 32 bit fixed has not been supported in FBOs on Nvidia hardware - is this still true for modern cards? \$\endgroup\$
    – Shadow503
    Commented Apr 28, 2016 at 14:40
  • 1
    \$\begingroup\$ @Shadow503 I can't find any documentation on precisely which FBO attachment formats are supported in NVidia's current crop of cards, but what they've traditionally done is to silently give you a 24-bit fixed-point depth buffer if you'd requested a 32-bit one. To tell if they're still doing that, you'd probably need to render something on the card, read back the depth buffer, and programmatically check how the depth values are quantized. \$\endgroup\$ Commented Apr 28, 2016 at 23:52
  • 1
    \$\begingroup\$ ...though having said that, if you're using a renderbuffer, you can probably use glGetRenderbufferParameteriv( <target>, GL_RENDERBUFFER_DEPTH_SIZE, &result ) to directly query what size the created depth buffer was. I'll give that a try on my 980 and add the results. \$\endgroup\$ Commented Apr 28, 2016 at 23:57
  • \$\begingroup\$ Thanks for the additional investigation! I'll have to see if I can get a 32 bit floating point buffer to work for my scene. Will doing this prevent me from using a stencil buffer? \$\endgroup\$
    – Shadow503
    Commented Apr 29, 2016 at 15:22
  • 1
    \$\begingroup\$ You can gain access to a stencil buffer by using a renderbuffer format of GL_DEPTH32F_STENCIL8 instead of GL_DEPTH_COMPONENT32F, and then attaching that single renderbuffer as both your FBO's depth attachment and its stencil attachment. I believe that this format is guaranteed to be supported by any OpenGL 3.x+ core context. \$\endgroup\$ Commented Apr 30, 2016 at 1:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .