From 70eb7996f265f3634dabda078f13d1be3533cc65 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Oct 2007 09:37:26 -0600 Subject: Finish unifying the surface and texture tile caches. --- src/mesa/pipe/softpipe/sp_tile_cache.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/mesa/pipe/softpipe/sp_tile_cache.c') 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; -- cgit v1.2.3