Index: src/glx/x11/vertarr.c =================================================================== RCS file: /cvs/mesa/Mesa/src/glx/x11/vertarr.c,v retrieving revision 1.4 diff -u -d -r1.4 vertarr.c --- src/glx/x11/vertarr.c 22 Feb 2005 22:36:31 -0000 1.4 +++ src/glx/x11/vertarr.c 10 Nov 2005 18:07:29 -0000 @@ -94,154 +94,73 @@ { __GLXcontext *gc = __glXGetCurrentContext(); __GLXattribute * state = (__GLXattribute *)(gc->client_state_private); - GLboolean tEnable = GL_FALSE, cEnable = GL_FALSE, nEnable = GL_FALSE; - GLenum tType = GL_FLOAT, nType = GL_FLOAT, vType = GL_FLOAT; - GLenum cType = GL_FALSE; - GLint tSize = 0, cSize = 0, nSize = 3, vSize; - int cOffset = 0, nOffset = 0, vOffset = 0; +#define _F GL_FLOAT +#define _UB GL_UNSIGNED_BYTE + struct { + GLenum type; + unsigned count; + } + static const modes[14][4] = { + /* tex color normal vertex */ + {{ 0, 0 }, { 0, 0 }, { 0, 0 }, { _F, 2 }}, /* GL_V2F */ + {{ 0, 0 }, { 0, 0 }, { 0, 0 }, { _F, 3 }}, /* GL_V3F */ + {{ 0, 0 }, { _UB, 4 }, { 0, 0 }, { _F, 2 }}, /* GL_C4UB_V2F */ + {{ 0, 0 }, { _UB, 4 }, { 0, 0 }, { _F, 3 }}, /* GL_C4UB_V3F */ + {{ 0, 0 }, { _F, 3 }, { 0, 0 }, { _F, 3 }}, /* GL_C3F_V3F */ + {{ 0, 0 }, { 0, 0 }, { _F, 3 }, { _F, 3 }}, /* GL_N3F_V3F */ + {{ 0, 0 }, { _F, 4 }, { _F, 3 }, { _F, 3 }}, /* GL_C4F_N3F_V3F */ + {{ _F, 2 }, { 0, 0 }, { 0, 0 }, { _F, 3 }}, /* GL_T2F_V3F */ + {{ _F, 4 }, { 0, 0 }, { 0, 0 }, { _F, 4 }}, /* GL_T4F_V4F */ + {{ _F, 2 }, { _UB, 4 }, { 0, 0 }, { _F, 3 }}, /* GL_T2F_C4UB_V3F */ + {{ _F, 2 }, { _F, 3 }, { 0, 0 }, { _F, 3 }}, /* GL_T2F_C3F_V3F */ + {{ _F, 2 }, { 0, 0 }, { _F, 3 }, { _F, 3 }}, /* GL_T2F_N3F_V3F */ + {{ _F, 2 }, { _F, 4 }, { _F, 3 }, { _F, 3 }}, /* GL_T2F_C4F_N3F_V3F */ + {{ _F, 4 }, { _F, 4 }, { _F, 3 }, { _F, 4 }}, /* GL_T4F_C4F_N3F_V4F */ + }; +#undef _F +#undef _UB GLint trueStride, size; + unsigned offsets[4]; + unsigned i; + const int idx = format - GL_V2F; - switch (format) { - case GL_V2F: - vSize = 2; - size = __glXTypeSize(vType) * vSize; - break; - case GL_V3F: - vSize = 3; - size = __glXTypeSize(vType) * vSize; - break; - case GL_C4UB_V2F: - cEnable = GL_TRUE; - cSize = 4; - cType = GL_UNSIGNED_BYTE; - vSize = 2; - vOffset = __glXTypeSize(cType) * cSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_C4UB_V3F: - cEnable = GL_TRUE; - cSize = 4; - cType = GL_UNSIGNED_BYTE; - vSize = 3; - vOffset = __glXTypeSize(vType) * cSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_C3F_V3F: - cEnable = GL_TRUE; - cSize = 3; - cType = GL_FLOAT; - vSize = 3; - vOffset = __glXTypeSize(cType) * cSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_N3F_V3F: - nEnable = GL_TRUE; - vSize = 3; - vOffset = __glXTypeSize(nType) * nSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_C4F_N3F_V3F: - cEnable = GL_TRUE; - cSize = 4; - cType = GL_FLOAT; - nEnable = GL_TRUE; - nOffset = __glXTypeSize(cType) * cSize; - vSize = 3; - vOffset = nOffset + __glXTypeSize(nType) * nSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T2F_V3F: - tEnable = GL_TRUE; - tSize = 2; - vSize = 3; - vOffset = __glXTypeSize(tType) * tSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T4F_V4F: - tEnable = GL_TRUE; - tSize = 4; - vSize = 4; - vOffset = __glXTypeSize(tType) * tSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T2F_C4UB_V3F: - tEnable = GL_TRUE; - tSize = 2; - cEnable = GL_TRUE; - cSize = 4; - cType = GL_UNSIGNED_BYTE; - cOffset = __glXTypeSize(tType) * tSize; - vSize = 3; - vOffset = cOffset + __glXTypeSize(cType) * cSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T2F_C3F_V3F: - tEnable = GL_TRUE; - tSize = 2; - cEnable = GL_TRUE; - cSize = 3; - cType = GL_FLOAT; - cOffset = __glXTypeSize(tType) * tSize; - vSize = 3; - vOffset = cOffset + __glXTypeSize(cType) * cSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T2F_N3F_V3F: - tEnable = GL_TRUE; - tSize = 2; - nEnable = GL_TRUE; - nOffset = __glXTypeSize(tType) * tSize; - vSize = 3; - vOffset = nOffset + __glXTypeSize(nType) * nSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T2F_C4F_N3F_V3F: - tEnable = GL_TRUE; - tSize = 2; - cEnable = GL_TRUE; - cSize = 4; - cType = GL_FLOAT; - cOffset = __glXTypeSize(tType) * tSize; - nEnable = GL_TRUE; - nOffset = cOffset + __glXTypeSize(cType) * cSize; - vSize = 3; - vOffset = nOffset + __glXTypeSize(nType) * nSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - case GL_T4F_C4F_N3F_V4F: - tEnable = GL_TRUE; - tSize = 4; - cEnable = GL_TRUE; - cSize = 4; - cType = GL_FLOAT; - cOffset = __glXTypeSize(tType) * tSize; - nEnable = GL_TRUE; - nOffset = cOffset + __glXTypeSize(cType) * cSize; - vSize = 4; - vOffset = nOffset + __glXTypeSize(nType) * nSize; - size = vOffset + __glXTypeSize(vType) * vSize; - break; - default: + if ( (idx < 0) || (idx > 0x0D) ) { __glXSetError(gc, GL_INVALID_ENUM); return; } + size = 0; + for ( i = 0 ; i < 4 ; i++ ) { + if ( modes[idx][i].count != 0 ) { + offsets[i] = size; + size += __glXTypeSize( modes[idx][i].type ) * modes[idx][i].count; + } + } + trueStride = (stride == 0) ? size : stride; __glXArrayDisableAll( state ); - if (tEnable) { + if ( modes[idx][0].count != 0 ) { __indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY); - __indirect_glTexCoordPointer(tSize, tType, trueStride, (const char *)pointer); + __indirect_glTexCoordPointer( modes[idx][0].count, modes[idx][0].type, + trueStride, + (const char *) pointer ); } - if (cEnable) { + if ( modes[idx][1].count != 0 ) { __indirect_glEnableClientState(GL_COLOR_ARRAY); - __indirect_glColorPointer(cSize, cType, trueStride, (const char *)pointer+cOffset); + __indirect_glColorPointer( modes[idx][1].count, modes[idx][1].type, + trueStride, + (const char *) pointer + offsets[1] ); } - if (nEnable) { + if ( modes[idx][2].count != 0 ) { __indirect_glEnableClientState(GL_NORMAL_ARRAY); - __indirect_glNormalPointer(nType, trueStride, (const char *)pointer+nOffset); + __indirect_glNormalPointer( modes[idx][2].count, + trueStride, + (const char *)pointer + offsets[2] ); } __indirect_glEnableClientState(GL_VERTEX_ARRAY); - __indirect_glVertexPointer(vSize, vType, trueStride, (const char *)pointer+vOffset); + __indirect_glVertexPointer( modes[idx][3].count, modes[idx][3].type, + trueStride, + (const char *)pointer + offsets[3] ); }