glsl: Change _mesa_glsl_parse_state ctor to use gl_shader_stage enum.
[mesa.git] / src / mesa / main / api_arrayelt.c
index bd55f8e432290c4e4a9616980c5d777147663dae..c9d4d038f007dd1ac5f512ce4a3ec31b184905d8 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -36,6 +35,7 @@
  */
 
 #include "glheader.h"
+#include "arrayobj.h"
 #include "api_arrayelt.h"
 #include "bufferobj.h"
 #include "context.h"
@@ -1469,6 +1469,18 @@ check_vbo(AEcontext *actx, struct gl_buffer_object *vbo)
 }
 
 
+static inline void
+update_derived_client_arrays(struct gl_context *ctx)
+{
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+
+   if (arrayObj->NewArrays) {
+      _mesa_update_array_object_client_arrays(ctx, arrayObj);
+      arrayObj->NewArrays = 0;
+   }
+}
+
+
 /**
  * Make a list of per-vertex functions to call for each glArrayElement call.
  * These functions access the array data (i.e. glVertex, glColor, glNormal,
@@ -1487,45 +1499,45 @@ _ae_update_state(struct gl_context *ctx)
    actx->nr_vbos = 0;
 
    /* conventional vertex arrays */
-   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_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->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_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->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_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->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0];
+   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->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1];
+   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->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG];
+   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->VertexAttrib[VERT_ATTRIB_TEX(i)];
+         &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.
@@ -1544,7 +1556,7 @@ _ae_update_state(struct gl_context *ctx)
    /* generic vertex attribute arrays */
    for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {  /* skip zero! */
       struct gl_client_array *attribArray =
-         &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
+         &arrayObj->_VertexAttrib[VERT_ATTRIB_GENERIC(i)];
       if (attribArray->Enabled) {
          GLint intOrNorm;
          at->array = attribArray;
@@ -1571,18 +1583,18 @@ _ae_update_state(struct gl_context *ctx)
    }
 
    /* finally, vertex position */
-   if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].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[VERT_ATTRIB_GENERIC0];
+      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->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
-      aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS];
+   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++;
@@ -1612,6 +1624,8 @@ _ae_map_vbos(struct gl_context *ctx)
    if (actx->mapped_vbos)
       return;
 
+   update_derived_client_arrays(ctx);
+
    if (actx->NewState)
       _ae_update_state(ctx);
 
@@ -1663,10 +1677,12 @@ _ae_ArrayElement(GLint elt)
    const struct _glapi_table * const disp = GET_DISPATCH();
    GLboolean do_map;
 
+   update_derived_client_arrays(ctx);
+
    /* If PrimitiveRestart is enabled and the index is the RestartIndex
     * then we call PrimitiveRestartNV and return.
     */
-   if (ctx->Array._PrimitiveRestart && (elt == ctx->Array._RestartIndex)) {
+   if (ctx->Array.PrimitiveRestart && (elt == ctx->Array.RestartIndex)) {
       CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
       return;
    }