Mesa (master): u_vbuf_mgr: make the uploader public

Marek Olšák mareko at kemper.freedesktop.org
Tue Feb 8 14:09:58 UTC 2011


Module: Mesa
Branch: master
Commit: f53cbf8bb0e542a114b76467fe715ceb977411ab
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f53cbf8bb0e542a114b76467fe715ceb977411ab

Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Feb  8 15:08:04 2011 +0100

u_vbuf_mgr: make the uploader public

---

 src/gallium/auxiliary/util/u_vbuf_mgr.c |   21 ++++++---------------
 src/gallium/auxiliary/util/u_vbuf_mgr.h |   11 +++++++++--
 src/gallium/drivers/r600/r600_pipe.c    |    2 +-
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.c b/src/gallium/auxiliary/util/u_vbuf_mgr.c
index 28c7f72..55d8695 100644
--- a/src/gallium/auxiliary/util/u_vbuf_mgr.c
+++ b/src/gallium/auxiliary/util/u_vbuf_mgr.c
@@ -73,8 +73,6 @@ struct u_vbuf_mgr_priv {
    struct translate_cache *translate_cache;
    unsigned translate_vb_slot;
 
-   struct u_upload_mgr *uploader;
-
    struct u_vbuf_mgr_elements *ve;
    void *saved_ve, *fallback_ve;
    boolean ve_binding_lock;
@@ -123,9 +121,9 @@ u_vbuf_mgr_create(struct pipe_context *pipe,
    mgr->pipe = pipe;
    mgr->translate_cache = translate_cache_create();
 
-   mgr->uploader = u_upload_create(pipe, upload_buffer_size,
-                                   upload_buffer_alignment,
-                                   PIPE_BIND_VERTEX_BUFFER);
+   mgr->b.uploader = u_upload_create(pipe, upload_buffer_size,
+                                     upload_buffer_alignment,
+                                     PIPE_BIND_VERTEX_BUFFER);
 
    mgr->caps.fetch_dword_unaligned =
          fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
@@ -146,7 +144,7 @@ void u_vbuf_mgr_destroy(struct u_vbuf_mgr *mgrb)
    }
 
    translate_cache_destroy(mgr->translate_cache);
-   u_upload_destroy(mgr->uploader);
+   u_upload_destroy(mgr->b.uploader);
    FREE(mgr);
 }
 
@@ -240,7 +238,7 @@ static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
    /* Create and map the output buffer. */
    num_verts = max_index + 1 - min_index;
 
-   u_upload_alloc(mgr->uploader,
+   u_upload_alloc(mgr->b.uploader,
                   key.output_stride * min_index,
                   key.output_stride * num_verts,
                   &out_offset, &out_buffer, upload_flushed,
@@ -537,7 +535,7 @@ static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
             size = mgr->ve->native_format_size[i];
          }
 
-         u_upload_data(mgr->uploader, first, size,
+         u_upload_data(mgr->b.uploader, first, size,
                        u_vbuf_resource(vb->buffer)->user_ptr + first,
                        &vb->buffer_offset,
                        &mgr->b.real_vertex_buffer[index],
@@ -597,10 +595,3 @@ void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgrb)
       u_vbuf_translate_end(mgr);
    }
 }
-
-void u_vbuf_mgr_flush_uploader(struct u_vbuf_mgr *mgrb)
-{
-   struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
-
-   u_upload_flush(mgr->uploader);
-}
diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.h b/src/gallium/auxiliary/util/u_vbuf_mgr.h
index 5eb5938..068459a 100644
--- a/src/gallium/auxiliary/util/u_vbuf_mgr.h
+++ b/src/gallium/auxiliary/util/u_vbuf_mgr.h
@@ -54,6 +54,15 @@ struct u_vbuf_mgr {
 
    /* Precomputed max_index for hardware vertex buffers. */
    int max_index;
+
+   /* This uploader can optionally be used by the driver.
+    *
+    * Allowed functions:
+    * - u_upload_alloc
+    * - u_upload_data
+    * - u_upload_buffer
+    * - u_upload_flush */
+   struct u_upload_mgr *uploader;
 };
 
 struct u_vbuf_resource {
@@ -102,8 +111,6 @@ void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgr,
 
 void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgr);
 
-void u_vbuf_mgr_flush_uploader(struct u_vbuf_mgr *mgr);
-
 
 static INLINE struct u_vbuf_resource *u_vbuf_resource(struct pipe_resource *r)
 {
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index de9c6a5..ad609fb 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -72,7 +72,7 @@ static void r600_flush(struct pipe_context *ctx, unsigned flags,
 	/* XXX These shouldn't be really necessary, but removing them breaks some tests.
 	 * Needless buffer reallocations may significantly increase memory consumption,
 	 * so getting rid of these 3 calls is important. */
-	u_vbuf_mgr_flush_uploader(rctx->vbuf_mgr);
+	u_upload_flush(rctx->vbuf_mgr->uploader);
 	u_upload_flush(rctx->upload_ib);
 	u_upload_flush(rctx->upload_const);
 }




More information about the mesa-commit mailing list