diff options
author | Brian Paul <[email protected]> | 2011-12-24 08:54:26 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-12-24 08:59:54 -0700 |
commit | e6c6b1c147f5079a1608234294e2b6cd29dd2a64 (patch) | |
tree | d88f7844a915a88e76408b15f0f3219fefb8bbe2 /src/mesa | |
parent | bd31fb346398ca350a5e251a5d104ee1c8b33454 (diff) |
swrast: stop using depth/stencil wrappers in CopyPixels code
The functions that read depth/stencil values understand all (packed)
depth/stencil buffer formats now so there's no reason to use the
wrappers.
Also, improve the format checks in fast_copy_pixels() to catch mismatched
depth/stencil cases.
v2: fix the test for combined depth+stencil buffers, per Eric.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 9769a477db6..907645e3ff0 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -245,7 +245,7 @@ copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, GLint destx, GLint desty ) { struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *readRb = fb->_DepthBuffer; + struct gl_renderbuffer *readRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; GLfloat *p, *tmpImage; GLint sy, dy, stepy; GLint j; @@ -339,7 +339,7 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, GLint destx, GLint desty ) { struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->_StencilBuffer; + struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; GLint sy, dy, stepy; GLint j; GLubyte *p, *tmpImage; @@ -446,7 +446,7 @@ copy_depth_stencil_pixels(struct gl_context *ctx, depthDrawRb = ctx->DrawBuffer->_DepthBuffer; depthReadRb = ctx->ReadBuffer->_DepthBuffer; - stencilReadRb = ctx->ReadBuffer->_StencilBuffer; + stencilReadRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; ASSERT(depthDrawRb); ASSERT(depthReadRb); @@ -599,7 +599,7 @@ copy_depth_stencil_pixels(struct gl_context *ctx, /** - * Try to do a fast copy pixels. + * Try to do a fast copy pixels with memcpy. * \return GL_TRUE if successful, GL_FALSE otherwise. */ static GLboolean @@ -630,12 +630,12 @@ fast_copy_pixels(struct gl_context *ctx, dstRb = dstFb->_ColorDrawBuffers[0]; } else if (type == GL_STENCIL) { - srcRb = srcFb->_StencilBuffer; - dstRb = dstFb->_StencilBuffer; + srcRb = srcFb->Attachment[BUFFER_STENCIL].Renderbuffer; + dstRb = dstFb->Attachment[BUFFER_STENCIL].Renderbuffer; } else if (type == GL_DEPTH) { - srcRb = srcFb->_DepthBuffer; - dstRb = dstFb->_DepthBuffer; + srcRb = srcFb->Attachment[BUFFER_DEPTH].Renderbuffer; + dstRb = dstFb->Attachment[BUFFER_DEPTH].Renderbuffer; } else { ASSERT(type == GL_DEPTH_STENCIL_EXT); @@ -649,6 +649,19 @@ fast_copy_pixels(struct gl_context *ctx, return GL_FALSE; } + if (type == GL_STENCIL || type == GL_DEPTH_COMPONENT) { + /* can't handle packed depth+stencil here */ + if (_mesa_is_format_packed_depth_stencil(srcRb->Format) || + _mesa_is_format_packed_depth_stencil(dstRb->Format)) + return GL_FALSE; + } + else if (type == GL_DEPTH_STENCIL) { + /* can't handle separate depth/stencil buffers */ + if (srcRb != srcFb->Attachment[BUFFER_STENCIL].Renderbuffer || + dstRb != dstFb->Attachment[BUFFER_STENCIL].Renderbuffer) + return GL_FALSE; + } + /* clipping not supported */ if (srcX < 0 || srcX + width > (GLint) srcFb->Width || srcY < 0 || srcY + height > (GLint) srcFb->Height || |