r300g: use the same upload buffer for vertices and indices
authorMarek Olšák <maraeo@gmail.com>
Tue, 8 Feb 2011 15:34:22 +0000 (16:34 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 8 Feb 2011 15:35:02 +0000 (16:35 +0100)
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_render_translate.c
src/gallium/drivers/r300/r300_screen_buffer.c

index 7e0c068ff3e56f2634dac1625a1af91351209b89..c6e03050fc719f46405aac3497b5d82ac2d048ee 100644 (file)
@@ -104,8 +104,6 @@ static void r300_destroy_context(struct pipe_context* context)
 
     if (r300->vbuf_mgr)
         u_vbuf_mgr_destroy(r300->vbuf_mgr);
-    if (r300->upload_ib)
-        u_upload_destroy(r300->upload_ib);
 
     /* XXX: This function assumes r300->query_list was initialized */
     r300_release_referenced_objects(r300);
@@ -434,8 +432,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300_init_resource_functions(r300);
 
     r300->vbuf_mgr = u_vbuf_mgr_create(&r300->context, 1024 * 1024, 16,
-                                      PIPE_BIND_VERTEX_BUFFER,
-                                      U_VERTEX_FETCH_DWORD_ALIGNED);
+                                       PIPE_BIND_VERTEX_BUFFER |
+                                       PIPE_BIND_INDEX_BUFFER,
+                                       U_VERTEX_FETCH_DWORD_ALIGNED);
     if (!r300->vbuf_mgr)
         goto fail;
 
@@ -453,13 +452,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         if (!r300_hyperz_init_mm(r300))
             goto fail;
 
-    r300->upload_ib = u_upload_create(&r300->context,
-                                     64 * 1024, 16,
-                                     PIPE_BIND_INDEX_BUFFER);
-
-    if (r300->upload_ib == NULL)
-        goto fail;
-
     r300_init_states(&r300->context);
 
     /* The KIL opcode needs the first texture unit to be enabled
index 9d2a0b290ae62a30440ae8e5acf02f0733510675..1737dafc6ac940957b054c62e5faf0d7e3d53fe7 100644 (file)
@@ -579,9 +579,6 @@ struct r300_context {
     /* two mem block managers for hiz/zmask ram space */
     struct mem_block *hiz_mm;
 
-    /* upload manager */
-    struct u_upload_mgr *upload_ib;
-
     struct u_vbuf_mgr *vbuf_mgr;
 
     struct util_slab_mempool pool_transfers;
index 76d012d81e6875a94412bff1332bbd1e8f8fc0c2..dbc64ebf827fcf6bf8736ef2859a8ad7fe333f54 100644 (file)
@@ -37,7 +37,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
 
     switch (*index_size) {
     case 1:
-        u_upload_alloc(r300->upload_ib, 0, count * 2,
+        u_upload_alloc(r300->vbuf_mgr->uploader, 0, count * 2,
                        &out_offset, &out_buffer, &flushed, &ptr);
 
         util_shorten_ubyte_elts_to_userptr(
@@ -52,7 +52,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
 
     case 2:
         if (index_offset) {
-            u_upload_alloc(r300->upload_ib, 0, count * 2,
+            u_upload_alloc(r300->vbuf_mgr->uploader, 0, count * 2,
                            &out_offset, &out_buffer, &flushed, &ptr);
 
             util_rebuild_ushort_elts_to_userptr(&r300->context, *index_buffer,
@@ -67,7 +67,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
 
     case 4:
         if (index_offset) {
-            u_upload_alloc(r300->upload_ib, 0, count * 4,
+            u_upload_alloc(r300->vbuf_mgr->uploader, 0, count * 4,
                            &out_offset, &out_buffer, &flushed, &ptr);
 
             util_rebuild_uint_elts_to_userptr(&r300->context, *index_buffer,
index d76524d261d0c284bb9f3b748f069c591810ff83..4a3cc7a3f41815e56c51febc269d1ffe4281946e 100644 (file)
@@ -67,7 +67,7 @@ void r300_upload_index_buffer(struct r300_context *r300,
 
     *index_buffer = NULL;
 
-    u_upload_data(r300->upload_ib,
+    u_upload_data(r300->vbuf_mgr->uploader,
                   0, count * index_size,
                   ptr + (*start * index_size),
                   &index_offset,