summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-10-03 13:45:24 -0600
committerBrian <[email protected]>2007-10-03 13:50:11 -0600
commita9f0330061471ba47beb2369884d7661b715722e (patch)
treea8a4aa83310fe9b378a0de6b23c2384fa2bbdc2a
parente6f4af6b236fcf077cef2ea74346fa9b97106b95 (diff)
basic support for reading GL_DEPTH_COMPONENT
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 98604e5b6b5..a82c4e526aa 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -86,7 +86,12 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
- strb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
+ if (format == GL_DEPTH_COMPONENT) {
+ strb = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
+ }
+ else {
+ strb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
+ }
if (!strb)
return;
@@ -98,6 +103,14 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
height, format, type, 0, 0);
dfStride = width * 4;
}
+#if 0
+ else if (format == GL_DEPTH_COMPONENT && type == GL_FLOAT) {
+ /* write tile(row) directly into user's buffer */
+ df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
+ height, format, type, 0, 0);
+ dfStride = width;
+ }
+#endif
else {
/* write tile(row) into temp row buffer */
df = (GLfloat *) temp;
@@ -122,8 +135,26 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
/* convert GLfloat to user's format/type */
GLvoid *dst = _mesa_image_address2d(&clippedPacking, dest, width,
height, format, type, i, 0);
- _mesa_pack_rgba_span_float(ctx, width, temp, format, type, dst,
- &clippedPacking, transferOps);
+ if (format == GL_DEPTH_COMPONENT) {
+ float z[MAX_WIDTH];
+ if (strb->surface->format == PIPE_FORMAT_S8_Z24) {
+ const double scale = 1.0 / ((1 << 24) - 1);
+ const uint *zs = (const uint *) temp;
+ uint k;
+ for (k = 0; k < width; k++) {
+ z[k] = (zs[k] & 0xffffff) * scale;
+ }
+ }
+ else {
+ assert(0);
+ }
+ _mesa_pack_depth_span(ctx, width, dst, type,
+ z, &clippedPacking);
+ }
+ else {
+ _mesa_pack_rgba_span_float(ctx, width, temp, format, type, dst,
+ &clippedPacking, transferOps);
+ }
}
}