Mesa (master): nv50: delay uploads until transfer object is destroyed

Ben Skeggs darktama at kemper.freedesktop.org
Sun Feb 22 05:48:27 UTC 2009


Module: Mesa
Branch: master
Commit: e5e255a4062bd96390a3eaa3c83aa40001b6de95
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5e255a4062bd96390a3eaa3c83aa40001b6de95

Author: Ben Skeggs <bskeggs at redhat.com>
Date:   Sun Feb 22 15:38:59 2009 +1000

nv50: delay uploads until transfer object is destroyed

It's possible a state tracker will map/unmap a transfer object many times.
Delaying upload until the object is destroyed will prevent unnecessary
uploads to the GPU.

Also fixing a typo here, was unmapping the wrong buffer on transfer_unmap!

---

 src/gallium/drivers/nv50/nv50_transfer.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index b025e5d..a00c999 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -162,11 +162,23 @@ nv50_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
 {
 	struct pipe_transfer *ptx = *pptx;
 	struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
+	struct nv50_miptree *mt = nv50_miptree(ptx->texture);
 
 	*pptx = NULL;
 	if (--ptx->refcount)
 		return;
 
+	if (ptx->usage != PIPE_TRANSFER_READ) {
+		nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
+					0, 0, tx->base.width, tx->base.height,
+					mt->buffer, tx->level_pitch,
+					tx->level_x, tx->level_y,
+					tx->level_width, tx->level_height,
+					tx->base.block.size, tx->base.width,
+					tx->base.height, NOUVEAU_BO_GART,
+					NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
+	}
+
 	pipe_buffer_reference(pscreen, &tx->buffer, NULL);
 	pipe_texture_reference(&ptx->texture, NULL);
 	FREE(ptx);
@@ -190,20 +202,8 @@ static void
 nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
 {
 	struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
-	struct nv50_miptree *mt = nv50_miptree(ptx->texture);
-
-	if (ptx->usage != PIPE_TRANSFER_READ) {
-		nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
-					0, 0, tx->base.width, tx->base.height,
-					mt->buffer, tx->level_pitch,
-					tx->level_x, tx->level_y,
-					tx->level_width, tx->level_height,
-					tx->base.block.size, tx->base.width,
-					tx->base.height, NOUVEAU_BO_GART,
-					NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
-	}
 
-	pipe_buffer_unmap(pscreen, mt->buffer);
+	pipe_buffer_unmap(pscreen, tx->buffer);
 }
 
 void




More information about the mesa-commit mailing list