diff options
author | Younes Manton <younes.m@gmail.com> | 2009-01-14 00:27:42 -0500 |
---|---|---|
committer | Younes Manton <younes.m@gmail.com> | 2009-01-18 21:40:10 -0500 |
commit | 7309e8057844bc67a81ce01a99a9cb62d36eda0b (patch) | |
tree | 29076e6070159232b42c362ad490f5e153b9055c | |
parent | 0521c2682a3249562ff6a3d6ab6c90d1d63b82a3 (diff) |
nouveau: Rename buffer on map if discardable, busy, and write-only.
-rw-r--r-- | src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c index 683710ee3c..5b3101fbba 100644 --- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c +++ b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c @@ -121,6 +121,21 @@ nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf, if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) map_flags |= NOUVEAU_BO_WR; + if (flags & PIPE_BUFFER_USAGE_DISCARD && + !(flags & PIPE_BUFFER_USAGE_CPU_READ) && + nouveau_bo_busy(nvbuf->bo, map_flags)) { + struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws; + struct nouveau_context *nv = nvpws->nv; + struct nouveau_device *dev = nv->nv_screen->device; + struct nouveau_bo *rename; + uint32_t flags = nouveau_flags_from_usage(nv, buf->usage); + + if (!nouveau_bo_new(dev, flags, buf->alignment, buf->size, &rename)) { + nouveau_bo_del(&nvbuf->bo); + nvbuf->bo = rename; + } + } + if (nouveau_bo_map(nvbuf->bo, map_flags)) return NULL; return nvbuf->bo->map; |