summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-05-01 11:28:47 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-05-01 12:00:45 +0100
commit27e46611f04108765fa99890822a474820d5c563 (patch)
tree1c4a98fc2895da0543e54c2f3a1989114e958ae1 /src/gallium
parentc9ed86a96483063f3d6789ed16645a3dca77d726 (diff)
softpipe: use CPU flags for mapping
But when creating surfaces, adjust incoming flags from GPU->CPU usage.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_surface.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c34
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c14
4 files changed, 44 insertions, 16 deletions
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 355c120d18..6c58f9909d 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -50,7 +50,7 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
for (i = 0; i < 2; i++) {
if (sp->constants[i].size)
sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
}
draw_set_mapped_constant_buffer(sp->draw,
@@ -133,14 +133,14 @@ softpipe_draw_elements(struct pipe_context *pipe,
void *buf
= pipe->winsys->buffer_map(pipe->winsys,
sp->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
}
/* Map index buffer, if present */
if (indexBuffer) {
void *mapped_indexes
= pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
}
else {
diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c
index b5cc053548..b82b1a8f37 100644
--- a/src/gallium/drivers/softpipe/sp_surface.c
+++ b/src/gallium/drivers/softpipe/sp_surface.c
@@ -49,11 +49,11 @@ sp_surface_copy(struct pipe_context *pipe,
assert( dst->cpp == src->cpp );
void *dst_map = pipe->screen->surface_map( pipe->screen,
dst,
- PIPE_BUFFER_USAGE_GPU_WRITE );
+ PIPE_BUFFER_USAGE_CPU_WRITE );
const void *src_map = pipe->screen->surface_map( pipe->screen,
src,
- PIPE_BUFFER_USAGE_GPU_READ );
+ PIPE_BUFFER_USAGE_CPU_READ );
assert(src_map && dst_map);
@@ -94,7 +94,7 @@ sp_surface_fill(struct pipe_context *pipe,
unsigned i, j;
void *dst_map = pipe->screen->surface_map( pipe->screen,
dst,
- PIPE_BUFFER_USAGE_GPU_WRITE );
+ PIPE_BUFFER_USAGE_CPU_WRITE );
assert(dst->pitch > 0);
assert(width <= dst->pitch);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index ee3fa994f9..2b31cd4f25 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -151,6 +151,23 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps->pitch = ps->width;
ps->offset = spt->level_offset[level];
ps->usage = usage;
+
+ /* Because we are softpipe, anything that the state tracker
+ * thought was going to be done with the GPU will actually get
+ * done with the CPU. Let's adjust the flags to take that into
+ * account.
+ */
+ if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE)
+ ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE;
+
+ if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
+ ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+
+
+ pipe_texture_reference(&ps->texture, pt);
+ ps->face = face;
+ ps->level = level;
+ ps->zslice = zslice;
if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
@@ -164,8 +181,18 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
if (usage & (PIPE_BUFFER_USAGE_CPU_WRITE |
PIPE_BUFFER_USAGE_GPU_WRITE)) {
- /* XXX if writing to the texture, invalidate the texcache entries!!! */
- assert(0);
+ /* XXX if writing to the texture, invalidate the texcache entries!!!
+ *
+ * Actually, no. Flushing dependent contexts is still done
+ * explicitly and separately. Hardware drivers won't insert
+ * FLUSH commands into a command stream at this point,
+ * neither should softpipe try to flush caches.
+ *
+ * Those contexts could be living in separate threads & doing
+ * all sorts of unrelated stuff... Context<->texture
+ * dependency tracking needs to happen elsewhere.
+ */
+ /* assert(0); */
}
}
return ps;
@@ -181,6 +208,7 @@ softpipe_tex_surface_release(struct pipe_screen *screen,
* where it would happen. For softpipe, nothing to do.
*/
assert ((*s)->texture);
+ pipe_texture_reference(&(*s)->texture, NULL);
screen->winsys->surface_release(screen->winsys, s);
}
@@ -206,7 +234,7 @@ softpipe_surface_map( struct pipe_screen *screen,
* of the map:
*/
if (surface->texture &&
- (flags & PIPE_BUFFER_USAGE_GPU_WRITE))
+ (flags & PIPE_BUFFER_USAGE_CPU_WRITE))
{
/* Do something to notify sharing contexts of a texture change.
* In softpipe, that would mean flushing the texture cache.
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index a3fd375a2d..142faf5074 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -165,8 +165,8 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
if (tc->surface) {
if (tc->surface_map) /* XXX: this is always NULL!? */
tc->surface_map = tc->screen->surface_map(tc->screen, tc->surface,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
ps->format == PIPE_FORMAT_Z16_UNORM ||
@@ -191,12 +191,12 @@ sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc)
{
if (tc->surface && !tc->surface_map)
tc->surface_map = tc->screen->surface_map(tc->screen, tc->surface,
- PIPE_BUFFER_USAGE_GPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_WRITE |
+ PIPE_BUFFER_USAGE_CPU_READ);
if (tc->tex_surf && !tc->tex_surf_map)
tc->tex_surf_map = tc->screen->surface_map(tc->screen, tc->tex_surf,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
}
@@ -523,9 +523,9 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
tc->screen->surface_unmap(tc->screen, tc->tex_surf);
tc->tex_surf = screen->get_tex_surface(screen, tc->texture, face, level, z,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
tc->tex_surf_map = screen->surface_map(screen, tc->tex_surf,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
tc->tex_face = face;
tc->tex_level = level;