diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 2 | ||||
-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 |
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 1d3f799f368..ff83dab0752 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 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; |