aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-20 12:50:34 -0600
committerBrian <[email protected]>2007-08-20 12:50:34 -0600
commit730df7662f57a46dee892733afc9a55f37d2ab03 (patch)
treeb08905db620e451e0647cdbaba32c2463a290717
parent7d14c3e538f9582e2f5fb0ff827af2ecce9b0f40 (diff)
don't map element buffer in _mesa_validate_DrawElements() unless necessary
-rw-r--r--src/mesa/main/api_validate.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 841c6a53026..64ab324af22 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -69,8 +69,9 @@ _mesa_validate_DrawElements(GLcontext *ctx,
GLuint indexBytes;
/* use indices in the buffer object */
- if (!ctx->Array.ElementArrayBufferObj->Data) {
- _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!");
+ if (!ctx->Array.ElementArrayBufferObj->Size) {
+ _mesa_warning(ctx,
+ "glDrawElements called with empty array elements buffer");
return GL_FALSE;
}
@@ -86,19 +87,10 @@ _mesa_validate_DrawElements(GLcontext *ctx,
indexBytes = count * sizeof(GLushort);
}
- if ((GLubyte *) indices + indexBytes >
- ctx->Array.ElementArrayBufferObj->Data +
- ctx->Array.ElementArrayBufferObj->Size) {
+ if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) {
_mesa_warning(ctx, "glDrawElements index out of buffer bounds");
return GL_FALSE;
}
-
- /* Actual address is the sum of pointers. Indices may be used below. */
- if (ctx->Const.CheckArrayBounds) {
- indices = (const GLvoid *)
- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
- (const GLubyte *) indices);
- }
}
else {
/* not using a VBO */
@@ -108,8 +100,18 @@ _mesa_validate_DrawElements(GLcontext *ctx,
if (ctx->Const.CheckArrayBounds) {
/* find max array index */
+ const GLubyte *map;
GLuint max = 0;
GLint i;
+
+ map = ctx->Driver.MapBuffer(ctx,
+ GL_ELEMENT_ARRAY_BUFFER_ARB,
+ GL_READ_ONLY,
+ ctx->Array.ElementArrayBufferObj);
+
+ /* Actual address is the sum of pointers */
+ indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
+
if (type == GL_UNSIGNED_INT) {
for (i = 0; i < count; i++)
if (((GLuint *) indices)[i] > max)
@@ -126,6 +128,11 @@ _mesa_validate_DrawElements(GLcontext *ctx,
if (((GLubyte *) indices)[i] > max)
max = ((GLubyte *) indices)[i];
}
+
+ ctx->Driver.UnmapBuffer(ctx,
+ GL_ELEMENT_ARRAY_BUFFER_ARB,
+ ctx->Array.ElementArrayBufferObj);
+
if (max >= ctx->Array._MaxElement) {
/* the max element is out of bounds of one or more enabled arrays */
return GL_FALSE;