summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_framebuffer.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-11-06 17:34:32 -0700
committerBrian <[email protected]>2007-11-06 17:34:32 -0700
commit85c7683f1f5f1d0d9e95eb59270705a2975fa437 (patch)
tree232b9f492253bf816930d41622866a9639e0d6d5 /src/mesa/state_tracker/st_framebuffer.c
parentb0e7da86abba5fc9040332a4b8ca81628a343956 (diff)
Improved logic for setting up depth/stencil buffers in st_create_framebuffer()
Diffstat (limited to 'src/mesa/state_tracker/st_framebuffer.c')
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 4833d10322e..b04dcdb79df 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -42,9 +42,6 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
struct st_framebuffer *stfb
= CALLOC_STRUCT(st_framebuffer);
if (stfb) {
- GLboolean swStencil = (visual->stencilBits > 0 &&
- visual->stencilBits != 8 &&
- visual->depthBits != 24);
GLenum rgbFormat = (visual->redBits == 5 ? GL_RGB5 : GL_RGBA8);
_mesa_initialize_framebuffer(&stfb->Base, visual);
@@ -63,29 +60,59 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
_mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
}
- if (visual->depthBits == 24) {
+ if (visual->depthBits == 24 && visual->stencilBits == 8) {
/* combined depth/stencil buffer */
struct gl_renderbuffer *depthStencilRb
= st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
/* note: bind RB to two attachment points */
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
- if(visual->stencilBits == 8)
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL,depthStencilRb);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, depthStencilRb);
}
- else if (visual->depthBits == 16) {
- /* just 16-bit depth buffer, no hw stencil */
- struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
- _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
+ else {
+ /* separate depth and/or stencil */
+
+ if (visual->depthBits == 32) {
+ /* 32-bit depth buffer */
+ struct gl_renderbuffer *depthRb
+ = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
+ }
+ else if (visual->depthBits == 24) {
+ /* 24-bit depth buffer, ignore stencil bits */
+ struct gl_renderbuffer *depthRb
+ = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
+ }
+ else if (visual->depthBits > 0) {
+ /* 16-bit depth buffer */
+ struct gl_renderbuffer *depthRb
+ = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
+ }
+
+ if (visual->stencilBits > 0) {
+ /* 8-bit stencil */
+ struct gl_renderbuffer *stencilRb
+ = st_new_renderbuffer_fb(GL_STENCIL_INDEX8_EXT);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, stencilRb);
+ }
}
- else
- assert(0);
+
+#if 0
+ if (visual->accumRedBits > 0) {
+ /* 16-bit/channel accum */
+ struct gl_renderbuffer *accumRb
+ = st_new_renderbuffer_fb(GL_RGBA16);
+ _mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb);
+ }
+#endif
/* now add any/all software-based renderbuffers we may need */
_mesa_add_soft_renderbuffers(&stfb->Base,
GL_FALSE, /* never sw color */
GL_FALSE, /* never sw depth */
- swStencil, visual->accumRedBits > 0,
+ GL_FALSE, /* stencil */
+ visual->accumRedBits > 0,
GL_FALSE, /* never sw alpha */
GL_FALSE /* never sw aux */ );
}