[Mesa-dev] [PATCH 3/9] st/mesa: make user index buffers optional

Marek Olšák maraeo at gmail.com
Tue Apr 24 14:56:24 PDT 2012


---
 src/mesa/state_tracker/st_context.c    |    4 +++-
 src/mesa/state_tracker/st_context.h    |    1 +
 src/mesa/state_tracker/st_draw.c       |    5 +++++
 src/mesa/state_tracker/st_extensions.c |    4 ++++
 4 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 84aae81..164cc45 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -155,7 +155,9 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
    st->dirty.mesa = ~0;
    st->dirty.st = ~0;
 
-   st->uploader = u_upload_create(st->pipe, 65536, 4, PIPE_BIND_VERTEX_BUFFER);
+   st->uploader = u_upload_create(st->pipe, 128 * 1024, 4,
+                                  PIPE_BIND_VERTEX_BUFFER |
+                                  PIPE_BIND_INDEX_BUFFER);
    st->cso_context = cso_create_context(pipe);
 
    st_init_vbuf(st);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 3ec98ad..ffd36e6 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -83,6 +83,7 @@ struct st_context
    GLboolean sw_primitive_restart;
    GLboolean clamp_frag_color_in_shader;
    GLboolean clamp_vert_color_in_shader;
+   boolean upload_indices;
 
 
    /* On old libGL's for linux we need to invalidate the drawables
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index c24ae75..d866fd7 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -61,6 +61,7 @@
 #include "util/u_format.h"
 #include "util/u_prim.h"
 #include "util/u_draw_quad.h"
+#include "util/u_upload_mgr.h"
 #include "draw/draw_context.h"
 #include "cso_cache/cso_context.h"
 
@@ -645,6 +646,10 @@ setup_index_buffer(struct st_context *st,
       pipe_resource_reference(&ibuffer->buffer, stobj->buffer);
       ibuffer->offset = pointer_to_offset(ib->ptr);
    }
+   else if (st->upload_indices) {
+      u_upload_data(st->uploader, 0, ib->count * ibuffer->index_size,
+      ib->ptr, &ibuffer->offset, &ibuffer->buffer);
+   }
    else {
       /* indices are in user space memory */
       ibuffer->buffer =
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 1b4bca6..b21f8a1 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -620,6 +620,10 @@ void st_init_extensions(struct st_context *st)
       ctx->Extensions.ARB_sync = GL_TRUE;
    }
 
+   if (!screen->get_param(screen, PIPE_CAP_USER_INDEX_BUFFERS)) {
+      st->upload_indices = TRUE;
+   }
+
    /* Maximum sample count. */
    for (i = 16; i > 0; --i) {
       if (screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_UNORM,
-- 
1.7.5.4



More information about the mesa-dev mailing list