summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-08-22 00:31:19 -0700
committerIan Romanick <[email protected]>2011-08-23 14:52:12 -0700
commit2ea1ff38164d95f8291ef2e5dfe2cb13936a60f2 (patch)
tree6f99fb98b21e3dd9934d7f95d462ab242b48acab
parent655c7d7498390ab69623e308abe5db4a8489a25c (diff)
tnl: Only map the necessary buffer range in bind_indices
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]>
-rw-r--r--src/mesa/tnl/t_draw.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index a23d1754391..86af4b7cfe2 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -347,16 +347,32 @@ static void bind_indices( struct gl_context *ctx,
}
if (ib->obj->Name && !ib->obj->Pointer) {
+ 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)++;
- ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
- ib->obj);
-
+ ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size,
+ GL_MAP_READ_BIT, ib->obj);
assert(ib->obj->Pointer);
+ } else {
+ ptr = ib->ptr;
}
- ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr);
-
if (ib->type == GL_UNSIGNED_INT && VB->Primitive[0].basevertex == 0) {
VB->Elts = (GLuint *) ptr;
}