From: Brian Paul Date: Sat, 24 Dec 2011 15:54:26 +0000 (-0700) Subject: swrast: remove the copy_depth_stencil_pixels() function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=826f36b1d8ae3881e6095d905fd10a7070742098;p=mesa.git swrast: remove the copy_depth_stencil_pixels() function Hopefully glCopyPixels(GL_DEPTH_STENCIL) will be handled by the fast copy function. Otherwise, just do the copy with separate depth + stencil copies. That's effectively what the removed code did anyway. Reviewed-by: Eric Anholt --- diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 907645e3ff0..1dc4286a3c2 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -421,183 +421,6 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, } -/** - * This isn't terribly efficient. If a driver really has combined - * depth/stencil buffers the driver should implement an optimized - * CopyPixels function. - */ -static void -copy_depth_stencil_pixels(struct gl_context *ctx, - const GLint srcX, const GLint srcY, - const GLint width, const GLint height, - const GLint destX, const GLint destY) -{ - struct gl_renderbuffer *stencilReadRb, *depthReadRb, *depthDrawRb; - GLint sy, dy, stepy; - GLint j; - GLubyte *tempStencilImage = NULL, *stencilPtr = NULL; - GLfloat *tempDepthImage = NULL, *depthPtr = NULL; - const GLfloat depthScale = ctx->DrawBuffer->_DepthMaxF; - const GLuint stencilMask = ctx->Stencil.WriteMask[0]; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - const GLboolean scaleOrBias - = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0; - GLint overlapping; - - depthDrawRb = ctx->DrawBuffer->_DepthBuffer; - depthReadRb = ctx->ReadBuffer->_DepthBuffer; - stencilReadRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - - ASSERT(depthDrawRb); - ASSERT(depthReadRb); - ASSERT(stencilReadRb); - - if (ctx->DrawBuffer == ctx->ReadBuffer) { - overlapping = regions_overlap(srcX, srcY, destX, destY, width, height, - ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); - } - else { - overlapping = GL_FALSE; - } - - /* Determine if copy should be bottom-to-top or top-to-bottom */ - if (!overlapping && srcY < destY) { - /* top-down max-to-min */ - sy = srcY + height - 1; - dy = destY + height - 1; - stepy = -1; - } - else { - /* bottom-up min-to-max */ - sy = srcY; - dy = destY; - stepy = 1; - } - - if (overlapping) { - GLint ssy = sy; - - if (stencilMask != 0x0) { - tempStencilImage - = (GLubyte *) malloc(width * height * sizeof(GLubyte)); - if (!tempStencilImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return; - } - - /* get copy of stencil pixels */ - stencilPtr = tempStencilImage; - for (j = 0; j < height; j++, ssy += stepy) { - _swrast_read_stencil_span(ctx, stencilReadRb, - width, srcX, ssy, stencilPtr); - stencilPtr += width; - } - stencilPtr = tempStencilImage; - } - - if (ctx->Depth.Mask) { - tempDepthImage - = (GLfloat *) malloc(width * height * sizeof(GLfloat)); - if (!tempDepthImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - free(tempStencilImage); - return; - } - - /* get copy of depth pixels */ - depthPtr = tempDepthImage; - for (j = 0; j < height; j++, ssy += stepy) { - _swrast_read_depth_span_float(ctx, depthReadRb, - width, srcX, ssy, depthPtr); - depthPtr += width; - } - depthPtr = tempDepthImage; - } - } - - for (j = 0; j < height; j++, sy += stepy, dy += stepy) { - if (stencilMask != 0x0) { - GLubyte stencil[MAX_WIDTH]; - - /* Get stencil values */ - if (overlapping) { - memcpy(stencil, stencilPtr, width * sizeof(GLubyte)); - stencilPtr += width; - } - else { - _swrast_read_stencil_span(ctx, stencilReadRb, - width, srcX, sy, stencil); - } - - _mesa_apply_stencil_transfer_ops(ctx, width, stencil); - - /* Write values */ - if (zoom) { - _swrast_write_zoomed_stencil_span(ctx, destX, destY, width, - destX, dy, stencil); - } - else { - _swrast_write_stencil_span( ctx, width, destX, dy, stencil ); - } - } - - if (ctx->Depth.Mask) { - GLfloat depth[MAX_WIDTH]; - GLuint zVals32[MAX_WIDTH]; - GLushort zVals16[MAX_WIDTH]; - GLvoid *zVals; - GLuint zBytes; - - /* get depth values */ - if (overlapping) { - memcpy(depth, depthPtr, width * sizeof(GLfloat)); - depthPtr += width; - } - else { - _swrast_read_depth_span_float(ctx, depthReadRb, - width, srcX, sy, depth); - } - - /* scale & bias */ - if (scaleOrBias) { - _mesa_scale_and_bias_depth(ctx, width, depth); - } - /* convert to integer Z values */ - if (depthDrawRb->DataType == GL_UNSIGNED_SHORT) { - GLint k; - for (k = 0; k < width; k++) - zVals16[k] = (GLushort) (depth[k] * depthScale); - zVals = zVals16; - zBytes = 2; - } - else { - GLint k; - for (k = 0; k < width; k++) - zVals32[k] = (GLuint) (depth[k] * depthScale); - zVals = zVals32; - zBytes = 4; - } - - /* Write values */ - if (zoom) { - _swrast_write_zoomed_z_span(ctx, destX, destY, width, - destX, dy, zVals); - } - else { - _swrast_put_row(ctx, depthDrawRb, width, destX, dy, zVals, zBytes); - } - } - } - - if (tempStencilImage) - free(tempStencilImage); - - if (tempDepthImage) - free(tempDepthImage); -} - - - /** * Try to do a fast copy pixels with memcpy. * \return GL_TRUE if successful, GL_FALSE otherwise. @@ -777,7 +600,9 @@ _swrast_CopyPixels( struct gl_context *ctx, copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty ); break; case GL_DEPTH_STENCIL_EXT: - copy_depth_stencil_pixels(ctx, srcx, srcy, width, height, destx, desty); + /* Copy buffers separately (if the fast copy path wasn't taken) */ + copy_depth_pixels(ctx, srcx, srcy, width, height, destx, desty); + copy_stencil_pixels(ctx, srcx, srcy, width, height, destx, desty); break; default: _mesa_problem(ctx, "unexpected type in _swrast_CopyPixels");