Mesa (7.10): r600g: need to reference upload buffer as the might still live accross flush

Jerome Glisse glisse at kemper.freedesktop.org
Thu Jan 6 20:55:51 UTC 2011


Module: Mesa
Branch: 7.10
Commit: 0fc205152c0706cff0eb9835e6a249376581366d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fc205152c0706cff0eb9835e6a249376581366d

Author: Jerome Glisse <jglisse at redhat.com>
Date:   Wed Dec 15 12:07:09 2010 -0500

r600g: need to reference upload buffer as the might still live accross flush

Can't get away from referencing upload buffer as after flush a vertex buffer
using the upload buffer might still be active. Likely need to simplify the
pipe_refence a bit so we don't waste so much cpu time in it.

candidates for 7.10 branch

Signed-off-by: Jerome Glisse <jglisse at redhat.com>

---

 src/gallium/drivers/r600/r600_buffer.c |    2 +-
 src/gallium/drivers/r600/r600_upload.c |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c
index 7d29f76..a17c54d 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -103,7 +103,7 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
 {
 	struct r600_resource_buffer *rbuffer = r600_buffer(buf);
 
-	if (!rbuffer->uploaded && rbuffer->r.bo) {
+	if (rbuffer->r.bo) {
 		r600_bo_reference((struct radeon*)screen->winsys, &rbuffer->r.bo, NULL);
 	}
 	rbuffer->r.bo = NULL;
diff --git a/src/gallium/drivers/r600/r600_upload.c b/src/gallium/drivers/r600/r600_upload.c
index ac72854..44102ff 100644
--- a/src/gallium/drivers/r600/r600_upload.c
+++ b/src/gallium/drivers/r600/r600_upload.c
@@ -69,6 +69,7 @@ void r600_upload_flush(struct r600_upload *upload)
 	upload->default_size = MAX2(upload->total_alloc_size, upload->default_size);
 	upload->total_alloc_size = 0;
 	upload->size = 0;
+	upload->offset = 0;
 	upload->ptr = NULL;
 	upload->buffer = NULL;
 }
@@ -105,7 +106,8 @@ int r600_upload_buffer(struct r600_upload *upload, unsigned offset,
 	memcpy(upload->ptr + upload->offset, (uint8_t *) in_ptr + offset, size);
 	*out_offset = upload->offset;
 	*out_size = upload->size;
-	*out_buffer = upload->buffer;
+	*out_buffer = NULL;
+	r600_bo_reference(upload->rctx->radeon, out_buffer, upload->buffer);
 	upload->offset += alloc_size;
 
 	return 0;




More information about the mesa-commit mailing list