summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-10-12 13:39:14 -0700
committerEric Anholt <[email protected]>2011-11-03 23:29:52 -0700
commite887df9bf56195dafdd945755cc52ac4cd4aab62 (patch)
tree86e8ae4b5144ab35fa6a93fcdd2733bb5e5c3ba6 /src
parentd072a5f545a272e1b27bbc528b504617824fba78 (diff)
swrast: Switch the remaining depth readpixels to MapRenderbuffer.
This avoids the wrapper, which should improve performance on packed depth/stencil drivers. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_readpix.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 4637bfb829f..5d79a20644d 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -103,8 +103,10 @@ read_depth_pixels( struct gl_context *ctx,
const struct gl_pixelstore_attrib *packing )
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
- struct gl_renderbuffer *rb = fb->_DepthBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
GLint j;
+ GLubyte *dst, *map;
+ int dstStride, stride;
if (!rb)
return;
@@ -120,14 +122,24 @@ read_depth_pixels( struct gl_context *ctx,
if (fast_read_depth_pixels(ctx, x, y, width, height, type, pixels, packing))
return;
+ dstStride = _mesa_image_row_stride(packing, width, GL_DEPTH_COMPONENT, type);
+ dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, 0, 0);
+
+ ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+ &map, &stride);
+
/* General case (slower) */
for (j = 0; j < height; j++, y++) {
GLfloat depthValues[MAX_WIDTH];
- GLvoid *dest = _mesa_image_address2d(packing, pixels, width, height,
- GL_DEPTH_COMPONENT, type, j, 0);
- _swrast_read_depth_span_float(ctx, rb, width, x, y, depthValues);
- _mesa_pack_depth_span(ctx, width, dest, type, depthValues, packing);
+ _mesa_unpack_float_z_row(rb->Format, width, map, depthValues);
+ _mesa_pack_depth_span(ctx, width, dst, type, depthValues, packing);
+
+ dst += dstStride;
+ map += stride;
}
+
+ ctx->Driver.UnmapRenderbuffer(ctx, rb);
}