[Mesa-dev] [PATCH 02/11] gallium/u_upload_mgr: add a helper that creates the default uploader

Marek Olšák maraeo at gmail.com
Thu Feb 9 00:11:03 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
Tested-by: Edmondo Tommasina <edmondo.tommasina at gmail.com>
---
 src/gallium/auxiliary/util/u_upload_mgr.c | 9 +++++++++
 src/gallium/auxiliary/util/u_upload_mgr.h | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index cfef1f0..11662e7 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -79,20 +79,29 @@ u_upload_create(struct pipe_context *pipe, unsigned default_size,
    }
    else {
       upload->map_flags = PIPE_TRANSFER_WRITE |
                           PIPE_TRANSFER_UNSYNCHRONIZED |
                           PIPE_TRANSFER_FLUSH_EXPLICIT;
    }
 
    return upload;
 }
 
+struct u_upload_mgr *
+u_upload_create_default(struct pipe_context *pipe)
+{
+   return u_upload_create(pipe, 1024 * 1024,
+                          PIPE_BIND_VERTEX_BUFFER |
+                          PIPE_BIND_INDEX_BUFFER |
+                          PIPE_BIND_CONSTANT_BUFFER,
+                          PIPE_USAGE_STREAM);
+}
 
 static void upload_unmap_internal(struct u_upload_mgr *upload, boolean destroying)
 {
    if (!destroying && upload->map_persistent)
       return;
 
    if (upload->transfer) {
       struct pipe_box *box = &upload->transfer->box;
 
       if (!upload->map_persistent && (int) upload->offset > box->x) {
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h
index b36e9e5..fcd6235 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -45,20 +45,27 @@ struct pipe_resource;
  * \param pipe          Pipe driver.
  * \param default_size  Minimum size of the upload buffer, in bytes.
  * \param bind          Bitmask of PIPE_BIND_* flags.
  * \param usage         PIPE_USAGE_*
  */
 struct u_upload_mgr *
 u_upload_create(struct pipe_context *pipe, unsigned default_size,
                 unsigned bind, enum pipe_resource_usage usage);
 
 /**
+ * Create the default uploader for pipe_context. Only pipe_context::screen
+ * needs to be set for this to succeed.
+ */
+struct u_upload_mgr *
+u_upload_create_default(struct pipe_context *pipe);
+
+/**
  * Destroy the upload manager.
  */
 void u_upload_destroy( struct u_upload_mgr *upload );
 
 /**
  * Unmap upload buffer
  *
  * \param upload           Upload manager
  *
  * This must usually be called prior to firing the command stream
-- 
2.7.4



More information about the mesa-dev mailing list