From: Marek Olšák Date: Tue, 8 Feb 2011 14:21:35 +0000 (+0100) Subject: r600g: use the same upload buffer for vertices, indices, and constants X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=467023e8080489abeff53e18ac83560eaf851827;p=mesa.git r600g: use the same upload buffer for vertices, indices, and constants This should reduce memory consumption. --- diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c index 0a0e3db854a..7483a5292bc 100644 --- a/src/gallium/drivers/r600/r600_buffer.c +++ b/src/gallium/drivers/r600/r600_buffer.c @@ -207,7 +207,7 @@ void r600_upload_index_buffer(struct r600_pipe_context *rctx, struct r600_drawl struct r600_resource_buffer *rbuffer = r600_buffer(draw->index_buffer); boolean flushed; - u_upload_data(rctx->upload_ib, 0, + u_upload_data(rctx->vbuf_mgr->uploader, 0, draw->info.count * draw->index_size, rbuffer->r.b.user_ptr, &draw->index_buffer_offset, @@ -224,7 +224,7 @@ void r600_upload_const_buffer(struct r600_pipe_context *rctx, struct r600_resour *rbuffer = NULL; - u_upload_data(rctx->upload_const, 0, size, ptr, const_offset, + u_upload_data(rctx->vbuf_mgr->uploader, 0, size, ptr, const_offset, (struct pipe_resource**)rbuffer, &flushed); } else { *const_offset = 0; diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 9826bf42acc..a7c19b09275 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -69,12 +69,10 @@ static void r600_flush(struct pipe_context *ctx, unsigned flags, #endif r600_context_flush(&rctx->ctx); - /* XXX These shouldn't be really necessary, but removing them breaks some tests. + /* XXX This shouldn't be really necessary, but removing it breaks some tests. * Needless buffer reallocations may significantly increase memory consumption, - * so getting rid of these 3 calls is important. */ + * so getting rid of this call is important. */ u_upload_flush(rctx->vbuf_mgr->uploader); - u_upload_flush(rctx->upload_ib); - u_upload_flush(rctx->upload_const); } static void r600_destroy_context(struct pipe_context *context) @@ -91,8 +89,6 @@ static void r600_destroy_context(struct pipe_context *context) free(rctx->states[i]); } - u_upload_destroy(rctx->upload_ib); - u_upload_destroy(rctx->upload_const); u_vbuf_mgr_destroy(rctx->vbuf_mgr); FREE(rctx); @@ -165,28 +161,16 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void return NULL; } - rctx->vbuf_mgr = u_vbuf_mgr_create(&rctx->context, 1024 * 1024, 16, - PIPE_BIND_VERTEX_BUFFER, + rctx->vbuf_mgr = u_vbuf_mgr_create(&rctx->context, 1024 * 1024, 256, + PIPE_BIND_VERTEX_BUFFER | + PIPE_BIND_INDEX_BUFFER | + PIPE_BIND_CONSTANT_BUFFER, U_VERTEX_FETCH_BYTE_ALIGNED); if (!rctx->vbuf_mgr) { r600_destroy_context(&rctx->context); return NULL; } - rctx->upload_ib = u_upload_create(&rctx->context, 128 * 1024, 16, - PIPE_BIND_INDEX_BUFFER); - if (rctx->upload_ib == NULL) { - r600_destroy_context(&rctx->context); - return NULL; - } - - rctx->upload_const = u_upload_create(&rctx->context, 1024 * 1024, 256, - PIPE_BIND_CONSTANT_BUFFER); - if (rctx->upload_const == NULL) { - r600_destroy_context(&rctx->context); - return NULL; - } - rctx->blitter = util_blitter_create(&rctx->context); if (rctx->blitter == NULL) { FREE(rctx); diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index b7ea6de3c7c..71d9647508b 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -151,9 +151,7 @@ struct r600_pipe_context { bool flatshade; struct r600_textures_info ps_samplers; - struct u_vbuf_mgr *vbuf_mgr; - struct u_upload_mgr *upload_ib; - struct u_upload_mgr *upload_const; + struct u_vbuf_mgr *vbuf_mgr; bool blit; }; diff --git a/src/gallium/drivers/r600/r600_translate.c b/src/gallium/drivers/r600/r600_translate.c index a980eac95e0..7482d15e12f 100644 --- a/src/gallium/drivers/r600/r600_translate.c +++ b/src/gallium/drivers/r600/r600_translate.c @@ -41,7 +41,7 @@ void r600_translate_index_buffer(struct r600_pipe_context *r600, switch (*index_size) { case 1: - u_upload_alloc(r600->upload_ib, 0, count * 2, + u_upload_alloc(r600->vbuf_mgr->uploader, 0, count * 2, &out_offset, &out_buffer, &flushed, &ptr); util_shorten_ubyte_elts_to_userptr(