But when creating surfaces, adjust incoming flags from GPU->CPU usage.
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,
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 {
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);
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);
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) *
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;
* 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);
}
* 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.
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 ||
{
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);
}
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;