summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-02-17 01:20:23 +0100
committerMarek Olšák <[email protected]>2017-02-25 00:03:09 +0100
commit4700f409fbabc3bc2394b813bb70789008107a45 (patch)
treed48b263d6eda56f43dea4f2aefb682ae79cc8c1c
parente78ccee9335ed677a6bf4597083954646760dadd (diff)
st/mesa: assume all drivers support user index buffers
Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Brian Paul <[email protected]> Tested-by: Brian Paul <[email protected]> (VMware driver only)
-rw-r--r--src/mesa/state_tracker/st_context.c2
-rw-r--r--src/mesa/state_tracker/st_context.h1
-rw-r--r--src/mesa/state_tracker/st_draw.c50
3 files changed, 13 insertions, 40 deletions
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 63213096484..58552582b45 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -338,8 +338,6 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st->dirty = ST_ALL_STATES_MASK;
- st->has_user_indexbuf =
- screen->get_param(screen, PIPE_CAP_USER_INDEX_BUFFERS);
st->has_user_constbuf =
screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 942fdd7bf1f..bb003843659 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -85,7 +85,6 @@ struct st_context
boolean has_half_float_packing;
boolean has_multi_draw_indirect;
boolean has_user_constbuf;
- boolean has_user_indexbuf;
/**
* If a shader can be created when we get its source.
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 8d54732eb55..f04b6c2f163 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -88,41 +88,31 @@ all_varyings_in_vbos(const struct gl_vertex_array *arrays[])
/**
* Basically, translate Mesa's index buffer information into
* a pipe_index_buffer object.
- * \return TRUE or FALSE for success/failure
*/
-static boolean
+static void
setup_index_buffer(struct st_context *st,
- const struct _mesa_index_buffer *ib,
- struct pipe_index_buffer *ibuffer)
+ const struct _mesa_index_buffer *ib)
{
+ struct pipe_index_buffer ibuffer;
struct gl_buffer_object *bufobj = ib->obj;
- ibuffer->index_size = vbo_sizeof_ib_type(ib->type);
+ ibuffer.index_size = vbo_sizeof_ib_type(ib->type);
/* get/create the index buffer object */
if (_mesa_is_bufferobj(bufobj)) {
/* indices are in a real VBO */
- ibuffer->buffer = st_buffer_object(bufobj)->buffer;
- ibuffer->offset = pointer_to_offset(ib->ptr);
- }
- else if (!st->has_user_indexbuf) {
- /* upload indexes from user memory into a real buffer */
- u_upload_data(st->pipe->stream_uploader, 0,
- ib->count * ibuffer->index_size, 4, ib->ptr,
- &ibuffer->offset, &ibuffer->buffer);
- if (!ibuffer->buffer) {
- /* out of memory */
- return FALSE;
- }
- u_upload_unmap(st->pipe->stream_uploader);
+ ibuffer.buffer = st_buffer_object(bufobj)->buffer;
+ ibuffer.offset = pointer_to_offset(ib->ptr);
+ ibuffer.user_buffer = NULL;
}
else {
/* indices are in user space memory */
- ibuffer->user_buffer = ib->ptr;
+ ibuffer.buffer = NULL;
+ ibuffer.offset = 0;
+ ibuffer.user_buffer = ib->ptr;
}
- cso_set_index_buffer(st->cso_context, ibuffer);
- return TRUE;
+ cso_set_index_buffer(st->cso_context, &ibuffer);
}
@@ -185,7 +175,6 @@ st_draw_vbo(struct gl_context *ctx,
struct gl_buffer_object *indirect)
{
struct st_context *st = st_context(ctx);
- struct pipe_index_buffer ibuffer = {0};
struct pipe_draw_info info;
const struct gl_vertex_array **arrays = ctx->Array._DrawArrays;
unsigned i;
@@ -215,10 +204,7 @@ st_draw_vbo(struct gl_context *ctx,
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
nr_prims);
- if (!setup_index_buffer(st, ib, &ibuffer)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBegin/DrawElements/DrawArray");
- return;
- }
+ setup_index_buffer(st, ib);
info.indexed = TRUE;
if (min_index != ~0U && max_index != ~0U) {
@@ -276,10 +262,6 @@ st_draw_vbo(struct gl_context *ctx,
cso_draw_vbo(st->cso_context, &info);
}
}
-
- if (ib && !st->has_user_indexbuf && !_mesa_is_bufferobj(ib->obj)) {
- pipe_resource_reference(&ibuffer.buffer, NULL);
- }
}
static void
@@ -294,7 +276,6 @@ st_indirect_draw_vbo(struct gl_context *ctx,
const struct _mesa_index_buffer *ib)
{
struct st_context *st = st_context(ctx);
- struct pipe_index_buffer ibuffer = {0};
struct pipe_draw_info info;
/* Mesa core state should have been validated already */
@@ -314,12 +295,7 @@ st_indirect_draw_vbo(struct gl_context *ctx,
util_draw_init_info(&info);
if (ib) {
- if (!setup_index_buffer(st, ib, &ibuffer)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDrawElementsIndirect%s",
- (draw_count > 1) ? "Multi" : "",
- indirect_params ? "CountARB" : "");
- return;
- }
+ setup_index_buffer(st, ib);
info.indexed = TRUE;