summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorYuanhan Liu <[email protected]>2011-12-28 13:54:42 +0800
committerYuanhan Liu <[email protected]>2011-12-30 13:53:40 +0800
commitefa1fac2158c9146b87f0d4340a864661721de21 (patch)
treef0e401b64e838f0a35e14d0ed363fde72a7706b1 /src/mesa/state_tracker
parentded02bd54b5925ee222d7f426850312236b4f59d (diff)
vbo: introduce vbo_sizeof_ib_type() function
introduce vbo_sizeof_ib_type() function to return the index data type size. I see some place use switch(ib->type) to get the index data type, which is sort of duplicate. Signed-off-by: Yuanhan Liu <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_draw.c15
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c17
2 files changed, 4 insertions, 28 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 87a99786521..954f15a3437 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -584,20 +584,7 @@ setup_index_buffer(struct gl_context *ctx,
if (ib) {
struct gl_buffer_object *bufobj = ib->obj;
- switch (ib->type) {
- case GL_UNSIGNED_INT:
- ibuffer->index_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- ibuffer->index_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- ibuffer->index_size = 1;
- break;
- default:
- assert(0);
- return;
- }
+ ibuffer->index_size = vbo_sizeof_ib_type(ib->type);
/* get/create the index buffer object */
if (_mesa_is_bufferobj(bufobj)) {
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 4c1e67495b7..a99eb2bf7d5 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -218,20 +218,9 @@ st_feedback_draw_vbo(struct gl_context *ctx,
if (ib) {
struct gl_buffer_object *bufobj = ib->obj;
- switch (ib->type) {
- case GL_UNSIGNED_INT:
- ibuffer.index_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- ibuffer.index_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- ibuffer.index_size = 1;
- break;
- default:
- assert(0);
- goto out_unref_vertex;
- }
+ ibuffer.index_size = vbo_sizeof_ib_type(ib->type);
+ if (ibuffer.index_size == 0)
+ goto out_unref_vertex;
if (bufobj && bufobj->Name) {
struct st_buffer_object *stobj = st_buffer_object(bufobj);