Mesa (gallium-0.2): nouveau: Rename buffer on map if discardable, busy, and write-only.

Younes Manton ymanton at kemper.freedesktop.org
Mon Jan 19 02:48:32 UTC 2009


Module: Mesa
Branch: gallium-0.2
Commit: 7309e8057844bc67a81ce01a99a9cb62d36eda0b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7309e8057844bc67a81ce01a99a9cb62d36eda0b

Author: Younes Manton <younes.m at gmail.com>
Date:   Wed Jan 14 00:27:42 2009 -0500

nouveau: Rename buffer on map if discardable, busy, and write-only.

---

 .../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 683710e..5b3101f 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;




More information about the mesa-commit mailing list