summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-12-07 21:21:58 -0700
committerBen Skeggs <skeggsb@gmail.com>2007-12-09 12:05:28 +1100
commit274a3d9cb6a196c1b191769f581915cf5f8dccfe (patch)
tree2efc7edf97559ef9ad8c3a13e744c7a257038a05
parent8c1c222b6ded06e40c044f4dee4550005ba620f9 (diff)
Try to reduce the frequency of calls to pipe->get_tex_surface()
Save the surface info in the tile cache and re-use whenever possible.
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
index 13774e6c8f..fadd169f5d 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.c
@@ -55,6 +55,9 @@ struct softpipe_tile_cache
float clear_color[4];
uint clear_val;
boolean depth_stencil; /** Is the surface a depth/stencil format? */
+
+ struct pipe_surface *tex_surf;
+ int tex_face, tex_level, tex_z;
};
@@ -179,11 +182,17 @@ sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
tc->texture = texture;
+ if (tc->tex_surf && tc->tex_surf->map)
+ pipe_surface_unmap(tc->tex_surf);
+ pipe_surface_reference(&tc->tex_surf, NULL);
+
/* 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;
}
+
+ tc->tex_face = -1; /* any invalid value here */
}
@@ -448,19 +457,33 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
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);
+ /* cache miss */
- pipe_surface_map(ps);
+ /* check if we need to get a new surface */
+ if (!tc->tex_surf ||
+ tc->tex_face != face ||
+ tc->tex_level != level ||
+ tc->tex_z != z) {
+ /* get new surface (view into texture) */
+ struct pipe_surface *ps;
- pipe->get_tile_rgba(pipe, ps,
- tile_x, tile_y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
+ if (tc->tex_surf && tc->tex_surf->map)
+ pipe_surface_unmap(tc->tex_surf);
- pipe_surface_unmap(ps);
- pipe_surface_reference(&ps, NULL);
+ ps = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
+ pipe_surface_reference(&tc->tex_surf, ps);
+ pipe_surface_map(ps);
+
+ tc->tex_face = face;
+ tc->tex_level = level;
+ tc->tex_z = z;
+ }
+
+ /* get tile from the surface (view into texture) */
+ pipe->get_tile_rgba(pipe, tc->tex_surf,
+ tile_x, tile_y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
tile->x = tile_x;
tile->y = tile_y;
tile->z = z;