i965/vs: Store texturing results into a vec4 temporary.
[mesa.git] / src / mesa / main / eval.c
index e651715f7885398df15852b0bed195fd49336f4d..59627cc433afbdc4e830e8d028cc0800553fbd19 100644 (file)
@@ -48,9 +48,6 @@
 #include "main/dispatch.h"
 
 
-#if FEATURE_evaluators
-
-
 /*
  * Return the number of components per control point for any type of
  * evaluator.  Return 0 if bad target.
@@ -80,19 +77,6 @@ GLuint _mesa_evaluator_components( GLenum target )
       default:                         break;
    }
 
-   /* XXX need to check for the vertex program extension
-   if (!ctx->Extensions.NV_vertex_program)
-      return 0;
-   */
-
-   if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV &&
-       target <= GL_MAP1_VERTEX_ATTRIB15_4_NV)
-      return 4;
-
-   if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV &&
-       target <= GL_MAP2_VERTEX_ATTRIB15_4_NV)
-      return 4;
-
    return 0;
 }
 
@@ -122,25 +106,6 @@ get_1d_map( struct gl_context *ctx, GLenum target )
          return &ctx->EvalMap.Map1Texture3;
       case GL_MAP1_TEXTURE_COORD_4:
          return &ctx->EvalMap.Map1Texture4;
-      case GL_MAP1_VERTEX_ATTRIB0_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB1_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB2_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB3_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB4_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB5_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB6_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB7_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB8_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB9_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB10_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB11_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB12_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB13_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB14_4_NV:
-      case GL_MAP1_VERTEX_ATTRIB15_4_NV:
-         if (!ctx->Extensions.NV_vertex_program)
-            return NULL;
-         return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV];
       default:
          return NULL;
    }
@@ -172,25 +137,6 @@ get_2d_map( struct gl_context *ctx, GLenum target )
          return &ctx->EvalMap.Map2Texture3;
       case GL_MAP2_TEXTURE_COORD_4:
          return &ctx->EvalMap.Map2Texture4;
-      case GL_MAP2_VERTEX_ATTRIB0_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB1_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB2_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB3_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB4_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB5_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB6_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB7_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB8_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB9_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB10_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB11_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB12_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB13_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB14_4_NV:
-      case GL_MAP2_VERTEX_ATTRIB15_4_NV:
-         if (!ctx->Extensions.NV_vertex_program)
-            return NULL;
-         return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV];
       default:
          return NULL;
    }
@@ -218,7 +164,7 @@ GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
    if (!points || !size)
       return NULL;
 
-   buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+   buffer = malloc(uorder * size * sizeof(GLfloat));
 
    if (buffer)
       for (i = 0, p = buffer; i < uorder; i++, points += ustride)
@@ -242,7 +188,7 @@ GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
    if (!points || !size)
       return NULL;
 
-   buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+   buffer = malloc(uorder * size * sizeof(GLfloat));
 
    if (buffer)
       for (i = 0, p = buffer; i < uorder; i++, points += ustride)
@@ -286,9 +232,9 @@ GLfloat *_mesa_copy_map_points2f( GLenum target,
    hsize = (uorder > vorder ? uorder : vorder)*size;
 
    if(hsize>dsize)
-     buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
+     buffer = malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
    else
-     buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+     buffer = malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
 
    /* compute the increment value for the u-loop */
    uinc = ustride - vorder*vstride;
@@ -329,9 +275,9 @@ GLfloat *_mesa_copy_map_points2d(GLenum target,
    hsize = (uorder > vorder ? uorder : vorder)*size;
 
    if(hsize>dsize)
-     buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
+     buffer = malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
    else
-     buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+     buffer = malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
 
    /* compute the increment value for the u-loop */
    uinc = ustride - vorder*vstride;
@@ -384,6 +330,7 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
    k = _mesa_evaluator_components( target );
    if (k == 0) {
       _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
+      return;
    }
 
    if (ustride < k) {
@@ -415,14 +362,13 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
    map->u1 = u1;
    map->u2 = u2;
    map->du = 1.0F / (u2 - u1);
-   if (map->Points)
-      FREE( map->Points );
+   free(map->Points);
    map->Points = pnts;
 }
 
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
              GLint order, const GLfloat *points )
 {
@@ -430,7 +376,7 @@ _mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
              GLint order, const GLdouble *points )
 {
@@ -474,6 +420,7 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
    k = _mesa_evaluator_components( target );
    if (k==0) {
       _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
+      return;
    }
 
    if (ustride < k) {
@@ -515,13 +462,12 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
    map->v1 = v1;
    map->v2 = v2;
    map->dv = 1.0F / (v2 - v1);
-   if (map->Points)
-      FREE( map->Points );
+   free(map->Points);
    map->Points = pnts;
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_Map2f( GLenum target,
              GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
              GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
@@ -532,7 +478,7 @@ _mesa_Map2f( GLenum target,
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_Map2d( GLenum target,
              GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
              GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
@@ -544,7 +490,7 @@ _mesa_Map2d( GLenum target,
 
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -630,13 +576,13 @@ overflow:
                " but %d bytes are required)", bufSize, numBytes );
 }
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
 {
    _mesa_GetnMapdvARB(target, query, INT_MAX, v);
 }
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -723,14 +669,14 @@ overflow:
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
 {
    _mesa_GetnMapfvARB(target, query, INT_MAX, v);
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -817,14 +763,14 @@ overflow:
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
 {
    _mesa_GetnMapivARB(target, query, INT_MAX, v);
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -842,14 +788,14 @@ _mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
 {
    _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 );
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
                  GLint vn, GLfloat v1, GLfloat v2 )
 {
@@ -877,7 +823,7 @@ _mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
 }
 
 
-static void GLAPIENTRY
+void GLAPIENTRY
 _mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
                  GLint vn, GLdouble v1, GLdouble v2 )
 {
@@ -902,31 +848,6 @@ _mesa_install_eval_vtxfmt(struct _glapi_table *disp,
 }
 
 
-void
-_mesa_init_eval_dispatch(struct _glapi_table *disp)
-{
-   SET_GetMapdv(disp, _mesa_GetMapdv);
-   SET_GetMapfv(disp, _mesa_GetMapfv);
-   SET_GetMapiv(disp, _mesa_GetMapiv);
-   SET_Map1d(disp, _mesa_Map1d);
-   SET_Map1f(disp, _mesa_Map1f);
-   SET_Map2d(disp, _mesa_Map2d);
-   SET_Map2f(disp, _mesa_Map2f);
-   SET_MapGrid1d(disp, _mesa_MapGrid1d);
-   SET_MapGrid1f(disp, _mesa_MapGrid1f);
-   SET_MapGrid2d(disp, _mesa_MapGrid2d);
-   SET_MapGrid2f(disp, _mesa_MapGrid2f);
-
-   /* GL_ARB_robustness */
-   SET_GetnMapdvARB(disp, _mesa_GetnMapdvARB);
-   SET_GetnMapfvARB(disp, _mesa_GetnMapfvARB);
-   SET_GetnMapivARB(disp, _mesa_GetnMapivARB);
-}
-
-
-#endif /* FEATURE_evaluators */
-
-
 /**********************************************************************/
 /*****                      Initialization                        *****/
 /**********************************************************************/
@@ -940,7 +861,7 @@ init_1d_map( struct gl_1d_map *map, int n, const float *initial )
    map->Order = 1;
    map->u1 = 0.0;
    map->u2 = 1.0;
-   map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
+   map->Points = malloc(n * sizeof(GLfloat));
    if (map->Points) {
       GLint i;
       for (i=0;i<n;i++)
@@ -961,7 +882,7 @@ init_2d_map( struct gl_2d_map *map, int n, const float *initial )
    map->u2 = 1.0;
    map->v1 = 0.0;
    map->v2 = 1.0;
-   map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
+   map->Points = malloc(n * sizeof(GLfloat));
    if (map->Points) {
       GLint i;
       for (i=0;i<n;i++)
@@ -972,8 +893,6 @@ init_2d_map( struct gl_2d_map *map, int n, const float *initial )
 
 void _mesa_init_eval( struct gl_context *ctx )
 {
-   int i;
-
    /* Evaluators group */
    ctx->Eval.Map1Color4 = GL_FALSE;
    ctx->Eval.Map1Index = GL_FALSE;
@@ -984,7 +903,6 @@ void _mesa_init_eval( struct gl_context *ctx )
    ctx->Eval.Map1TextureCoord4 = GL_FALSE;
    ctx->Eval.Map1Vertex3 = GL_FALSE;
    ctx->Eval.Map1Vertex4 = GL_FALSE;
-   memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib));
    ctx->Eval.Map2Color4 = GL_FALSE;
    ctx->Eval.Map2Index = GL_FALSE;
    ctx->Eval.Map2Normal = GL_FALSE;
@@ -994,7 +912,6 @@ void _mesa_init_eval( struct gl_context *ctx )
    ctx->Eval.Map2TextureCoord4 = GL_FALSE;
    ctx->Eval.Map2Vertex3 = GL_FALSE;
    ctx->Eval.Map2Vertex4 = GL_FALSE;
-   memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib));
    ctx->Eval.AutoNormal = GL_FALSE;
    ctx->Eval.MapGrid1un = 1;
    ctx->Eval.MapGrid1u1 = 0.0;
@@ -1013,7 +930,6 @@ void _mesa_init_eval( struct gl_context *ctx )
       static GLfloat index[1] = { 1.0 };
       static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
       static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 };
-      static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 };
 
       init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex );
       init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex );
@@ -1024,8 +940,6 @@ void _mesa_init_eval( struct gl_context *ctx )
       init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord );
       init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord );
       init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord );
-      for (i = 0; i < 16; i++)
-         init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib );
 
       init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex );
       init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex );
@@ -1036,56 +950,30 @@ void _mesa_init_eval( struct gl_context *ctx )
       init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord );
       init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord );
       init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord );
-      for (i = 0; i < 16; i++)
-         init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib );
    }
 }
 
 
 void _mesa_free_eval_data( struct gl_context *ctx )
 {
-   int i;
-
    /* Free evaluator data */
-   if (ctx->EvalMap.Map1Vertex3.Points)
-      FREE( ctx->EvalMap.Map1Vertex3.Points );
-   if (ctx->EvalMap.Map1Vertex4.Points)
-      FREE( ctx->EvalMap.Map1Vertex4.Points );
-   if (ctx->EvalMap.Map1Index.Points)
-      FREE( ctx->EvalMap.Map1Index.Points );
-   if (ctx->EvalMap.Map1Color4.Points)
-      FREE( ctx->EvalMap.Map1Color4.Points );
-   if (ctx->EvalMap.Map1Normal.Points)
-      FREE( ctx->EvalMap.Map1Normal.Points );
-   if (ctx->EvalMap.Map1Texture1.Points)
-      FREE( ctx->EvalMap.Map1Texture1.Points );
-   if (ctx->EvalMap.Map1Texture2.Points)
-      FREE( ctx->EvalMap.Map1Texture2.Points );
-   if (ctx->EvalMap.Map1Texture3.Points)
-      FREE( ctx->EvalMap.Map1Texture3.Points );
-   if (ctx->EvalMap.Map1Texture4.Points)
-      FREE( ctx->EvalMap.Map1Texture4.Points );
-   for (i = 0; i < 16; i++)
-      FREE((ctx->EvalMap.Map1Attrib[i].Points));
-
-   if (ctx->EvalMap.Map2Vertex3.Points)
-      FREE( ctx->EvalMap.Map2Vertex3.Points );
-   if (ctx->EvalMap.Map2Vertex4.Points)
-      FREE( ctx->EvalMap.Map2Vertex4.Points );
-   if (ctx->EvalMap.Map2Index.Points)
-      FREE( ctx->EvalMap.Map2Index.Points );
-   if (ctx->EvalMap.Map2Color4.Points)
-      FREE( ctx->EvalMap.Map2Color4.Points );
-   if (ctx->EvalMap.Map2Normal.Points)
-      FREE( ctx->EvalMap.Map2Normal.Points );
-   if (ctx->EvalMap.Map2Texture1.Points)
-      FREE( ctx->EvalMap.Map2Texture1.Points );
-   if (ctx->EvalMap.Map2Texture2.Points)
-      FREE( ctx->EvalMap.Map2Texture2.Points );
-   if (ctx->EvalMap.Map2Texture3.Points)
-      FREE( ctx->EvalMap.Map2Texture3.Points );
-   if (ctx->EvalMap.Map2Texture4.Points)
-      FREE( ctx->EvalMap.Map2Texture4.Points );
-   for (i = 0; i < 16; i++)
-      FREE((ctx->EvalMap.Map2Attrib[i].Points));
+   free(ctx->EvalMap.Map1Vertex3.Points);
+   free(ctx->EvalMap.Map1Vertex4.Points);
+   free(ctx->EvalMap.Map1Index.Points);
+   free(ctx->EvalMap.Map1Color4.Points);
+   free(ctx->EvalMap.Map1Normal.Points);
+   free(ctx->EvalMap.Map1Texture1.Points);
+   free(ctx->EvalMap.Map1Texture2.Points);
+   free(ctx->EvalMap.Map1Texture3.Points);
+   free(ctx->EvalMap.Map1Texture4.Points);
+
+   free(ctx->EvalMap.Map2Vertex3.Points);
+   free(ctx->EvalMap.Map2Vertex4.Points);
+   free(ctx->EvalMap.Map2Index.Points);
+   free(ctx->EvalMap.Map2Color4.Points);
+   free(ctx->EvalMap.Map2Normal.Points);
+   free(ctx->EvalMap.Map2Texture1.Points);
+   free(ctx->EvalMap.Map2Texture2.Points);
+   free(ctx->EvalMap.Map2Texture3.Points);
+   free(ctx->EvalMap.Map2Texture4.Points);
 }