diff options
author | Brian <[email protected]> | 2007-10-18 15:18:55 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-10-18 15:18:55 -0600 |
commit | 0007cd7ba0a61fcbcf9c9d19e014408be25ae496 (patch) | |
tree | 37199fc1c03f0c29cadc7072276113f5101d939d /src/mesa/state_tracker | |
parent | 5d39f4f9fdba4cd3333a39af583a73b85eb6bb74 (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/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 42 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 6 |
3 files changed, 41 insertions, 8 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index b88b96e3b2f..90f91c39b5d 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 09d9b1ea3b4..8ced3f504c2 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 b4ae041d36c..bacc0b9b3ff 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; |