Mesa (master): softpipe: some improvements to texture tile cache

Brian Paul brianp at kemper.freedesktop.org
Tue Feb 17 01:55:31 UTC 2009


Module: Mesa
Branch: master
Commit: 07855a1d766e21e4a017a5f9f19936ce5511e088
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=07855a1d766e21e4a017a5f9f19936ce5511e088

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Feb 16 18:45:58 2009 -0700

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 files 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 ab76009..bd5a672 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 ||




More information about the mesa-commit mailing list