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...
This commit is contained in:
Brian
2007-10-18 15:18:55 -06:00
parent 5d39f4f9fd
commit 0007cd7ba0
4 changed files with 43 additions and 8 deletions

View File

@@ -1603,6 +1603,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc;
mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; mesaCtx->st->pipe->supported_formats = xmesa_supported_formats;
mesaCtx->st->haveFramebufferRegions = GL_FALSE;
/* special pipe->clear function */ /* special pipe->clear function */
mesaCtx->st->pipe->clear = xmesa_clear; mesaCtx->st->pipe->clear = xmesa_clear;

View File

@@ -1219,6 +1219,11 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
srcy = ctx->DrawBuffer->Height - srcy - height; srcy = ctx->DrawBuffer->Height - srcy - 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 */ /* copy source framebuffer region into mipmap/texture */
pipe->region_copy(pipe, pipe->region_copy(pipe,
mt->region, /* dest */ mt->region, /* dest */
@@ -1227,6 +1232,27 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
psRead->region, psRead->region,
0, /* src_offset */ 0, /* src_offset */
srcx, srcy, width, height); 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 */ /* draw textured quad */

View File

@@ -90,6 +90,7 @@ struct st_context *st_create_context( GLcontext *ctx,
st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
st->haveFramebufferRegions = GL_TRUE;
#if 0 #if 0
st_init_cb_clear( st ); st_init_cb_clear( st );

View File

@@ -111,6 +111,12 @@ struct st_context
char vendor[100]; char vendor[100];
char renderer[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: /* State to be validated:
*/ */
struct st_tracked_state **atoms; struct st_tracked_state **atoms;