summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe/sp_tile_cache.c
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-10-22 09:37:26 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-10-22 09:37:26 -0600
commit70eb7996f265f3634dabda078f13d1be3533cc65 (patch)
tree30148a72c347274cafa3386accb22aae4c1f9c7a /src/mesa/pipe/softpipe/sp_tile_cache.c
parentec3bd21c465f27d0a8e313e00338109d21019fc0 (diff)
Finish unifying the surface and texture tile caches.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_tile_cache.c')
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
index d88bce4619..1e287c91a4 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.c
@@ -129,7 +129,15 @@ void
sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
struct pipe_mipmap_tree *texture)
{
+ uint i;
+
tc->texture = texture;
+
+ /* mark as entries as invalid/empty */
+ /* XXX we should try to avoid this when the teximage hasn't changed */
+ for (i = 0; i < NUM_ENTRIES; i++) {
+ tc->entries[i].x = -1;
+ }
}
@@ -263,10 +271,10 @@ sp_get_cached_tile(struct softpipe_tile_cache *tc, int x, int y)
* This is basically a direct-map cache.
* XXX There's probably lots of ways in which we can improve this.
*/
-static uint
+static INLINE uint
tex_cache_pos(int x, int y, int z, int face, int level)
{
- uint entry = x + y * 2 + z * 4 + face + level;
+ uint entry = x + y * 5 + z * 4 + face + level;
return entry % NUM_ENTRIES;
}
@@ -275,19 +283,17 @@ tex_cache_pos(int x, int y, int z, int face, int level)
* Similar to sp_get_cached_tile() but for textures.
* Tiles are read-only and indexed with more params.
*/
-struct softpipe_cached_tile *
-sp_get_cached_tile_tex(struct softpipe_tile_cache *tc, int x, int y, int z,
+const struct softpipe_cached_tile *
+sp_get_cached_tile_tex(struct pipe_context *pipe,
+ struct softpipe_tile_cache *tc, int x, int y, int z,
int face, int level)
{
- struct pipe_context *pipe; /* XXX need this */
-
/* tile pos in framebuffer: */
const int tile_x = x & ~(TILE_SIZE - 1);
const int tile_y = y & ~(TILE_SIZE - 1);
-
/* cache pos/entry: */
- const int pos = tex_cache_pos(x / TILE_SIZE, y / TILE_SIZE,
- z, face, level);
+ const uint pos = tex_cache_pos(x / TILE_SIZE, y / TILE_SIZE, z,
+ face, level);
struct softpipe_cached_tile *tile = tc->entries + pos;
if (tile_x != tile->x ||
@@ -295,6 +301,7 @@ sp_get_cached_tile_tex(struct softpipe_tile_cache *tc, int x, int y, int z,
z != tile->z ||
face != tile->face ||
level != tile->level) {
+ /* XXX this call is a bit heavier than we'd like: */
struct pipe_surface *ps
= pipe->get_tex_surface(pipe, tc->texture, face, level, z);
@@ -303,6 +310,12 @@ sp_get_cached_tile_tex(struct softpipe_tile_cache *tc, int x, int y, int z,
(float *) tile->data.color);
pipe_surface_reference(&ps, NULL);
+
+ tile->x = tile_x;
+ tile->y = tile_y;
+ tile->z = z;
+ tile->face = face;
+ tile->level = level;
}
return tile;