struct softpipe_tile_cache
{
struct softpipe_surface *surface; /**< the surface we're caching */
+ struct pipe_mipmap_tree *texture; /**< if caching a texture */
struct softpipe_cached_tile entries[NUM_ENTRIES];
uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
};
}
+void
+sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
+ struct pipe_mipmap_tree *texture)
+{
+ tc->texture = texture;
+}
void
}
+/**
+ * Given the texture face, level, zslice, x and y values, compute
+ * the cache entry position/index where we'd hope to find the
+ * cached texture tile.
+ * This is basically a direct-map cache.
+ * XXX There's probably lots of ways in which we can improve this.
+ */
+static uint
+tex_cache_pos(int x, int y, int z, int face, int level)
+{
+ uint entry = x + y * 2 + z * 4 + face + level;
+ return entry % NUM_ENTRIES;
+}
+
+
+/**
+ * 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,
+ 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);
+ struct softpipe_cached_tile *tile = tc->entries + pos;
+
+ if (tile_x != tile->x ||
+ tile_y != tile->y ||
+ z != tile->z ||
+ face != tile->face ||
+ level != tile->level) {
+ struct pipe_surface *ps
+ = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
+
+ ps->get_tile(ps,
+ tile_x, tile_y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
+
+ pipe_surface_reference(&ps, NULL);
+ }
+
+ return tile;
+}
+
+
+
void
sp_clear_tile_cache(struct softpipe_tile_cache *tc, unsigned clearval)
{
struct softpipe_cached_tile
{
- int x, y; /** pos of tile in window coords */
+ int x, y; /**< pos of tile in window coords */
+ int z, face, level; /**< Extra texture indexes */
union {
float color[TILE_SIZE][TILE_SIZE][4];
uint depth32[TILE_SIZE][TILE_SIZE];
sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
struct softpipe_surface *sps);
+extern void
+sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
+ struct pipe_mipmap_tree *texture);
+
extern void
sp_flush_tile_cache(struct softpipe_tile_cache *tc);
extern struct softpipe_cached_tile *
sp_get_cached_tile(struct softpipe_tile_cache *tc, int x, int y);
+extern struct softpipe_cached_tile *
+sp_get_cached_tile_tex(struct softpipe_tile_cache *tc, int x, int y, int z,
+ int face, int level);
+
#endif /* SP_TILE_CACHE_H */