summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl
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/tnl
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/tnl')
-rw-r--r--src/mesa/tnl/t_draw.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index 83ded1949c9..f949c34d335 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -349,26 +349,10 @@ static void bind_indices( struct gl_context *ctx,
if (_mesa_is_bufferobj(ib->obj) && !_mesa_bufferobj_mapped(ib->obj)) {
/* if the buffer object isn't mapped yet, map it now */
- unsigned map_size;
-
- switch (ib->type) {
- case GL_UNSIGNED_BYTE:
- map_size = ib->count * sizeof(GLubyte);
- break;
- case GL_UNSIGNED_SHORT:
- map_size = ib->count * sizeof(GLushort);
- break;
- case GL_UNSIGNED_INT:
- map_size = ib->count * sizeof(GLuint);
- break;
- default:
- assert(0);
- map_size = 0;
- }
-
bo[*nr_bo] = ib->obj;
(*nr_bo)++;
- ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size,
+ ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr,
+ ib->count * vbo_sizeof_ib_type(ib->type),
GL_MAP_READ_BIT, ib->obj);
assert(ib->obj->Pointer);
} else {