summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-08-22 00:14:51 -0700
committerIan Romanick <[email protected]>2011-08-23 14:52:11 -0700
commit655c7d7498390ab69623e308abe5db4a8489a25c (patch)
tree6cca997a2dd5d71d5b01083d8d07f4e13c51163e /src/mesa/vbo
parent28249bd260f4c52badf3eb61ade2744604b21bca (diff)
mesa: Only map the necessary buffer range in vbo_get_minmax_index
Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Acked-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo_exec_array.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 484e1a85e41..18719d5f537 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -95,10 +95,25 @@ vbo_get_minmax_index(struct gl_context *ctx,
GLuint i;
if (_mesa_is_bufferobj(ib->obj)) {
- const GLvoid *map =
- ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
- ib->obj);
- indices = ADD_POINTERS(map, ib->ptr);
+ unsigned map_size;
+
+ switch (ib->type) {
+ case GL_UNSIGNED_INT:
+ map_size = count * sizeof(GLuint);
+ break;
+ case GL_UNSIGNED_SHORT:
+ map_size = count * sizeof(GLushort);
+ break;
+ case GL_UNSIGNED_BYTE:
+ map_size = count * sizeof(GLubyte);
+ break;
+ default:
+ assert(0);
+ map_size = 0;
+ }
+
+ indices = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size,
+ GL_MAP_READ_BIT, ib->obj);
} else {
indices = ib->ptr;
}