r600g: use the same upload buffer for vertices, indices, and constants
authorMarek Olšák <maraeo@gmail.com>
Tue, 8 Feb 2011 14:21:35 +0000 (15:21 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 8 Feb 2011 15:35:02 +0000 (16:35 +0100)
This should reduce memory consumption.

src/gallium/drivers/r600/r600_buffer.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_translate.c

index 0a0e3db854a02421eca526dc503c357eb9fbcf68..7483a5292bc02c6bd47004574c265895716c11dd 100644 (file)
@@ -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;
index 9826bf42acc789b9f6cf517d2d2b28e1d253f0bd..a7c19b09275643fb8324f00011f5193723cb7f3f 100644 (file)
@@ -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);
index b7ea6de3c7c6608db52dfa50a82c997ab7076db2..71d9647508bfa9681b7b4a8b79ee3f56e4e9b247 100644 (file)
@@ -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;
 };
 
index a980eac95e048a1516c739dfac9cdfdf8028b5b7..7482d15e12fb629a5cd152fa096bfaa27a3d8646 100644 (file)
@@ -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(