Finish unifying the surface and texture tile caches.

This commit is contained in:
Brian
2007-10-22 09:37:26 -06:00
parent ec3bd21c46
commit 70eb7996f2
8 changed files with 72 additions and 118 deletions

View File

@@ -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;