[Mesa-dev] [PATCH 17/21] r600g: don't share u_upload_mgr with u_vbuf, create its own

Marek Olšák maraeo at gmail.com
Wed Apr 11 08:38:51 PDT 2012


---
 src/gallium/drivers/r600/r600_pipe.c         |   10 ++++++++++
 src/gallium/drivers/r600/r600_pipe.h         |    1 +
 src/gallium/drivers/r600/r600_state_common.c |    6 +++---
 src/gallium/drivers/r600/r600_translate.c    |    2 +-
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 9c9fa4d..814274e 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -28,6 +28,7 @@
 #include "util/u_blitter.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_simple_shaders.h"
+#include "util/u_upload_mgr.h"
 #include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 #include "os/os_time.h"
@@ -194,6 +195,9 @@ static void r600_destroy_context(struct pipe_context *context)
 	if (rctx->vbuf_mgr) {
 		u_vbuf_destroy(rctx->vbuf_mgr);
 	}
+	if (rctx->uploader) {
+		u_upload_destroy(rctx->uploader);
+	}
 	util_slab_destroy(&rctx->pool_transfers);
 
 	r600_update_num_contexts(rctx->screen, -1);
@@ -304,6 +308,12 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 	if (!rctx->vbuf_mgr)
 		goto fail;
 
+        rctx->uploader = u_upload_create(&rctx->context, 1024 * 1024, 256,
+                                         PIPE_BIND_INDEX_BUFFER |
+                                         PIPE_BIND_CONSTANT_BUFFER);
+        if (!rctx->uploader)
+                goto fail;
+
 	rctx->blitter = util_blitter_create(&rctx->context);
 	if (rctx->blitter == NULL)
 		goto fail;
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index c4e0557..76b20b8 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -280,6 +280,7 @@ struct r600_context {
 	struct r600_textures_info	ps_samplers;
 
 	struct u_vbuf			*vbuf_mgr;
+	struct u_upload_mgr	        *uploader;
 	struct util_slab_mempool	pool_transfers;
 	boolean				have_depth_texture, have_depth_fb;
 
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 2a30470..9d44323 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -577,10 +577,10 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
 				tmpPtr[i] = bswap_32(((uint32_t *)ptr)[i]);
 			}
 
-			u_upload_data(rctx->vbuf_mgr->uploader, 0, size, tmpPtr, &cb->buffer_offset, &cb->buffer);
+			u_upload_data(rctx->uploader, 0, size, tmpPtr, &cb->buffer_offset, &cb->buffer);
 			free(tmpPtr);
 		} else {
-			u_upload_data(rctx->vbuf_mgr->uploader, 0, buffer->width0, ptr, &cb->buffer_offset, &cb->buffer);
+			u_upload_data(rctx->uploader, 0, buffer->width0, ptr, &cb->buffer_offset, &cb->buffer);
 		}
 	} else {
 		/* Setup the hw buffer. */
@@ -779,7 +779,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
 
 		ptr = ib.buffer->user_ptr;
 		if (ptr) {
-			u_upload_data(rctx->vbuf_mgr->uploader, 0, info.count * ib.index_size,
+			u_upload_data(rctx->uploader, 0, info.count * ib.index_size,
 				      ptr, &ib.offset, &ib.buffer);
 		}
 	} else {
diff --git a/src/gallium/drivers/r600/r600_translate.c b/src/gallium/drivers/r600/r600_translate.c
index a556782..af3b8ca 100644
--- a/src/gallium/drivers/r600/r600_translate.c
+++ b/src/gallium/drivers/r600/r600_translate.c
@@ -38,7 +38,7 @@ void r600_translate_index_buffer(struct r600_context *r600,
 
 	switch (ib->index_size) {
 	case 1:
-		u_upload_alloc(r600->vbuf_mgr->uploader, 0, count * 2,
+		u_upload_alloc(r600->uploader, 0, count * 2,
 			       &out_offset, &out_buffer, &ptr);
 
 		util_shorten_ubyte_elts_to_userptr(
-- 
1.7.5.4



More information about the mesa-dev mailing list