summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_readpixels.c
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-04-15 13:23:23 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-04-15 13:23:23 +1000
commit276e177dfb644c60af6247598cda6c1c49dfea7b (patch)
treedac9407ee5e6cb67af67d8b52603ab8e2d5312ae /src/mesa/state_tracker/st_cb_readpixels.c
parent7f811f2c42937f254ae1b11e5b0ece765a8ea31b (diff)
parentd3878b070b7b5084526b65499737cc686a6039b6 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/mesa/state_tracker/st_cb_readpixels.c')
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 2bcc8c99fb..1fef55b844 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -129,6 +129,34 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
/**
+ * Return renderbuffer to use for reading color pixels for glRead/CopyPixel
+ * commands.
+ * Special care is needed for the front buffer.
+ */
+struct st_renderbuffer *
+st_get_color_read_renderbuffer(GLcontext *ctx)
+{
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct st_renderbuffer *strb =
+ st_renderbuffer(fb->_ColorReadBuffer);
+ struct st_renderbuffer *front =
+ st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+
+ if (strb == front
+ && ctx->st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) {
+ /* reading from front color buffer, which is a logical copy of the
+ * back color buffer.
+ */
+ struct st_renderbuffer *back =
+ st_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+ strb = back;
+ }
+
+ return strb;
+}
+
+
+/**
* Do glReadPixels by getting rows from the framebuffer surface with
* get_tile(). Convert to requested format/type with Mesa image routines.
* Image transfer ops are done in software too.
@@ -173,12 +201,13 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
strb = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
}
else {
- strb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
+ /* Read color buffer */
+ strb = st_get_color_read_renderbuffer(ctx);
}
+
if (!strb)
return;
-
if (format == GL_RGBA && type == GL_FLOAT) {
/* write tile(row) directly into user's buffer */
df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
@@ -240,7 +269,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
else if (strb->surface->format == PIPE_FORMAT_Z16_UNORM) {
for (i = 0; i < height; i++) {
- GLshort ztemp[MAX_WIDTH], j;
+ GLushort ztemp[MAX_WIDTH], j;
GLfloat zfloat[MAX_WIDTH];
const double scale = 1.0 / 0xffff;
pipe_get_tile_raw(pipe, strb->surface, x, y, width, 1, ztemp, 0);