sna: Retain the GTT space used for an upload buffer

In order to retain the GTT space without keeping hold of the memory used
for the upload buffer, we have to create a new bo and copy the relevant
details across.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2011-08-29 16:47:48 +01:00
parent 28c8c5ca14
commit aafe03d3d1
1 changed files with 15 additions and 1 deletions

View File

@ -701,15 +701,29 @@ static void kgem_finish_partials(struct kgem *kgem)
continue;
}
list_del(&bo->base.list);
if (bo->write && bo->need_io) {
DBG(("%s: handle=%d, uploading %d/%d\n",
__FUNCTION__, bo->base.handle, bo->used, bo->alloc));
gem_write(kgem->fd, bo->base.handle,
0, bo->used, bo+1);
bo->need_io = 0;
/* transfer the handle to a minimum bo */
if (bo->base.refcnt == 1) {
struct kgem_bo *base = malloc(sizeof(*base));
if (base) {
memcpy(base, &bo->base, sizeof (*base));
list_init(&base->list);
list_replace(&bo->base.request,
&base->request);
free(bo);
bo = (struct kgem_partial_bo *)base;
}
}
}
list_del(&bo->base.list);
kgem_bo_unref(kgem, &bo->base);
}
}