diff options
author | Eric Anholt <[email protected]> | 2011-10-11 17:07:37 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-11-03 23:29:52 -0700 |
commit | ff27e058bc93338ef0dbe322ab4e588ea4bbec0d (patch) | |
tree | 1281874e1016191ba644cbcc37b60917dc928481 /src/mesa/swrast | |
parent | 492d223590569448c5666d421444102b50dda90d (diff) |
swrast: Directly map the stencil buffer in read_stencil_pixels.
This avoids going through the wrapper that has to rewrite the data for
packed depth/stencil. This isn't done in _swrast_read_stencil_span
because we don't want to map/unmap for each span.
v2: Move the unpack code to format_unpack.c.
v3: Fix signed/unsigned comparison.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_readpix.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 187c27e4ece..6351ec123ea 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -142,8 +142,10 @@ read_stencil_pixels( struct gl_context *ctx, const struct gl_pixelstore_attrib *packing ) { struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->_StencilBuffer; + struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; GLint j; + GLubyte *map; + GLint stride; if (!rb) return; @@ -151,18 +153,24 @@ read_stencil_pixels( struct gl_context *ctx, /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); + ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, + &map, &stride); + /* process image row by row */ - for (j=0;j<height;j++,y++) { + for (j = 0; j < height; j++) { GLvoid *dest; GLstencil stencil[MAX_WIDTH]; - _swrast_read_stencil_span(ctx, rb, width, x, y, stencil); - + _mesa_unpack_ubyte_stencil_row(rb->Format, width, map, stencil); dest = _mesa_image_address2d(packing, pixels, width, height, GL_STENCIL_INDEX, type, j, 0); _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing); + + map += stride; } + + ctx->Driver.UnmapRenderbuffer(ctx, rb); } |