summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe/sp_tile_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_tile_cache.c')
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
index 1dbcc5aadd..d6f60807e6 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.c
@@ -49,6 +49,7 @@
struct softpipe_tile_cache
{
struct pipe_surface *surface; /**< the surface we're caching */
+ void *surface_map;
struct pipe_texture *texture; /**< if caching a texture */
struct softpipe_cached_tile entries[NUM_ENTRIES];
uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
@@ -57,6 +58,7 @@ struct softpipe_tile_cache
boolean depth_stencil; /** Is the surface a depth/stencil format? */
struct pipe_surface *tex_surf;
+ void *tex_surf_map;
int tex_face, tex_level, tex_z;
struct softpipe_cached_tile tile; /**< scratch tile for clears */
@@ -150,7 +152,7 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
{
assert(!tc->texture);
- if (tc->surface && tc->surface->map) {
+ if (tc->surface_map) {
/*assert(tc->surface != ps);*/
pipe_surface_unmap(tc->surface);
}
@@ -158,8 +160,8 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
pipe_surface_reference(&tc->surface, ps);
if (ps) {
- if (!ps->map)
- pipe_surface_map(ps);
+ if (tc->surface_map)
+ tc->surface_map = pipe_surface_map(ps);
tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
ps->format == PIPE_FORMAT_Z16_UNORM ||
@@ -179,6 +181,32 @@ sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
}
+void
+sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc)
+{
+ if (tc->surface && !tc->surface_map)
+ tc->surface_map = pipe_surface_map(tc->surface);
+
+ if (tc->tex_surf && !tc->tex_surf_map)
+ tc->tex_surf_map = pipe_surface_map(tc->tex_surf);
+}
+
+
+void
+sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc)
+{
+ if (tc->surface_map) {
+ pipe_surface_unmap(tc->surface);
+ tc->surface_map = NULL;
+ }
+
+ if (tc->tex_surf_map) {
+ pipe_surface_unmap(tc->tex_surf);
+ tc->tex_surf_map = NULL;
+ }
+}
+
+
/**
* Specify the texture to cache.
*/
@@ -192,8 +220,10 @@ sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
tc->texture = texture;
- if (tc->tex_surf && tc->tex_surf->map)
+ if (tc->tex_surf_map) {
pipe_surface_unmap(tc->tex_surf);
+ tc->tex_surf_map = NULL;
+ }
pipe_surface_reference(&tc->tex_surf, NULL);
/* mark as entries as invalid/empty */
@@ -330,9 +360,6 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
if (!ps || !ps->buffer)
return;
- if (!ps->map)
- pipe_surface_map(ps);
-
for (pos = 0; pos < NUM_ENTRIES; pos++) {
struct softpipe_cached_tile *tile = tc->entries + pos;
if (tile->x >= 0) {
@@ -475,11 +502,11 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
tc->tex_z != z) {
/* get new surface (view into texture) */
- if (tc->tex_surf && tc->tex_surf->map)
+ if (tc->tex_surf_map)
pipe_surface_unmap(tc->tex_surf);
tc->tex_surf = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
- pipe_surface_map(tc->tex_surf);
+ tc->tex_surf_map = pipe_surface_map(tc->tex_surf);
tc->tex_face = face;
tc->tex_level = level;