summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-04-06 15:31:58 -0600
committerBrian Paul <brianp@vmware.com>2009-04-06 15:31:58 -0600
commitf4d744af24e07103f0f297b485f3dbca1fb7bc3b (patch)
treeb4d843742a65ff2739cdbe388703e64c623e17b1 /src
parent87c356a222bb97ecf9b04e8d509b103199159b11 (diff)
softpipe: clean up the buffer clear and tile cache code a little
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c46
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.h3
3 files changed, 15 insertions, 39 deletions
diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c
index f72c6c63e7..fa59277438 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -65,7 +65,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
util_pack_color(rgba, ps->format, &cv);
- sp_tile_cache_clear(softpipe->cbuf_cache[i], cv);
+ sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, cv);
#if !TILE_CLEAR_OPTIMIZATION
/* non-cached surface */
@@ -75,10 +75,11 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+ static const float zero[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
cv = util_pack_z_stencil(ps->format, depth, stencil);
- sp_tile_cache_clear(softpipe->zsbuf_cache, cv);
+ sp_tile_cache_clear(softpipe->zsbuf_cache, zero, cv);
#if !TILE_CLEAR_OPTIMIZATION
/* non-cached surface */
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index fd1097f41c..1f9b8f1f4f 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -57,9 +57,9 @@ struct softpipe_tile_cache
struct pipe_texture *texture; /**< if caching a texture */
struct softpipe_cached_tile entries[NUM_ENTRIES];
uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
- float clear_color[4];
- uint clear_val;
- boolean depth_stencil; /** Is the surface a depth/stencil format? */
+ float clear_color[4]; /**< for color bufs */
+ uint clear_val; /**< for z+stencil, or packed color clear value */
+ boolean depth_stencil; /**< Is the surface a depth/stencil format? */
struct pipe_transfer *tex_trans;
void *tex_trans_map;
@@ -599,43 +599,17 @@ sp_get_cached_tile_tex(struct softpipe_context *sp,
* Save the color and set a 'clearflag' for each tile of the screen.
*/
void
-sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue)
+sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba,
+ uint clearValue)
{
- uint r, g, b, a;
uint pos;
- tc->clear_val = clearValue;
-
- switch (tc->transfer->format) {
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- case PIPE_FORMAT_R8G8B8X8_UNORM:
- r = (clearValue >> 24) & 0xff;
- g = (clearValue >> 16) & 0xff;
- b = (clearValue >> 8) & 0xff;
- a = (clearValue ) & 0xff;
- break;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- r = (clearValue >> 16) & 0xff;
- g = (clearValue >> 8) & 0xff;
- b = (clearValue ) & 0xff;
- a = (clearValue >> 24) & 0xff;
- break;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- case PIPE_FORMAT_B8G8R8X8_UNORM:
- r = (clearValue >> 8) & 0xff;
- g = (clearValue >> 16) & 0xff;
- b = (clearValue >> 24) & 0xff;
- a = (clearValue ) & 0xff;
- break;
- default:
- r = g = b = a = 0;
- }
+ tc->clear_color[0] = rgba[0];
+ tc->clear_color[1] = rgba[1];
+ tc->clear_color[2] = rgba[2];
+ tc->clear_color[3] = rgba[3];
- tc->clear_color[0] = r / 255.0f;
- tc->clear_color[1] = g / 255.0f;
- tc->clear_color[2] = b / 255.0f;
- tc->clear_color[3] = a / 255.0f;
+ tc->clear_val = clearValue;
#if TILE_CLEAR_OPTIMIZATION
/* set flags to indicate all the tiles are cleared */
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h
index 9ac3fdda94..8f247d0e58 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.h
@@ -89,7 +89,8 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue);
+sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba,
+ uint clearValue);
extern struct softpipe_cached_tile *
sp_get_cached_tile(struct softpipe_context *softpipe,