mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.
[mesa.git] / src / mesa / main / api_arrayelt.c
index b93a057e68bfe4d05efa72a08e7fc3d3351f4d26..fc87fcba35a15491297cf7e5887fcb51ef411cb1 100644 (file)
@@ -17,7 +17,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
@@ -40,7 +40,6 @@
 #include "context.h"
 #include "imports.h"
 #include "macros.h"
-#include "mfeatures.h"
 #include "mtypes.h"
 #include "main/dispatch.h"
 
@@ -83,9 +82,6 @@ typedef struct {
 #define NUM_TYPES 8
 
 
-#if FEATURE_arrayelt
-
-
 static const int ColorFuncs[2][NUM_TYPES] = {
    {
       _gloffset_Color3bv,
@@ -1071,25 +1067,25 @@ VertexAttrib4fvARB(GLuint index, const GLfloat *v)
 static void GLAPIENTRY
 VertexAttrib1dvARB(GLuint index, const GLdouble *v)
 {
-   CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v));
+   CALL_VertexAttrib1dv(GET_DISPATCH(), (index, v));
 }
 
 static void GLAPIENTRY
 VertexAttrib2dvARB(GLuint index, const GLdouble *v)
 {
-   CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v));
+   CALL_VertexAttrib2dv(GET_DISPATCH(), (index, v));
 }
 
 static void GLAPIENTRY
 VertexAttrib3dvARB(GLuint index, const GLdouble *v)
 {
-   CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v));
+   CALL_VertexAttrib3dv(GET_DISPATCH(), (index, v));
 }
 
 static void GLAPIENTRY
 VertexAttrib4dvARB(GLuint index, const GLdouble *v)
 {
-   CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v));
+   CALL_VertexAttrib4dv(GET_DISPATCH(), (index, v));
 }
 
 
@@ -1117,7 +1113,7 @@ VertexAttribI3bv(GLuint index, const GLbyte *v)
 static void GLAPIENTRY
 VertexAttribI4bv(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index, v));
+   CALL_VertexAttribI4bv(GET_DISPATCH(), (index, v));
 }
 
 
@@ -1142,7 +1138,7 @@ VertexAttribI3ubv(GLuint index, const GLubyte *v)
 static void GLAPIENTRY
 VertexAttribI4ubv(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index, v));
+   CALL_VertexAttribI4ubv(GET_DISPATCH(), (index, v));
 }
 
 
@@ -1168,7 +1164,7 @@ VertexAttribI3sv(GLuint index, const GLshort *v)
 static void GLAPIENTRY
 VertexAttribI4sv(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index, v));
+   CALL_VertexAttribI4sv(GET_DISPATCH(), (index, v));
 }
 
 
@@ -1193,7 +1189,7 @@ VertexAttribI3usv(GLuint index, const GLushort *v)
 static void GLAPIENTRY
 VertexAttribI4usv(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index, v));
+   CALL_VertexAttribI4usv(GET_DISPATCH(), (index, v));
 }
 
 
@@ -1408,14 +1404,14 @@ GLboolean _ae_create_context( struct gl_context *ctx )
       return GL_TRUE;
 
    /* These _gloffset_* values may not be compile-time constants */
-   SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
-   SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
-   SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
-   SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
-   SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
-   SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
+   SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bv;
+   SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubv;
+   SecondaryColorFuncs[2] = _gloffset_SecondaryColor3sv;
+   SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usv;
+   SecondaryColorFuncs[4] = _gloffset_SecondaryColor3iv;
+   SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uiv;
    SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
-   SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
+   SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dv;
 
    FogCoordFuncs[0] = -1;
    FogCoordFuncs[1] = -1;
@@ -1424,9 +1420,9 @@ GLboolean _ae_create_context( struct gl_context *ctx )
    FogCoordFuncs[4] = -1;
    FogCoordFuncs[5] = -1;
    FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
-   FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
+   FogCoordFuncs[7] = _gloffset_FogCoorddv;
 
-   ctx->aelt_context = CALLOC( sizeof(AEcontext) );
+   ctx->aelt_context = calloc(1, sizeof(AEcontext));
    if (!ctx->aelt_context)
       return GL_FALSE;
 
@@ -1438,7 +1434,7 @@ GLboolean _ae_create_context( struct gl_context *ctx )
 void _ae_destroy_context( struct gl_context *ctx )
 {
    if ( AE_CONTEXT( ctx ) ) {
-      FREE( ctx->aelt_context );
+      free(ctx->aelt_context);
       ctx->aelt_context = NULL;
    }
 }
@@ -1474,44 +1470,44 @@ static void _ae_update_state( struct gl_context *ctx )
    actx->nr_vbos = 0;
 
    /* conventional vertex arrays */
-   if (arrayObj->Index.Enabled) {
-      aa->array = &arrayObj->Index;
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
       aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (arrayObj->EdgeFlag.Enabled) {
-      aa->array = &arrayObj->EdgeFlag;
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG];
       aa->offset = _gloffset_EdgeFlagv;
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (arrayObj->Normal.Enabled) {
-      aa->array = &arrayObj->Normal;
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL];
       aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (arrayObj->Color.Enabled) {
-      aa->array = &arrayObj->Color;
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0];
       aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (arrayObj->SecondaryColor.Enabled) {
-      aa->array = &arrayObj->SecondaryColor;
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1];
       aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (arrayObj->FogCoord.Enabled) {
-      aa->array = &arrayObj->FogCoord;
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG];
       aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-      struct gl_client_array *attribArray = &arrayObj->TexCoord[i];
+      struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)];
       if (attribArray->Enabled) {
          /* NOTE: we use generic glVertexAttribNV functions here.
           * If we ever remove GL_NV_vertex_program this will have to change.
@@ -1528,34 +1524,27 @@ static void _ae_update_state( struct gl_context *ctx )
    }
 
    /* generic vertex attribute arrays */   
-   for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) {  /* skip zero! */
-      struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i];
+   for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {  /* skip zero! */
+      struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
       if (attribArray->Enabled) {
+         GLint intOrNorm;
          at->array = attribArray;
          /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
           * function pointer here (for float arrays) since the pointer may
           * change from one execution of _ae_ArrayElement() to
           * the next.  Doing so caused UT to break.
           */
-         if (ctx->VertexProgram._Enabled
-             && ctx->VertexProgram.Current->IsNVProgram) {
-            at->func = AttribFuncsNV[at->array->Normalized]
-                                    [at->array->Size-1]
-                                    [TYPE_IDX(at->array->Type)];
-         }
-         else {
-            GLint intOrNorm;
-            if (at->array->Integer)
-               intOrNorm = 2;
-            else if (at->array->Normalized)
-               intOrNorm = 1;
-            else
-               intOrNorm = 0;
-
-            at->func = AttribFuncsARB[intOrNorm]
-                                     [at->array->Size-1]
-                                     [TYPE_IDX(at->array->Type)];
-         }
+         if (at->array->Integer)
+            intOrNorm = 2;
+         else if (at->array->Normalized)
+            intOrNorm = 1;
+         else
+            intOrNorm = 0;
+
+         at->func = AttribFuncsARB[intOrNorm]
+            [at->array->Size-1]
+            [TYPE_IDX(at->array->Type)];
+
          at->index = i;
         check_vbo(actx, at->array->BufferObj);
          at++;
@@ -1563,24 +1552,24 @@ static void _ae_update_state( struct gl_context *ctx )
    }
 
    /* finally, vertex position */
-   if (arrayObj->VertexAttrib[0].Enabled) {
+   if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
       /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
        * issued as the last (provoking) attribute).
        */
-      aa->array = &arrayObj->VertexAttrib[0];
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0];
       assert(aa->array->Size >= 2); /* XXX fix someday? */
       aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   else if (arrayObj->Vertex.Enabled) {
-      aa->array = &arrayObj->Vertex;
+   else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS];
       aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
 
-   check_vbo(actx, ctx->Array.ElementArrayBufferObj);
+   check_vbo(actx, arrayObj->ElementArrayBufferObj);
 
    ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
    ASSERT(aa - actx->arrays < 32);
@@ -1643,12 +1632,20 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
    const struct _glapi_table * const disp = GET_DISPATCH();
    GLboolean do_map;
 
+   /* If PrimitiveRestart is enabled and the index is the RestartIndex
+    * then we call PrimitiveRestartNV and return.
+    */
+   if (ctx->Array._PrimitiveRestart && (elt == ctx->Array._RestartIndex)) {
+      CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
+      return;
+   }
+
    if (actx->NewState) {
       assert(!actx->mapped_vbos);
       _ae_update_state( ctx );
    }
 
-   /* Determine if w need to map/unmap VBOs */
+   /* Determine if we need to map/unmap VBOs */
    do_map = actx->nr_vbos && !actx->mapped_vbos;
 
    if (do_map)
@@ -1703,6 +1700,3 @@ void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
 {
    SET_ArrayElement(disp, vfmt->ArrayElement);
 }
-
-
-#endif /* FEATURE_arrayelt */