[Mesa-dev] [PATCH 05/17] swrast: Switch the remaining depth/stencil readpixels path to MapRenderbuffer.
Eric Anholt
eric at anholt.net
Tue Nov 1 16:17:30 PDT 2011
Reviewed-by: Brian Paul <brianp at vmware.com>
---
src/mesa/swrast/s_readpix.c | 72 +++++++++++++++++++++++++------------------
1 files changed, 42 insertions(+), 30 deletions(-)
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 8559ab7..a372846 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -450,6 +450,45 @@ fast_read_depth_stencil_pixels_separate(struct gl_context *ctx,
return GL_TRUE;
}
+static void
+slow_read_depth_stencil_pixels_separate(struct gl_context *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLubyte *dst, int dstStride)
+{
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ struct gl_renderbuffer *stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ GLubyte *depthMap, *stencilMap;
+ int depthStride, stencilStride, j;
+
+ ctx->Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height,
+ GL_MAP_READ_BIT, &depthMap, &depthStride);
+ ctx->Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height,
+ GL_MAP_READ_BIT, &stencilMap, &stencilStride);
+
+ for (j = 0; j < height; j++) {
+ GLstencil stencilVals[MAX_WIDTH];
+ GLfloat depthVals[MAX_WIDTH];
+
+ _mesa_unpack_float_z_row(depthRb->Format, width, depthMap, depthVals);
+ _mesa_unpack_ubyte_stencil_row(stencilRb->Format, width,
+ stencilMap, stencilVals);
+
+ _mesa_pack_depth_stencil_span(ctx, width, type, (GLuint *)dst,
+ depthVals, stencilVals, packing);
+
+ depthMap += depthStride;
+ stencilMap += stencilStride;
+ dst += dstStride;
+ }
+
+ ctx->Driver.UnmapRenderbuffer(ctx, depthRb);
+ ctx->Driver.UnmapRenderbuffer(ctx, stencilRb);
+}
+
/**
* Read combined depth/stencil values.
@@ -467,16 +506,9 @@ read_depth_stencil_pixels(struct gl_context *ctx,
= ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
const GLboolean stencilTransfer = ctx->Pixel.IndexShift
|| ctx->Pixel.IndexOffset || ctx->Pixel.MapStencilFlag;
- struct gl_renderbuffer *depthRb, *stencilRb;
GLubyte *dst;
int dstStride;
- depthRb = ctx->ReadBuffer->_DepthBuffer;
- stencilRb = ctx->ReadBuffer->_StencilBuffer;
-
- if (!depthRb || !stencilRb)
- return;
-
dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
width, height,
GL_DEPTH_STENCIL_EXT,
@@ -496,29 +528,9 @@ read_depth_stencil_pixels(struct gl_context *ctx,
return;
}
- /* Reading GL_DEPTH_STENCIL pixels from separate depth/stencil buffers,
- * or we need pixel transfer.
- */
- {
- GLint i;
-
- for (i = 0; i < height; i++) {
- GLstencil stencilVals[MAX_WIDTH];
- GLuint *depthStencilDst = (GLuint *) (dst + dstStride * i);
-
- _swrast_read_stencil_span(ctx, stencilRb, width,
- x, y + i, stencilVals);
-
- {
- /* general case */
- GLfloat depthVals[MAX_WIDTH];
- _swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
- depthVals);
- _mesa_pack_depth_stencil_span(ctx, width, type, depthStencilDst,
- depthVals, stencilVals, packing);
- }
- }
- }
+ slow_read_depth_stencil_pixels_separate(ctx, x, y, width, height,
+ type, packing,
+ dst, dstStride);
}
--
1.7.7
More information about the mesa-dev
mailing list