Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / main / attrib.c
index 0641b98b3b78a88056751d406f962e4ff39d6b6a..fb6fbe5b6db3ed4ec1657bc1ea8949eb4a569e27 100644 (file)
@@ -33,7 +33,6 @@
 #include "bufferobj.h"
 #include "clear.h"
 #include "colormac.h"
-#include "colortab.h"
 #include "context.h"
 #include "depth.h"
 #include "enable.h"
 #include "hint.h"
 #include "light.h"
 #include "lines.h"
+#include "macros.h"
 #include "matrix.h"
 #include "multisample.h"
 #include "points.h"
 #include "polygon.h"
 #include "scissor.h"
-#include "simple_list.h"
 #include "stencil.h"
 #include "texenv.h"
 #include "texgen.h"
@@ -57,7 +56,7 @@
 #include "varray.h"
 #include "viewport.h"
 #include "mtypes.h"
-#include "glapi/dispatch.h"
+#include "main/dispatch.h"
 
 
 /**
@@ -70,16 +69,11 @@ struct gl_enable_attrib
    GLboolean Blend;
    GLbitfield ClipPlanes;
    GLboolean ColorMaterial;
-   GLboolean ColorTable[COLORTABLE_MAX];
-   GLboolean Convolution1D;
-   GLboolean Convolution2D;
-   GLboolean Separable2D;
    GLboolean CullFace;
    GLboolean DepthClamp;
    GLboolean DepthTest;
    GLboolean Dither;
    GLboolean Fog;
-   GLboolean Histogram;
    GLboolean Light[MAX_LIGHTS];
    GLboolean Lighting;
    GLboolean LineSmooth;
@@ -108,7 +102,6 @@ struct gl_enable_attrib
    GLboolean Map2Vertex4;
    GLboolean Map2Attrib[16];  /* GL_NV_vertex_program */
 
-   GLboolean MinMax;
    GLboolean Normalize;
    GLboolean PixelTexture;
    GLboolean PointSmooth;
@@ -223,7 +216,7 @@ _mesa_PushAttrib(GLbitfield mask)
    if (mask & GL_ACCUM_BUFFER_BIT) {
       struct gl_accum_attrib *attr;
       attr = MALLOC_STRUCT( gl_accum_attrib );
-      MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) );
+      memcpy( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) );
       save_attrib_data(&head, GL_ACCUM_BUFFER_BIT, attr);
    }
 
@@ -231,7 +224,7 @@ _mesa_PushAttrib(GLbitfield mask)
       GLuint i;
       struct gl_colorbuffer_attrib *attr;
       attr = MALLOC_STRUCT( gl_colorbuffer_attrib );
-      MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) );
+      memcpy( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) );
       /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */
       for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++)
          attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i];
@@ -242,14 +235,14 @@ _mesa_PushAttrib(GLbitfield mask)
       struct gl_current_attrib *attr;
       FLUSH_CURRENT( ctx, 0 );
       attr = MALLOC_STRUCT( gl_current_attrib );
-      MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) );
+      memcpy( attr, &ctx->Current, sizeof(struct gl_current_attrib) );
       save_attrib_data(&head, GL_CURRENT_BIT, attr);
    }
 
    if (mask & GL_DEPTH_BUFFER_BIT) {
       struct gl_depthbuffer_attrib *attr;
       attr = MALLOC_STRUCT( gl_depthbuffer_attrib );
-      MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) );
+      memcpy( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) );
       save_attrib_data(&head, GL_DEPTH_BUFFER_BIT, attr);
    }
 
@@ -263,12 +256,6 @@ _mesa_PushAttrib(GLbitfield mask)
       attr->Blend = ctx->Color.BlendEnabled;
       attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled;
       attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
-      for (i = 0; i < COLORTABLE_MAX; i++) {
-         attr->ColorTable[i] = ctx->Pixel.ColorTableEnabled[i];
-      }
-      attr->Convolution1D = ctx->Pixel.Convolution1DEnabled;
-      attr->Convolution2D = ctx->Pixel.Convolution2DEnabled;
-      attr->Separable2D = ctx->Pixel.Separable2DEnabled;
       attr->CullFace = ctx->Polygon.CullFlag;
       attr->DepthClamp = ctx->Transform.DepthClamp;
       attr->DepthTest = ctx->Depth.Test;
@@ -280,8 +267,6 @@ _mesa_PushAttrib(GLbitfield mask)
       attr->Lighting = ctx->Light.Enabled;
       attr->LineSmooth = ctx->Line.SmoothFlag;
       attr->LineStipple = ctx->Line.StippleFlag;
-      attr->Histogram = ctx->Pixel.HistogramEnabled;
-      attr->MinMax = ctx->Pixel.MinMaxEnabled;
       attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled;
       attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled;
       attr->Map1Color4 = ctx->Eval.Map1Color4;
@@ -293,7 +278,7 @@ _mesa_PushAttrib(GLbitfield mask)
       attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4;
       attr->Map1Vertex3 = ctx->Eval.Map1Vertex3;
       attr->Map1Vertex4 = ctx->Eval.Map1Vertex4;
-      MEMCPY(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib));
+      memcpy(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib));
       attr->Map2Color4 = ctx->Eval.Map2Color4;
       attr->Map2Index = ctx->Eval.Map2Index;
       attr->Map2Normal = ctx->Eval.Map2Normal;
@@ -303,7 +288,7 @@ _mesa_PushAttrib(GLbitfield mask)
       attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4;
       attr->Map2Vertex3 = ctx->Eval.Map2Vertex3;
       attr->Map2Vertex4 = ctx->Eval.Map2Vertex4;
-      MEMCPY(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib));
+      memcpy(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib));
       attr->Normalize = ctx->Transform.Normalize;
       attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped;
       attr->PointSmooth = ctx->Point.SmoothFlag;
@@ -337,21 +322,21 @@ _mesa_PushAttrib(GLbitfield mask)
    if (mask & GL_EVAL_BIT) {
       struct gl_eval_attrib *attr;
       attr = MALLOC_STRUCT( gl_eval_attrib );
-      MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) );
+      memcpy( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) );
       save_attrib_data(&head, GL_EVAL_BIT, attr);
    }
 
    if (mask & GL_FOG_BIT) {
       struct gl_fog_attrib *attr;
       attr = MALLOC_STRUCT( gl_fog_attrib );
-      MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) );
+      memcpy( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) );
       save_attrib_data(&head, GL_FOG_BIT, attr);
    }
 
    if (mask & GL_HINT_BIT) {
       struct gl_hint_attrib *attr;
       attr = MALLOC_STRUCT( gl_hint_attrib );
-      MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) );
+      memcpy( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) );
       save_attrib_data(&head, GL_HINT_BIT, attr);
    }
 
@@ -359,28 +344,28 @@ _mesa_PushAttrib(GLbitfield mask)
       struct gl_light_attrib *attr;
       FLUSH_CURRENT(ctx, 0);   /* flush material changes */
       attr = MALLOC_STRUCT( gl_light_attrib );
-      MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) );
+      memcpy( attr, &ctx->Light, sizeof(struct gl_light_attrib) );
       save_attrib_data(&head, GL_LIGHTING_BIT, attr);
    }
 
    if (mask & GL_LINE_BIT) {
       struct gl_line_attrib *attr;
       attr = MALLOC_STRUCT( gl_line_attrib );
-      MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) );
+      memcpy( attr, &ctx->Line, sizeof(struct gl_line_attrib) );
       save_attrib_data(&head, GL_LINE_BIT, attr);
    }
 
    if (mask & GL_LIST_BIT) {
       struct gl_list_attrib *attr;
       attr = MALLOC_STRUCT( gl_list_attrib );
-      MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) );
+      memcpy( attr, &ctx->List, sizeof(struct gl_list_attrib) );
       save_attrib_data(&head, GL_LIST_BIT, attr);
    }
 
    if (mask & GL_PIXEL_MODE_BIT) {
       struct gl_pixel_attrib *attr;
       attr = MALLOC_STRUCT( gl_pixel_attrib );
-      MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) );
+      memcpy( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) );
       /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */
       attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer;
       save_attrib_data(&head, GL_PIXEL_MODE_BIT, attr);
@@ -389,35 +374,35 @@ _mesa_PushAttrib(GLbitfield mask)
    if (mask & GL_POINT_BIT) {
       struct gl_point_attrib *attr;
       attr = MALLOC_STRUCT( gl_point_attrib );
-      MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) );
+      memcpy( attr, &ctx->Point, sizeof(struct gl_point_attrib) );
       save_attrib_data(&head, GL_POINT_BIT, attr);
    }
 
    if (mask & GL_POLYGON_BIT) {
       struct gl_polygon_attrib *attr;
       attr = MALLOC_STRUCT( gl_polygon_attrib );
-      MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) );
+      memcpy( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) );
       save_attrib_data(&head, GL_POLYGON_BIT, attr);
    }
 
    if (mask & GL_POLYGON_STIPPLE_BIT) {
       GLuint *stipple;
       stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) );
-      MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
+      memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
       save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple);
    }
 
    if (mask & GL_SCISSOR_BIT) {
       struct gl_scissor_attrib *attr;
       attr = MALLOC_STRUCT( gl_scissor_attrib );
-      MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) );
+      memcpy( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) );
       save_attrib_data(&head, GL_SCISSOR_BIT, attr);
    }
 
    if (mask & GL_STENCIL_BUFFER_BIT) {
       struct gl_stencil_attrib *attr;
       attr = MALLOC_STRUCT( gl_stencil_attrib );
-      MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) );
+      memcpy( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) );
       save_attrib_data(&head, GL_STENCIL_BUFFER_BIT, attr);
    }
 
@@ -433,7 +418,7 @@ _mesa_PushAttrib(GLbitfield mask)
       _mesa_lock_context_textures(ctx);
 
       /* copy/save the bulk of texture state here */
-      _mesa_memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture));
+      memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture));
 
       /* Save references to the currently bound texture objects so they don't
        * accidentally get deleted while referenced in the attribute stack.
@@ -461,14 +446,14 @@ _mesa_PushAttrib(GLbitfield mask)
    if (mask & GL_TRANSFORM_BIT) {
       struct gl_transform_attrib *attr;
       attr = MALLOC_STRUCT( gl_transform_attrib );
-      MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );
+      memcpy( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );
       save_attrib_data(&head, GL_TRANSFORM_BIT, attr);
    }
 
    if (mask & GL_VIEWPORT_BIT) {
       struct gl_viewport_attrib *attr;
       attr = MALLOC_STRUCT( gl_viewport_attrib );
-      MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );
+      memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );
       save_attrib_data(&head, GL_VIEWPORT_BIT, attr);
    }
 
@@ -476,7 +461,7 @@ _mesa_PushAttrib(GLbitfield mask)
    if (mask & GL_MULTISAMPLE_BIT_ARB) {
       struct gl_multisample_attrib *attr;
       attr = MALLOC_STRUCT( gl_multisample_attrib );
-      MEMCPY( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) );
+      memcpy( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) );
       save_attrib_data(&head, GL_MULTISAMPLE_BIT_ARB, attr);
    }
 
@@ -488,7 +473,7 @@ end:
 
 
 static void
-pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
+pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
 {
    const GLuint curTexUnitSave = ctx->Texture.CurrentUnit;
    GLuint i;
@@ -520,26 +505,11 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
 
    TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,
                    GL_COLOR_MATERIAL);
-   TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION],
-                   enable->ColorTable[COLORTABLE_PRECONVOLUTION],
-                   GL_COLOR_TABLE);
-   TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION],
-                   enable->ColorTable[COLORTABLE_POSTCONVOLUTION],
-                   GL_POST_CONVOLUTION_COLOR_TABLE);
-   TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX],
-                   enable->ColorTable[COLORTABLE_POSTCOLORMATRIX],
-                   GL_POST_COLOR_MATRIX_COLOR_TABLE);
    TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE);
    TEST_AND_UPDATE(ctx->Transform.DepthClamp, enable->DepthClamp,
                   GL_DEPTH_CLAMP);
    TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST);
    TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER);
-   TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D,
-                   GL_CONVOLUTION_1D);
-   TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D,
-                   GL_CONVOLUTION_2D);
-   TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D,
-                   GL_SEPARABLE_2D);
    TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG);
    TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING);
    TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH);
@@ -699,7 +669,7 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
  * Pop/restore texture attribute/group state.
  */
 static void
-pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
+pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
 {
    GLuint u;
 
@@ -1011,7 +981,7 @@ _mesa_PopAttrib(void)
             break;
          case GL_CURRENT_BIT:
            FLUSH_CURRENT( ctx, 0 );
-            MEMCPY( &ctx->Current, attr->data,
+            memcpy( &ctx->Current, attr->data,
                    sizeof(struct gl_current_attrib) );
             break;
          case GL_DEPTH_BUFFER_BIT:
@@ -1033,7 +1003,7 @@ _mesa_PopAttrib(void)
             }
             break;
          case GL_EVAL_BIT:
-            MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );
+            memcpy( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );
            ctx->NewState |= _NEW_EVAL;
             break;
          case GL_FOG_BIT:
@@ -1127,7 +1097,7 @@ _mesa_PopAttrib(void)
                _mesa_set_enable(ctx, GL_COLOR_MATERIAL,
                                 light->ColorMaterialEnabled);
                /* materials */
-               MEMCPY(&ctx->Light.Material, &light->Material,
+               memcpy(&ctx->Light.Material, &light->Material,
                       sizeof(struct gl_material));
             }
             break;
@@ -1142,10 +1112,10 @@ _mesa_PopAttrib(void)
             }
             break;
          case GL_LIST_BIT:
-            MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
+            memcpy( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
             break;
          case GL_PIXEL_MODE_BIT:
-            MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
+            memcpy( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
             /* XXX what other pixel state needs to be set by function calls? */
             _mesa_ReadBuffer(ctx->Pixel.ReadBuffer);
            ctx->NewState |= _NEW_PIXEL;
@@ -1204,7 +1174,7 @@ _mesa_PopAttrib(void)
             }
             break;
         case GL_POLYGON_STIPPLE_BIT:
-           MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
+           memcpy( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
            ctx->NewState |= _NEW_POLYGONSTIPPLE;
            if (ctx->Driver.PolygonStipple)
               ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data );
@@ -1353,7 +1323,7 @@ adjust_buffer_object_ref_counts(struct gl_array_object *arrayObj, GLint step)
  * object refcounts.
  */
 static void
-copy_pixelstore(GLcontext *ctx,
+copy_pixelstore(struct gl_context *ctx,
                 struct gl_pixelstore_attrib *dst,
                 const struct gl_pixelstore_attrib *src)
 {
@@ -1418,8 +1388,8 @@ _mesa_PushClientAttrib(GLbitfield mask)
       ctx->Array.ElementArrayBufferObj->RefCount++;
 #endif
 
-      MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
-      MEMCPY( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) );
+      memcpy( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
+      memcpy( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) );
 
       attr->ArrayObj = obj;
 
@@ -1493,7 +1463,7 @@ _mesa_PopClientAttrib(void)
                                 data->ElementArrayBufferObj->Name);
 #endif
 
-           MEMCPY( ctx->Array.ArrayObj, data->ArrayObj,
+           memcpy( ctx->Array.ArrayObj, data->ArrayObj,
                    sizeof( struct gl_array_object ) );
 
            FREE( data->ArrayObj );
@@ -1536,7 +1506,7 @@ _mesa_init_attrib_dispatch(struct _glapi_table *disp)
  * Free any attribute state data that might be attached to the context.
  */
 void
-_mesa_free_attrib_data(GLcontext *ctx)
+_mesa_free_attrib_data(struct gl_context *ctx)
 {
    while (ctx->AttribStackDepth > 0) {
       struct gl_attrib_node *attr, *next;
@@ -1560,15 +1530,15 @@ _mesa_free_attrib_data(GLcontext *ctx)
          }
 
          next = attr->next;
-         _mesa_free(attr->data);
-         _mesa_free(attr);
+         free(attr->data);
+         free(attr);
          attr = next;
       }
    }
 }
 
 
-void _mesa_init_attrib( GLcontext *ctx )
+void _mesa_init_attrib( struct gl_context *ctx )
 {
    /* Renderer and client attribute stacks */
    ctx->AttribStackDepth = 0;