diff options
author | Brian Paul <[email protected]> | 2011-12-10 11:44:44 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-12-13 06:45:37 -0700 |
commit | d7c0fac90b1fe550df3d75777747c1ae9be41fc0 (patch) | |
tree | f700709dcb247e9e9fc9f0638a24154f4e4bb7c8 /src/mesa/swrast/s_renderbuffer.c | |
parent | 8ba9c22cdb9fb16725a7d02dc200fcd8386f315f (diff) |
swrast: add debug code to test combined depth/stencil buffers
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/swrast/s_renderbuffer.c')
-rw-r--r-- | src/mesa/swrast/s_renderbuffer.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c index 7622e38fd3c..bb7cdebfe8c 100644 --- a/src/mesa/swrast/s_renderbuffer.c +++ b/src/mesa/swrast/s_renderbuffer.c @@ -1888,6 +1888,31 @@ add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, } +static GLboolean +add_depth_stencil_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb) +{ + struct gl_renderbuffer *rb; + + assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); + assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth+stencil buffer"); + return GL_FALSE; + } + + rb->InternalFormat = GL_DEPTH_STENCIL; + + rb->AllocStorage = soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); + + return GL_TRUE; +} + + /** * Add a software-based accumulation renderbuffer to the given framebuffer. * This is a helper routine for device drivers when creating a @@ -1999,14 +2024,29 @@ _swrast_add_soft_renderbuffers(struct gl_framebuffer *fb, frontRight, backRight); } - if (depth) { - assert(fb->Visual.depthBits > 0); - add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); - } +#if 0 + /* This is pretty much for debugging purposes only since there's a perf + * hit for using combined depth/stencil in swrast. + */ + if (depth && fb->Visual.depthBits == 24 && + stencil && fb->Visual.stencilBits == 8) { + /* use combined depth/stencil buffer */ + add_depth_stencil_renderbuffer(NULL, fb); + } + else +#else + (void) add_depth_stencil_renderbuffer; +#endif + { + if (depth) { + assert(fb->Visual.depthBits > 0); + add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); + } - if (stencil) { - assert(fb->Visual.stencilBits > 0); - add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + if (stencil) { + assert(fb->Visual.stencilBits > 0); + add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + } } if (accum) { |