st/mesa: Check the format before adding depth/stencil buffers.
authorChia-I Wu <olv@lunarg.com>
Fri, 12 Mar 2010 03:27:50 +0000 (11:27 +0800)
committerChia-I Wu <olv@lunarg.com>
Fri, 12 Mar 2010 03:30:46 +0000 (11:30 +0800)
The format might have depth bits, stencil bits, or both.  Add the
renderbuffers as needed.

src/mesa/state_tracker/st_manager.c

index 6c3cde0968312d6e3017a1816d78c7449c319b7d..f0dda4be6e9b0df02908e0a1bd819527923a246a 100644 (file)
@@ -270,9 +270,15 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
    if (!rb)
       return FALSE;
 
-   _mesa_add_renderbuffer(&stfb->Base, idx, rb);
-   if (idx == BUFFER_DEPTH)
-      _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb);
+   if (idx != BUFFER_DEPTH) {
+      _mesa_add_renderbuffer(&stfb->Base, idx, rb);
+   }
+   else {
+      if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0))
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, rb);
+      if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1))
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb);
+   }
 
    return TRUE;
 }