mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
softpipe: use CPU flags for mapping
But when creating surfaces, adjust incoming flags from GPU->CPU usage.
This commit is contained in:
parent
c9ed86a964
commit
27e46611f0
4 changed files with 44 additions and 16 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue