From: Ben Skeggs Date: Fri, 21 Mar 2008 06:40:01 +0000 (+1100) Subject: nouveau: potentially delay buffer destruction X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=735ecf5de8587f8e52fe6ffc7f3f17403d140e23;p=mesa.git nouveau: potentially delay buffer destruction Rather than spinning waiting for the GPU to finish with the buffer, add a callback on the buffer's fence object instead. Gives a sizable performance increase in OA. --- diff --git a/src/gallium/winsys/dri/nouveau/nouveau_bo.c b/src/gallium/winsys/dri/nouveau/nouveau_bo.c index 40d4667c477..5dbb7d03744 100644 --- a/src/gallium/winsys/dri/nouveau/nouveau_bo.c +++ b/src/gallium/winsys/dri/nouveau/nouveau_bo.c @@ -206,6 +206,18 @@ nouveau_bo_ref(struct nouveau_device *dev, uint64_t handle, return 0; } +static void +nouveau_bo_del_cb(void *priv) +{ + struct nouveau_bo_priv *nvbo = priv; + + nouveau_fence_ref(NULL, &nvbo->fence); + nouveau_mem_free(nvbo->base.device, &nvbo->drm, &nvbo->map); + if (nvbo->sysmem && !nvbo->user) + free(nvbo->sysmem); + free(nvbo); +} + void nouveau_bo_del(struct nouveau_bo **bo) { @@ -220,11 +232,9 @@ nouveau_bo_del(struct nouveau_bo **bo) return; if (nvbo->fence) - nouveau_fence_wait(&nvbo->fence); - nouveau_mem_free(nvbo->base.device, &nvbo->drm, &nvbo->map); - if (nvbo->sysmem && !nvbo->user) - free(nvbo->sysmem); - free(nvbo); + nouveau_fence_signal_cb(nvbo->fence, nouveau_bo_del_cb, nvbo); + else + nouveau_bo_del_cb(nvbo); } int