infrastructure for GL_ARB_multisample
[mesa.git] / src / mesa / main / dlist.c
index bb52349ffc60a8496ed0f5079ceb5e20364726b0..c889b67f8bc5b992f9852889de11b4f8a8080412 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: dlist.c,v 1.57 2000/12/27 22:55:09 keithw Exp $ */
+/* $Id: dlist.c,v 1.72 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.3
+ * Version:  3.5
  *
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -110,7 +110,7 @@ Functions which cause errors if called while compiling a display list:
 /* How many nodes to allocate at a time:
  * - reduced now that we hold vertices etc. elsewhere.
  */
-#define BLOCK_SIZE 64
+#define BLOCK_SIZE 256
 
 
 /*
@@ -166,17 +166,12 @@ typedef enum {
        OPCODE_DRAW_BUFFER,
        OPCODE_DRAW_PIXELS,
        OPCODE_ENABLE,
-       OPCODE_EVALCOORD1,
-       OPCODE_EVALCOORD2,
        OPCODE_EVALMESH1,
        OPCODE_EVALMESH2,
-       OPCODE_EVALPOINT1,
-       OPCODE_EVALPOINT2,
        OPCODE_FOG,
        OPCODE_FRONT_FACE,
        OPCODE_FRUSTUM,
        OPCODE_HINT,
-       OPCODE_HINT_PGI,
        OPCODE_HISTOGRAM,
        OPCODE_INDEX_MASK,
        OPCODE_INIT_NAMES,
@@ -251,6 +246,8 @@ typedef enum {
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
+        /* GL_ARB_multisample */
+        OPCODE_SAMPLE_COVERAGE,
        /* The following three are meta instructions */
        OPCODE_ERROR,           /* raise compiled-in error */
        OPCODE_CONTINUE,
@@ -314,7 +311,7 @@ static Node *make_empty_list( void )
  * Destroy all nodes in a display list.
  * Input:  list - display list number
  */
-void gl_destroy_list( GLcontext *ctx, GLuint list )
+void _mesa_destroy_list( GLcontext *ctx, GLuint list )
 {
    Node *n, *block;
    GLboolean done;
@@ -330,8 +327,8 @@ void gl_destroy_list( GLcontext *ctx, GLuint list )
 
       /* check for extension opcodes first */
 
-      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
-      if (i >= 0 && i < ctx->listext.nr_opcodes) {
+      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
+      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
         ctx->listext.opcode[i].destroy(ctx, &n[1]);
         n += ctx->listext.opcode[i].size;
       }
@@ -504,7 +501,7 @@ static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
 /*****                        Public                              *****/
 /**********************************************************************/
 
-void gl_init_lists( void )
+void _mesa_init_lists( void )
 {
    static int init_flag = 0;
 
@@ -554,17 +551,12 @@ void gl_init_lists( void )
       InstSize[OPCODE_DRAW_BUFFER] = 2;
       InstSize[OPCODE_DRAW_PIXELS] = 6;
       InstSize[OPCODE_ENABLE] = 2;
-      InstSize[OPCODE_EVALCOORD1] = 2;
-      InstSize[OPCODE_EVALCOORD2] = 3;
       InstSize[OPCODE_EVALMESH1] = 4;
       InstSize[OPCODE_EVALMESH2] = 6;
-      InstSize[OPCODE_EVALPOINT1] = 2;
-      InstSize[OPCODE_EVALPOINT2] = 3;
       InstSize[OPCODE_FOG] = 6;
       InstSize[OPCODE_FRONT_FACE] = 2;
       InstSize[OPCODE_FRUSTUM] = 7;
       InstSize[OPCODE_HINT] = 3;
-      InstSize[OPCODE_HINT_PGI] = 3;
       InstSize[OPCODE_HISTOGRAM] = 5;
       InstSize[OPCODE_INDEX_MASK] = 2;
       InstSize[OPCODE_INIT_NAMES] = 1;
@@ -637,6 +629,8 @@ void gl_init_lists( void )
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
+      /* GL_ARB_multisample */
+      InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
       /* GL_ARB_multitexture */
       InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
       InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
@@ -660,7 +654,7 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
 
 #ifdef DEBUG
    if (opcode < (int) OPCODE_DRV_0) {
-      assert( (GLint) count == InstSize[opcode] );
+      assert( count == InstSize[opcode] );
    }
 #endif
 
@@ -670,7 +664,7 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
       n[0].opcode = OPCODE_CONTINUE;
       newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
       if (!newblock) {
-         gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
+         _mesa_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
          return NULL;
       }
       n[1].next = (Node *) newblock;
@@ -726,7 +720,7 @@ static void save_Accum( GLenum op, GLfloat value )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   FLUSH_VERTICES(ctx, 0);
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
    if (n) {
       n[1].e = op;
@@ -869,11 +863,13 @@ static void save_BlendColor( GLfloat red, GLfloat green,
 }
 
 
-static void save_CallList( GLuint list )
+void _mesa_save_CallList( GLuint list )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
+
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
    if (n) {
       n[1].ui = list;
@@ -884,11 +880,12 @@ static void save_CallList( GLuint list )
 }
 
 
-static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
+void _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
 {
    GET_CURRENT_CONTEXT(ctx);
    GLint i;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
 
    for (i=0;i<n;i++) {
       GLuint list = translate_id( i, type, lists );
@@ -1045,6 +1042,8 @@ static void save_ColorMaterial( GLenum face, GLenum mode )
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
+
    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
    if (n) {
       n[1].e = face;
@@ -1063,7 +1062,8 @@ static void save_ColorTable( GLenum target, GLenum internalFormat,
    GET_CURRENT_CONTEXT(ctx);
    if (target == GL_PROXY_TEXTURE_1D ||
        target == GL_PROXY_TEXTURE_2D ||
-       target == GL_PROXY_TEXTURE_3D) {
+       target == GL_PROXY_TEXTURE_3D ||
+       target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
       /* execute immediately */
       (*ctx->Exec->ColorTable)( target, internalFormat, width,
                                 format, type, table );
@@ -1372,8 +1372,9 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 }
 
 
-static void save_CopyPixels( GLint x, GLint y,
-                             GLsizei width, GLsizei height, GLenum type )
+static void 
+save_CopyPixels( GLint x, GLint y,
+                GLsizei width, GLsizei height, GLenum type )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1805,23 +1806,6 @@ static void save_Hint( GLenum target, GLenum mode )
 }
 
 
-/* GL_PGI_misc_hints*/
-static void save_HintPGI( GLenum target, GLint mode )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   Node *n;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT_PGI, 2 );
-   if (n) {
-      n[1].e = target;
-      n[2].i = mode;
-   }
-   if (ctx->ExecuteFlag) {
-      (*ctx->Exec->HintPGI)( target, mode );
-   }
-}
-
-
 static void
 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
 {
@@ -2150,7 +2134,7 @@ static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points );
+      GLfloat *pnts = _mesa_copy_map_points1d( target, stride, order, points );
       n[1].e = target;
       n[2].f = u1;
       n[3].f = u2;
@@ -2171,7 +2155,7 @@ static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
+      GLfloat *pnts = _mesa_copy_map_points1f( target, stride, order, points );
       n[1].e = target;
       n[2].f = u1;
       n[3].f = u2;
@@ -2195,7 +2179,7 @@ static void save_Map2d( GLenum target,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder,
+      GLfloat *pnts = _mesa_copy_map_points2d( target, ustride, uorder,
                                             vstride, vorder, points );
       n[1].e = target;
       n[2].f = u1;
@@ -2227,7 +2211,7 @@ static void save_Map2f( GLenum target,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
+      GLfloat *pnts = _mesa_copy_map_points2f( target, ustride, uorder,
                                             vstride, vorder, points );
       n[1].e = target;
       n[2].f = u1;
@@ -2367,7 +2351,7 @@ static void save_NewList( GLuint list, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    /* It's an error to call this function while building a display list */
-   gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
+   _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
    (void) list;
    (void) mode;
 }
@@ -2396,7 +2380,8 @@ static void save_Ortho( GLdouble left, GLdouble right,
 }
 
 
-static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
+static void
+save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2414,7 +2399,8 @@ static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
 }
 
 
-static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
+static void
+save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
 {
    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
    GLint i;
@@ -2432,7 +2418,8 @@ static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
 }
 
 
-static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
+static void
+save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
 {
    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
    GLint i;
@@ -2450,7 +2437,8 @@ static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
 }
 
 
-static void save_PixelTransferf( GLenum pname, GLfloat param )
+static void
+save_PixelTransferf( GLenum pname, GLfloat param )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2466,13 +2454,15 @@ static void save_PixelTransferf( GLenum pname, GLfloat param )
 }
 
 
-static void save_PixelTransferi( GLenum pname, GLint param )
+static void
+save_PixelTransferi( GLenum pname, GLint param )
 {
    save_PixelTransferf( pname, (GLfloat) param );
 }
 
 
-static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
+static void
+save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2488,7 +2478,8 @@ static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
 }
 
 
-static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
+static void
+save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2583,7 +2574,7 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units )
 static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
 {
    GET_CURRENT_CONTEXT(ctx);
-   save_PolygonOffset(factor, ctx->Visual.DepthMaxF * bias);
+   save_PolygonOffset(factor, ctx->DepthMaxF * bias);
 }
 
 
@@ -2602,6 +2593,7 @@ static void save_PopMatrix( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
    (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->PopMatrix)();
@@ -2646,6 +2638,7 @@ static void save_PushAttrib( GLbitfield mask )
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
    if (n) {
       n[1].bf = mask;
@@ -2687,6 +2680,7 @@ static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
    if (n) {
       n[1].f = x;
@@ -3238,7 +3232,7 @@ static void save_TexImage2D( GLenum target,
 
 
 static void save_TexImage3D( GLenum target,
-                             GLint level, GLint internalFormat,
+                             GLint level, GLenum internalFormat,
                              GLsizei width, GLsizei height, GLsizei depth,
                              GLint border,
                              GLenum format, GLenum type,
@@ -3259,7 +3253,7 @@ static void save_TexImage3D( GLenum target,
       if (n) {
          n[1].e = target;
          n[2].i = level;
-         n[3].i = internalFormat;
+         n[3].i = (GLint) internalFormat;
          n[4].i = (GLint) width;
          n[5].i = (GLint) height;
          n[6].i = (GLint) depth;
@@ -3424,6 +3418,7 @@ static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
    n = ALLOC_INSTRUCTION( ctx,  OPCODE_WINDOW_POS, 4 );
    if (n) {
       n[1].f = x;
@@ -3604,7 +3599,8 @@ static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
 }
 
 
-static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
+static void
+save_MultTransposeMatrixdARB( const GLdouble m[16] )
 {
    GLfloat tm[16];
    _math_transposefd(tm, m);
@@ -3612,7 +3608,8 @@ static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
 }
 
 
-static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
+static void
+save_MultTransposeMatrixfARB( const GLfloat m[16] )
 {
    GLfloat tm[16];
    _math_transposef(tm, m);
@@ -3620,7 +3617,8 @@ static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
 }
 
 
-static void save_PixelTexGenSGIX(GLenum mode)
+static void
+save_PixelTexGenSGIX(GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3655,7 +3653,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
       /* make copy of image */
       image = MALLOC(imageSize);
       if (!image) {
-         gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
          return;
       }
       MEMCPY(image, data, imageSize);
@@ -3699,7 +3697,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
       /* make copy of image */
       image = MALLOC(imageSize);
       if (!image) {
-         gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
          return;
       }
       MEMCPY(image, data, imageSize);
@@ -3744,7 +3742,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
       /* make copy of image */
       image = MALLOC(imageSize);
       if (!image) {
-         gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
          return;
       }
       MEMCPY(image, data, imageSize);
@@ -3785,7 +3783,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
    /* make copy of image */
    image = MALLOC(imageSize);
    if (!image) {
-      gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
       return;
    }
    MEMCPY(image, data, imageSize);
@@ -3824,7 +3822,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
    /* make copy of image */
    image = MALLOC(imageSize);
    if (!image) {
-      gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
       return;
    }
    MEMCPY(image, data, imageSize);
@@ -3865,7 +3863,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
    /* make copy of image */
    image = MALLOC(imageSize);
    if (!image) {
-      gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
       return;
    }
    MEMCPY(image, data, imageSize);
@@ -3893,9 +3891,28 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
 }
 
 
+/* GL_ARB_multisample */
+static void
+save_SampleCoverageARB(GLclampf value, GLboolean invert)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
+   if (n) {
+      n[1].f = value;
+      n[2].b = invert;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->SampleCoverageARB)( value, invert );
+   }
+}
+
+
 /* GL_SGIS_pixel_texture */
 
-static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
+static void
+save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3911,19 +3928,22 @@ static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
 }
 
 
-static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
+static void
+save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
 {
    save_PixelTexGenParameteriSGIS(target, (GLint) value);
 }
 
 
-static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
+static void
+save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
 {
    save_PixelTexGenParameteriSGIS(target, *value);
 }
 
 
-static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
+static void
+save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
 {
    save_PixelTexGenParameteriSGIS(target, (GLint) *value);
 }
@@ -3934,7 +3954,8 @@ static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
  * Will appear in the list before the vertex buffer containing the
  * command that provoked the error.  I don't see this as a problem.
  */
-void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
+void
+_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
 {
    Node *n;
    n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
@@ -3970,7 +3991,8 @@ islist(GLcontext *ctx, GLuint list)
  * the absolute list number, not relative to ListBase.
  * Input:  list - display list number
  */
-static void execute_list( GLcontext *ctx, GLuint list )
+static void
+execute_list( GLcontext *ctx, GLuint list )
 {
    Node *n;
    GLboolean done;
@@ -3981,6 +4003,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
    if (ctx->Driver.BeginCallList)
       ctx->Driver.BeginCallList( ctx, list );
 
+/*     fprintf(stderr, "execute list %d\n", list); */
 /*     mesa_print_display_list( list );  */
 
    ctx->CallDepth++;
@@ -3992,14 +4015,14 @@ static void execute_list( GLcontext *ctx, GLuint list )
       OpCode opcode = n[0].opcode;
       int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
 
-      if (i >= 0 && i < ctx->listext.nr_opcodes) {
+      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
         ctx->listext.opcode[i].execute(ctx, &n[1]);
         n += ctx->listext.opcode[i].size;
       }
       else {
         switch (opcode) {
         case OPCODE_ERROR:
-           gl_error( ctx, n[1].e, (const char *) n[2].data );
+           _mesa_error( ctx, n[1].e, (const char *) n[2].data );
            break;
          case OPCODE_ACCUM:
            (*ctx->Exec->Accum)( n[1].e, n[2].f );
@@ -4246,9 +4269,6 @@ static void execute_list( GLcontext *ctx, GLuint list )
         case OPCODE_HINT:
            (*ctx->Exec->Hint)( n[1].e, n[2].e );
            break;
-        case OPCODE_HINT_PGI:
-           (*ctx->Exec->HintPGI)( n[1].e, n[2].i );
-           break;
         case OPCODE_HISTOGRAM:
            (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
            break;
@@ -4610,6 +4630,9 @@ static void execute_list( GLcontext *ctx, GLuint list )
                                         n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
                                         n[9].e, n[10].i, n[11].data);
             break;
+         case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
+            (*ctx->Exec->SampleCoverageARB)(n[1].f, n[2].b);
+            break;
         case OPCODE_CONTINUE:
            n = (Node *) n[1].next;
            break;
@@ -4620,7 +4643,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
             {
                char msg[1000];
                sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
-               gl_problem( ctx, msg );
+               _mesa_problem( ctx, msg );
             }
             done = GL_TRUE;
         }
@@ -4673,11 +4696,11 @@ _mesa_DeleteLists( GLuint list, GLsizei range )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (range<0) {
-      gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
+      _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
       return;
    }
    for (i=list;i<list+range;i++) {
-      gl_destroy_list( ctx, i );
+      _mesa_destroy_list( ctx, i );
    }
 }
 
@@ -4696,7 +4719,7 @@ _mesa_GenLists(GLsizei range )
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
 
    if (range<0) {
-      gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
+      _mesa_error( ctx, GL_INVALID_VALUE, "glGenLists" );
       return 0;
    }
    if (range==0) {
@@ -4735,21 +4758,21 @@ _mesa_NewList( GLuint list, GLenum mode )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE&VERBOSE_API)
-      fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
+      fprintf(stderr, "glNewList %u %s\n", list, _mesa_lookup_enum_by_nr(mode));
 
    if (list==0) {
-      gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
+      _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
       return;
    }
 
    if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
-      gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
+      _mesa_error( ctx, GL_INVALID_ENUM, "glNewList" );
       return;
    }
 
    if (ctx->CurrentListPtr) {
       /* already compiling a display list */
-      gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
       return;
    }
 
@@ -4770,7 +4793,7 @@ _mesa_NewList( GLuint list, GLenum mode )
 
 
 /*
- * End definition of current display list.  Is the current 
+ * End definition of current display list.  Is the current
  * ASSERT_OUTSIDE_BEGIN_END strong enough to really guarentee that
  * we are outside begin/end calls?
  */
@@ -4787,14 +4810,14 @@ _mesa_EndList( void )
 
    /* Check that a list is under construction */
    if (!ctx->CurrentListPtr) {
-      gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
       return;
    }
 
    (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
 
    /* Destroy old list, if any */
-   gl_destroy_list(ctx, ctx->CurrentListNum);
+   _mesa_destroy_list(ctx, ctx->CurrentListNum);
    /* Install the list */
    _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
 
@@ -4811,6 +4834,7 @@ _mesa_EndList( void )
 
    ctx->CurrentDispatch = ctx->Exec;
    _glapi_set_dispatch( ctx->CurrentDispatch );
+
 }
 
 
@@ -4818,15 +4842,13 @@ _mesa_EndList( void )
 void
 _mesa_CallList( GLuint list )
 {
+   GLboolean save_compile_flag;
    GET_CURRENT_CONTEXT(ctx);
+   FLUSH_CURRENT(ctx, 0);
    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
    /* execute the display list, and restore the CompileFlag. */
-   GLboolean save_compile_flag;
 
-   if (MESA_VERBOSE&VERBOSE_API) {
-      fprintf(stderr, "glCallList %u\n", list);
-      mesa_print_display_list( list );
-   }
+/*     mesa_print_display_list( list ); */
 
    save_compile_flag = ctx->CompileFlag;
    if (save_compile_flag) {
@@ -5092,7 +5114,7 @@ static void exec_GetTexLevelParameteriv( GLenum target, GLint level,
    ctx->Exec->GetTexLevelParameteriv( target, level, pname, params );
 }
 
-static void exec_GetTexParameterfv( GLenum target, GLenum pname, 
+static void exec_GetTexParameterfv( GLenum target, GLenum pname,
                                    GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5165,7 +5187,7 @@ static GLboolean exec_AreTexturesResident(GLsizei n, const GLuint *texName,
    return ctx->Exec->AreTexturesResident( n, texName, residences);
 }
 
-static void exec_ColorPointer(GLint size, GLenum type, GLsizei stride, 
+static void exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
                              const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5222,7 +5244,7 @@ static void exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
    ctx->Exec->IndexPointer( type, stride, ptr);
 }
 
-static void exec_InterleavedArrays(GLenum format, GLsizei stride, 
+static void exec_InterleavedArrays(GLenum format, GLsizei stride,
                                   const GLvoid *pointer)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5258,7 +5280,7 @@ static void exec_PushClientAttrib(GLbitfield mask)
    ctx->Exec->PushClientAttrib( mask);
 }
 
-static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, 
+static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
                                 const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5266,7 +5288,7 @@ static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->TexCoordPointer( size,  type,  stride, ptr);
 }
 
-static void exec_GetCompressedTexImageARB(GLenum target, GLint level, 
+static void exec_GetCompressedTexImageARB(GLenum target, GLint level,
                                          GLvoid *img)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5274,7 +5296,7 @@ static void exec_GetCompressedTexImageARB(GLenum target, GLint level,
    ctx->Exec->GetCompressedTexImageARB( target, level, img);
 }
 
-static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride, 
+static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
                               const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5282,7 +5304,7 @@ static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->VertexPointer( size, type, stride, ptr);
 }
 
-static void exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, 
+static void exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
                                         GLint x, GLint y, GLsizei width)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5308,7 +5330,7 @@ static void exec_GetColorTable( GLenum target, GLenum format,
    ctx->Exec->GetColorTable( target, format, type, data );
 }
 
-static void exec_GetColorTableParameterfv( GLenum target, GLenum pname, 
+static void exec_GetColorTableParameterfv( GLenum target, GLenum pname,
                                           GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5316,7 +5338,7 @@ static void exec_GetColorTableParameterfv( GLenum target, GLenum pname,
    ctx->Exec->GetColorTableParameterfv( target, pname, params );
 }
 
-static void exec_GetColorTableParameteriv( GLenum target, GLenum pname, 
+static void exec_GetColorTableParameteriv( GLenum target, GLenum pname,
                                           GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5332,7 +5354,7 @@ static void exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
    ctx->Exec->GetConvolutionFilter( target, format, type, image);
 }
 
-static void exec_GetConvolutionParameterfv(GLenum target, GLenum pname, 
+static void exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
                                           GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5348,7 +5370,7 @@ static void exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
    ctx->Exec->GetConvolutionParameteriv( target, pname, params);
 }
 
-static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, 
+static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
                              GLenum type, GLvoid *values)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5356,7 +5378,7 @@ static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
    ctx->Exec->GetHistogram( target, reset, format, type, values);
 }
 
-static void exec_GetHistogramParameterfv(GLenum target, GLenum pname, 
+static void exec_GetHistogramParameterfv(GLenum target, GLenum pname,
                                         GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5364,7 +5386,7 @@ static void exec_GetHistogramParameterfv(GLenum target, GLenum pname,
    ctx->Exec->GetHistogramParameterfv( target, pname, params);
 }
 
-static void exec_GetHistogramParameteriv(GLenum target, GLenum pname, 
+static void exec_GetHistogramParameteriv(GLenum target, GLenum pname,
                                         GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5372,7 +5394,7 @@ static void exec_GetHistogramParameteriv(GLenum target, GLenum pname,
    ctx->Exec->GetHistogramParameteriv( target, pname, params);
 }
 
-static void exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, 
+static void exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
                           GLenum type, GLvoid *values)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5396,7 +5418,7 @@ static void exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
    ctx->Exec->GetMinmaxParameteriv( target, pname, params);
 }
 
-static void exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, 
+static void exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
                                    GLvoid *row, GLvoid *column, GLvoid *span)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5506,7 +5528,7 @@ static void exec_SecondaryColorPointerEXT(GLint size, GLenum type,
    ctx->Exec->SecondaryColorPointerEXT( size, type, stride, ptr);
 }
 
-static void exec_FogCoordPointerEXT(GLenum type, GLsizei stride, 
+static void exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
                                    const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5528,15 +5550,15 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
 {
    _mesa_init_no_op_table(table, tableSize);
 
-   _mesa_loopback_init_api_table( table, GL_FALSE );
+   _mesa_loopback_init_api_table( table, GL_TRUE );
 
    /* GL 1.0 */
    table->Accum = save_Accum;
    table->AlphaFunc = save_AlphaFunc;
    table->Bitmap = save_Bitmap;
    table->BlendFunc = save_BlendFunc;
-   table->CallList = save_CallList;
-   table->CallLists = save_CallLists;
+   table->CallList = _mesa_save_CallList;
+   table->CallLists = _mesa_save_CallLists;
    table->Clear = save_Clear;
    table->ClearAccum = save_ClearAccum;
    table->ClearColor = save_ClearColor;
@@ -5818,9 +5840,6 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->PointParameterfEXT = save_PointParameterfEXT;
    table->PointParameterfvEXT = save_PointParameterfvEXT;
 
-   /* 77. GL_PGI_misc_hints */
-   table->HintPGI = save_HintPGI;
-
    /* 78. GL_EXT_paletted_texture */
 #if 0
    table->ColorTableEXT = save_ColorTable;
@@ -5876,6 +5895,9 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
    table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
 
+   /* GL_ARB_multisample */
+   table->SampleCoverageARB = save_SampleCoverageARB;
+
    /* ARB 12. GL_ARB_texture_compression */
    table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
    table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
@@ -5899,7 +5921,7 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
  ***/
 static const char *enum_string( GLenum k )
 {
-   return gl_lookup_enum_by_nr( k );
+   return _mesa_lookup_enum_by_nr( k );
 }
 
 
@@ -5924,12 +5946,13 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
    done = n ? GL_FALSE : GL_TRUE;
    while (!done) {
       OpCode opcode = n[0].opcode;
-      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
 
-      if (i >= 0 && i < ctx->listext.nr_opcodes) {
+      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
         ctx->listext.opcode[i].print(ctx, &n[1]);
         n += ctx->listext.opcode[i].size;
-      } else {
+      }
+      else {
         switch (opcode) {
          case OPCODE_ACCUM:
             fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
@@ -6020,11 +6043,37 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
             fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
             break;
          case OPCODE_BIND_TEXTURE:
-           fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
+           fprintf(f,"BindTexture %s %d\n", _mesa_lookup_enum_by_nr(n[1].ui),
                    n[2].ui);
            break;
          case OPCODE_SHADE_MODEL:
-           fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
+           fprintf(f,"ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
+           break;
+        case OPCODE_MAP1:
+           fprintf(f,"Map1 %s %.3f %.3f %d %d\n", 
+                   _mesa_lookup_enum_by_nr(n[1].ui),
+                   n[2].f, n[3].f, n[4].i, n[5].i);
+           break;
+        case OPCODE_MAP2:
+           fprintf(f,"Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", 
+                   _mesa_lookup_enum_by_nr(n[1].ui),
+                   n[2].f, n[3].f, n[4].f, n[5].f,
+                   n[6].i, n[7].i, n[8].i, n[9].i);
+           break;
+        case OPCODE_MAPGRID1:
+           fprintf(f,"MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
+           break;
+        case OPCODE_MAPGRID2:
+           fprintf(f,"MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", 
+                   n[1].i, n[2].f, n[3].f,
+                   n[4].i, n[5].f, n[6].f);
+           break;
+        case OPCODE_EVALMESH1:
+           fprintf(f,"EvalMesh1 %d %d\n", n[1].i, n[2].i);
+           break;
+        case OPCODE_EVALMESH2:
+           fprintf(f,"EvalMesh2 %d %d %d %d\n",
+                   n[1].i, n[2].i, n[3].i, n[4].i);
            break;
 
         /*