From 2a7c39a21102f1c373f7415985ee8f31be4da40a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 23 Jul 2009 11:14:39 +0100 Subject: [PATCH] llvmpipe: avoid flushing depth buffer cache on swapbuffers There's no need to push out depth buffer contents on swapbuffers. Note that this change doesn't throw away depth buffer changes, it simply holds them in the cache over calls to swapbuffers. The hope is that swapbuffers will be followed by a clear() which means in that case we won't have to write the changes out. --- src/gallium/drivers/llvmpipe/lp_context.c | 5 +---- src/gallium/drivers/llvmpipe/lp_flush.c | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 8341cc1bc11..aa2159b8d5e 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -72,13 +72,10 @@ llvmpipe_unmap_transfers(struct llvmpipe_context *lp) { uint i; - for (i = 0; i < lp->framebuffer.nr_cbufs; i++) - lp_flush_tile_cache(lp->cbuf_cache[i]); - lp_flush_tile_cache(lp->zsbuf_cache); - for (i = 0; i < lp->framebuffer.nr_cbufs; i++) { lp_tile_cache_unmap_transfers(lp->cbuf_cache[i]); } + lp_tile_cache_unmap_transfers(lp->zsbuf_cache); } diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index f815e79003c..866d4fb0996 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -56,14 +56,16 @@ llvmpipe_flush( struct pipe_context *pipe, } } - if (flags & PIPE_FLUSH_RENDER_CACHE) { + if (flags & PIPE_FLUSH_SWAPBUFFERS) { + /* If this is a swapbuffers, just flush color buffers. + * + * The zbuffer changes are not discarded, but held in the cache + * in the hope that a later clear will wipe them out. + */ for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) if (llvmpipe->cbuf_cache[i]) lp_flush_tile_cache(llvmpipe->cbuf_cache[i]); - if (llvmpipe->zsbuf_cache) - lp_flush_tile_cache(llvmpipe->zsbuf_cache); - /* Need this call for hardware buffers before swapbuffers. * * there should probably be another/different flush-type function @@ -71,7 +73,15 @@ llvmpipe_flush( struct pipe_context *pipe, * to unmap surfaces when flushing. */ llvmpipe_unmap_transfers(llvmpipe); - + } + else if (flags & PIPE_FLUSH_RENDER_CACHE) { + for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) + if (llvmpipe->cbuf_cache[i]) + lp_flush_tile_cache(llvmpipe->cbuf_cache[i]); + + if (llvmpipe->zsbuf_cache) + lp_flush_tile_cache(llvmpipe->zsbuf_cache); + llvmpipe->dirty_render_cache = FALSE; } -- 2.30.2