mesa/version: only enable GL4.1 with correct limits.
[mesa.git] / src / mesa / main / api_arrayelt.c
index 2517d15b350bc29581caaf826154c379c55c38d9..5df7b05fbd8883f76e5bdfd5ffa74e5ba439a9e8 100644 (file)
 #include "api_arrayelt.h"
 #include "bufferobj.h"
 #include "context.h"
-#include "imports.h"
+
 #include "macros.h"
 #include "mtypes.h"
 #include "main/dispatch.h"
 #include "varray.h"
 
-typedef void (GLAPIENTRY *array_func)( const void * );
-
-typedef struct {
-   const struct gl_array_attributes *array;
-   const struct gl_vertex_buffer_binding *binding;
-   int offset;
-} AEarray;
-
 typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
 
-typedef struct {
-   const struct gl_array_attributes *array;
-   const struct gl_vertex_buffer_binding *binding;
-   attrib_func func;
-   GLuint index;
-} AEattrib;
-
-typedef struct {
-   AEarray arrays[32];
-   AEattrib attribs[VERT_ATTRIB_MAX + 1];
-
-   bool dirty_state;
-} AEcontext;
-
-
-/** Cast wrapper */
-static inline AEcontext *
-AE_CONTEXT(struct gl_context *ctx)
-{
-   return (AEcontext *) ctx->aelt_context;
-}
-
-
 /*
  * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
  * in the range [0, 7].  Luckily these type tokens are sequentially
@@ -107,13 +76,6 @@ vertex_format_to_index(const struct gl_vertex_format *vformat)
 }
 
 
-bool
-_ae_is_state_dirty(struct gl_context *ctx)
-{
-   return AE_CONTEXT(ctx)->dirty_state;
-}
-
-
 #define NUM_TYPES 8
 
 
@@ -524,7 +486,7 @@ VertexAttrib4dvNV(GLuint index, const GLdouble *v)
 /*
  * Array [size][type] of VertexAttrib functions
  */
-static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = {
+static const attrib_func AttribFuncsNV[2][4][NUM_TYPES] = {
    {
       /* non-normalized */
       {
@@ -1451,17 +1413,19 @@ attrib_src(const struct gl_vertex_array_object *vao,
 {
    const struct gl_vertex_buffer_binding *binding =
       &vao->BufferBinding[array->BufferBindingIndex];
-   const GLubyte *src
-      = ADD_POINTERS(binding->BufferObj->Mappings[MAP_INTERNAL].Pointer,
-                     _mesa_vertex_attrib_address(array, binding))
-      + elt * binding->Stride;
-   return src;
+   const GLubyte *src = _mesa_vertex_attrib_address(array, binding);
+
+   if (binding->BufferObj) {
+      src = ADD_POINTERS(binding->BufferObj->Mappings[MAP_INTERNAL].Pointer,
+                         src);
+   }
+
+   return src + elt * binding->Stride;
 }
 
 
 void
-_mesa_array_element(struct gl_context *ctx,
-                    struct _glapi_table *disp, GLint elt)
+_mesa_array_element(struct gl_context *ctx, GLint elt)
 {
    const struct gl_vertex_array_object *vao = ctx->Array.VAO;
    GLbitfield mask;
@@ -1489,10 +1453,7 @@ _mesa_array_element(struct gl_context *ctx,
       const gl_vert_attrib attrib = VERT_ATTRIB_GENERIC0;
       const struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
       const void *src = attrib_src(vao, array, elt);
-      /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
-       * issued as the last (provoking) attribute).
-       */
-      func_nv(&array->Format)(0, src);
+      func_arb(&array->Format)(0, src);
    } else if (vao->Enabled & VERT_BIT_POS) {
       const gl_vert_attrib attrib = VERT_ATTRIB_POS;
       const struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
@@ -1512,46 +1473,25 @@ void GLAPIENTRY
 _ae_ArrayElement(GLint elt)
 {
    GET_CURRENT_CONTEXT(ctx);
-   const struct _glapi_table * const disp = GET_DISPATCH();
    struct gl_vertex_array_object *vao;
 
    /* 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, ());
+      CALL_PrimitiveRestartNV(GET_DISPATCH(), ());
       return;
    }
 
    vao = ctx->Array.VAO;
    _mesa_vao_map_arrays(ctx, vao, GL_MAP_READ_BIT);
 
-   _mesa_array_element(ctx, (struct _glapi_table *)disp, elt);
+   _mesa_array_element(ctx, elt);
 
    _mesa_vao_unmap_arrays(ctx, vao);
 }
 
 
-void
-_ae_invalidate_state(struct gl_context *ctx)
-{
-   AEcontext *actx = AE_CONTEXT(ctx);
-
-   /* Only interested in this subset of mesa state.  Need to prune
-    * this down as both tnl/ and the drivers can raise statechanges
-    * for arcane reasons in the middle of seemingly atomic operations
-    * like DrawElements, over which we'd like to keep a known set of
-    * arrays and vbo's mapped.
-    *
-    * Luckily, neither the drivers nor tnl muck with the state that
-    * concerns us here:
-    */
-   assert(ctx->NewState & _NEW_ARRAY);
-
-   actx->dirty_state = true;
-}
-
-
 void
 _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
                               const GLvertexformat *vfmt)