summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-10-18 15:18:55 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-10-18 15:18:55 -0600
commit0007cd7ba0a61fcbcf9c9d19e014408be25ae496 (patch)
tree37199fc1c03f0c29cadc7072276113f5101d939d /src/mesa
parent5d39f4f9fdba4cd3333a39af583a73b85eb6bb74 (diff)
Alternate CopyPixels path based on get/put_tile().
For some drivers (like Xlib) it's not possible to treat the front/back color buffers as pipe_regions. So pipe->region_copy() won't work. Added a new state tracker field indicating if we can use regions for colorbuffer accesses. This should probably be re-considered someday...
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/x11/xm_api.c2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c42
-rw-r--r--src/mesa/state_tracker/st_context.c1
-rw-r--r--src/mesa/state_tracker/st_context.h6
4 files changed, 43 insertions, 8 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 1d3f799f36..ff83dab075 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -1603,6 +1603,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc;
mesaCtx->st->pipe->supported_formats = xmesa_supported_formats;
+ mesaCtx->st->haveFramebufferRegions = GL_FALSE;
+
/* special pipe->clear function */
mesaCtx->st->pipe->clear = xmesa_clear;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index b88b96e3b2..90f91c39b5 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1219,14 +1219,40 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
srcy = ctx->DrawBuffer->Height - srcy - height;
}
- /* copy source framebuffer region into mipmap/texture */
- pipe->region_copy(pipe,
- mt->region, /* dest */
- 0, /* dest_offset */
- 0, 0, /* destx/y */
- psRead->region,
- 0, /* src_offset */
- srcx, srcy, width, height);
+ /* For some drivers (like Xlib) it's not possible to treat the
+ * front/back color buffers as regions (they're XImages and Pixmaps).
+ * So, this var tells us if we can use region_copy here...
+ */
+ if (st->haveFramebufferRegions) {
+ /* copy source framebuffer region into mipmap/texture */
+ pipe->region_copy(pipe,
+ mt->region, /* dest */
+ 0, /* dest_offset */
+ 0, 0, /* destx/y */
+ psRead->region,
+ 0, /* src_offset */
+ srcx, srcy, width, height);
+ }
+ else {
+ /* alternate path using get/put_tile() */
+ struct pipe_surface *psTex;
+ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+
+ psTex = pipe->get_tex_surface(pipe, mt, 0, 0, 0);
+
+ (void) pipe->region_map(pipe, psRead->region);
+ (void) pipe->region_map(pipe, psTex->region);
+
+ psRead->get_tile(psRead, srcx, srcy, width, height, buf);
+ psTex->put_tile(psTex, 0, 0, width, height, buf);
+
+ pipe->region_unmap(pipe, psRead->region);
+ pipe->region_unmap(pipe, psTex->region);
+
+ pipe_surface_reference(&psTex, NULL);
+
+ free(buf);
+ }
/* draw textured quad */
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 09d9b1ea3b..8ced3f504c 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -90,6 +90,7 @@ struct st_context *st_create_context( GLcontext *ctx,
st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
+ st->haveFramebufferRegions = GL_TRUE;
#if 0
st_init_cb_clear( st );
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index b4ae041d36..bacc0b9b3f 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -111,6 +111,12 @@ struct st_context
char vendor[100];
char renderer[100];
+ /** Can we access the front/back color buffers as pipe_regions?
+ * We can't with the Xlib driver...
+ * This is a hack that should be fixed someday.
+ */
+ GLboolean haveFramebufferRegions;
+
/* State to be validated:
*/
struct st_tracked_state **atoms;