Mesa (master): mesa: check for no state change in Enable/ DisableVertexAttribArray()
Brian Paul
brianp at kemper.freedesktop.org
Mon Feb 20 15:04:58 UTC 2012
Module: Mesa
Branch: master
Commit: 45453d8f69a8e7d4088c71d238228c142e3be59f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=45453d8f69a8e7d4088c71d238228c142e3be59f
Author: Brian Paul <brianp at vmware.com>
Date: Sun Feb 19 19:50:31 2012 -0700
mesa: check for no state change in Enable/DisableVertexAttribArray()
Avoid setting dirty state flags when enabling or disabling a vertex
attribute arrays when there's no change.
Reviewed-by: José Fonseca <jfonseca at vmware.com>
---
src/mesa/main/varray.c | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index dfe5064..93f6fcd 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -483,6 +483,7 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
void GLAPIENTRY
_mesa_EnableVertexAttribArrayARB(GLuint index)
{
+ struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -492,18 +493,24 @@ _mesa_EnableVertexAttribArrayARB(GLuint index)
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ arrayObj = ctx->Array.ArrayObj;
+
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib));
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
- ctx->Array.ArrayObj->_Enabled |= VERT_BIT_GENERIC(index);
- ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ if (!arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
+ /* was disabled, now being enabled */
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
+ arrayObj->_Enabled |= VERT_BIT_GENERIC(index);
+ ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ }
}
void GLAPIENTRY
_mesa_DisableVertexAttribArrayARB(GLuint index)
{
+ struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -513,12 +520,17 @@ _mesa_DisableVertexAttribArrayARB(GLuint index)
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ arrayObj = ctx->Array.ArrayObj;
+
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib));
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
- ctx->Array.ArrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
- ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
+ /* was enabled, now being disabled */
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
+ arrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
+ ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ }
}
More information about the mesa-commit
mailing list