mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 09:30:11 +01:00
Start implementing cache routines for textures.
First step to consolidating surface/texture caching...
This commit is contained in:
parent
c2322333b8
commit
b3204c2aff
2 changed files with 71 additions and 1 deletions
|
|
@ -49,6 +49,7 @@
|
|||
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];
|
||||
};
|
||||
|
|
@ -124,6 +125,12 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
|
||||
struct pipe_mipmap_tree *texture)
|
||||
{
|
||||
tc->texture = texture;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
|
@ -249,6 +256,60 @@ sp_get_cached_tile(struct softpipe_tile_cache *tc, int x, int y)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ struct softpipe_tile_cache;
|
|||
|
||||
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];
|
||||
|
|
@ -65,6 +66,10 @@ extern void
|
|||
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);
|
||||
|
||||
|
|
@ -74,6 +79,10 @@ sp_clear_tile_cache(struct softpipe_tile_cache *tc, unsigned clearval);
|
|||
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 */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue