diff options
author | Brian Paul <[email protected]> | 2012-05-25 09:44:53 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-05-31 09:40:35 -0600 |
commit | 185ed2105829d6f5eb19edb9abbf0d7977e157c3 (patch) | |
tree | 91716430893902305c60756e64b2ec8328895640 /src/gallium/auxiliary/draw | |
parent | 151bf6e6cf8f9de4067cfcf15f6ac448ff295533 (diff) |
draw: simplify index buffer specification
Replace draw_set_index_buffer() and draw_set_mapped_index_buffer() with
draw_set_indexes() which simply takes a pointer and an index size.
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_context.c | 30 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_context.h | 7 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_private.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt.c | 22 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h | 6 |
5 files changed, 24 insertions, 43 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index ad49ce733ac..2eae204ff2c 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -627,25 +627,23 @@ void draw_set_render( struct draw_context *draw, } -void -draw_set_index_buffer(struct draw_context *draw, - const struct pipe_index_buffer *ib) -{ - if (ib) - memcpy(&draw->pt.index_buffer, ib, sizeof(draw->pt.index_buffer)); - else - memset(&draw->pt.index_buffer, 0, sizeof(draw->pt.index_buffer)); -} - - /** - * Tell drawing context where to find mapped index/element buffer. + * Tell the draw module where vertex indexes/elements are located, and + * their size (in bytes). + * + * Note: the caller must apply the pipe_index_buffer::offset value to + * the address. The draw module doesn't do that. */ void -draw_set_mapped_index_buffer(struct draw_context *draw, - const void *elements) -{ - draw->pt.user.elts = elements; +draw_set_indexes(struct draw_context *draw, + const void *elements, unsigned elem_size) +{ + assert(elem_size == 0 || + elem_size == 1 || + elem_size == 2 || + elem_size == 4); + draw->pt.user.elts = elements; + draw->pt.user.eltSize = elem_size; } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index f3a3f232322..4cd0caf3296 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -208,11 +208,8 @@ void draw_set_vertex_elements(struct draw_context *draw, unsigned count, const struct pipe_vertex_element *elements); -void draw_set_index_buffer(struct draw_context *draw, - const struct pipe_index_buffer *ib); - -void draw_set_mapped_index_buffer(struct draw_context *draw, - const void *elements); +void draw_set_indexes(struct draw_context *draw, + const void *elements, unsigned elem_size); void draw_set_mapped_vertex_buffer(struct draw_context *draw, unsigned attr, const void *buffer); diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 9e6380341da..d85deeea7f5 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -169,8 +169,6 @@ struct draw_context struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned nr_vertex_elements; - struct pipe_index_buffer index_buffer; - /* user-space vertex data, buffers */ struct { /** vertex element/index buffer (ex: glDrawElements) */ diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 2c4edc0f946..5b6eaa739d0 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -232,28 +232,24 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count) uint j; if (draw->pt.user.eltSize) { - const char *elts; - /* indexed arrays */ - elts = (const char *) draw->pt.user.elts; - elts += draw->pt.index_buffer.offset; switch (draw->pt.user.eltSize) { case 1: { - const ubyte *elem = (const ubyte *) elts; + const ubyte *elem = (const ubyte *) draw->pt.user.elts; ii = elem[start + i]; } break; case 2: { - const ushort *elem = (const ushort *) elts; + const ushort *elem = (const ushort *) draw->pt.user.elts; ii = elem[start + i]; } break; case 4: { - const uint *elem = (const uint *) elts; + const uint *elem = (const uint *) draw->pt.user.elts; ii = elem[start + i]; } break; @@ -368,28 +364,25 @@ draw_pt_arrays_restart(struct draw_context *draw, if (draw->pt.user.elts) { /* indexed prims (draw_elements) */ - const char *elts = - (const char *) draw->pt.user.elts + draw->pt.index_buffer.offset; - cur_start = start; cur_count = 0; switch (draw->pt.user.eltSize) { case 1: { - const ubyte *elt_ub = (const ubyte *) elts; + const ubyte *elt_ub = (const ubyte *) draw->pt.user.elts; PRIM_RESTART_LOOP(elt_ub); } break; case 2: { - const ushort *elt_us = (const ushort *) elts; + const ushort *elt_us = (const ushort *) draw->pt.user.elts; PRIM_RESTART_LOOP(elt_us); } break; case 4: { - const uint *elt_ui = (const uint *) elts; + const uint *elt_ui = (const uint *) draw->pt.user.elts; PRIM_RESTART_LOOP(elt_ui); } break; @@ -469,9 +462,6 @@ draw_vbo(struct draw_context *draw, if (info->indexed) assert(draw->pt.user.elts); - draw->pt.user.eltSize = - (info->indexed) ? draw->pt.index_buffer.index_size : 0; - draw->pt.user.eltBias = info->index_bias; draw->pt.user.min_index = info->min_index; draw->pt.user.max_index = info->max_index; diff --git a/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h index bb3cbf80ad7..98a4668efb7 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h +++ b/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h @@ -38,8 +38,7 @@ CONCAT(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit, unsigned istart, unsigned icount) { struct draw_context *draw = vsplit->draw; - const ELT_TYPE *ib = (const ELT_TYPE *) - ((const char *) draw->pt.user.elts + draw->pt.index_buffer.offset); + const ELT_TYPE *ib = (const ELT_TYPE *) draw->pt.user.elts; const unsigned min_index = draw->pt.user.min_index; const unsigned max_index = draw->pt.user.max_index; const int elt_bias = draw->pt.user.eltBias; @@ -128,8 +127,7 @@ CONCAT(vsplit_segment_cache_, ELT_TYPE)(struct vsplit_frontend *vsplit, boolean close, unsigned iclose) { struct draw_context *draw = vsplit->draw; - const ELT_TYPE *ib = (const ELT_TYPE *) - ((const char *) draw->pt.user.elts + draw->pt.index_buffer.offset); + const ELT_TYPE *ib = (const ELT_TYPE *) draw->pt.user.elts; const int ibias = draw->pt.user.eltBias; unsigned i; |