From 07855a1d766e21e4a017a5f9f19936ce5511e088 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 16 Feb 2009 18:45:58 -0700 Subject: softpipe: some improvements to texture tile cache Use a somewhat better function in tex_cache_pos() to get better caching. Increase number of cache entries to 50. Also fix a texture invalidation bug. If texture is marked as modified, invalidate all texture tiles. --- src/gallium/drivers/softpipe/sp_tile_cache.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index ab76009375..bd5a672f77 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -40,7 +40,7 @@ #include "sp_texture.h" #include "sp_tile_cache.h" -#define NUM_ENTRIES 32 +#define NUM_ENTRIES 50 /** XXX move these */ @@ -484,7 +484,7 @@ sp_get_cached_tile(struct softpipe_context *softpipe, static INLINE uint tex_cache_pos(int x, int y, int z, int face, int level) { - uint entry = x + y * 5 + z * 4 + face + level; + uint entry = x + y * 9 + z * 3 + face + level * 7; return entry % NUM_ENTRIES; } @@ -510,8 +510,12 @@ sp_get_cached_tile_tex(struct softpipe_context *sp, if (tc->texture) { struct softpipe_texture *spt = softpipe_texture(tc->texture); if (spt->modified) { - /* texture was modified, force a cache reload */ - tile->x = -1; + /* texture was modified, invalidate all cached tiles */ + uint p; + for (p = 0; p < NUM_ENTRIES; p++) { + tile = tc->entries + p; + tile->x = -1; + } spt->modified = FALSE; } } @@ -523,6 +527,10 @@ sp_get_cached_tile_tex(struct softpipe_context *sp, level != tile->level) { /* cache miss */ +#if 0 + printf("miss at %u x=%d y=%d z=%d face=%d level=%d\n", pos, + x/TILE_SIZE, y/TILE_SIZE, z, face, level); +#endif /* check if we need to get a new surface */ if (!tc->tex_surf || tc->tex_face != face || -- cgit v1.2.3