set table size to 1023 and use new HASH_FUNC() macro
[mesa.git] / src / mesa / main / dlist.c
index c654cb62195fadee819f39e0aeeeb83f8a4cd63b..effdb7702a7de5faa8727f0983cc09681e92742d 100644 (file)
@@ -1,13 +1,8 @@
-/**
- * \file dlist.c
- * Display lists management functions.
- */
-
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.3
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
  */
 
 
+/**
+ * \file dlist.c
+ * Display lists management functions.
+ */
+
 #include "glheader.h"
 #include "imports.h"
+#include "api_arrayelt.h"
 #include "api_loopback.h"
 #include "config.h"
 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
@@ -64,6 +65,7 @@
 #include "dlist.h"
 #include "macros.h"
 #include "matrix.h"
+#include "occlude.h"
 #include "pixel.h"
 #include "points.h"
 #include "polygon.h"
 #include "nvprogram.h"
 #include "program.h"
 #endif
+#if FEATURE_ATI_fragment_shader
+#include "atifragshader.h"
+#endif
 
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
 
 
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ *
+ * Checks if dd_function_table::SaveNeedFlush is marked to flush
+ * stored (save) vertices, and calls
+ * dd_function_table::SaveFlushVertices if so.
+ */
+#define SAVE_FLUSH_VERTICES(ctx)               \
+do {                                           \
+   if (ctx->Driver.SaveNeedFlush)              \
+      ctx->Driver.SaveFlushVertices(ctx);      \
+} while (0)
+
 
 /**
  * Macro to assert that the API call was made outside the
@@ -123,7 +143,7 @@ do {                                                                        \
 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)                   \
 do {                                                                   \
    ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);                                 \
-   FLUSH_VERTICES(ctx, 0);                                             \
+   SAVE_FLUSH_VERTICES(ctx);                                           \
 } while (0)
 
 /**
@@ -136,7 +156,7 @@ do {                                                                        \
 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
 do {                                                                   \
    ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);             \
-   FLUSH_VERTICES(ctx, 0);                                             \
+   SAVE_FLUSH_VERTICES(ctx);                                           \
 } while (0)
 
 
@@ -148,13 +168,14 @@ do {                                                                      \
  * integer values starting at 0 is very important, see InstSize array usage)
  */
 typedef enum {
+       OPCODE_INVALID = -1,                    /* Force signed enum */
        OPCODE_ACCUM,
        OPCODE_ALPHA_FUNC,
         OPCODE_BIND_TEXTURE,
        OPCODE_BITMAP,
        OPCODE_BLEND_COLOR,
        OPCODE_BLEND_EQUATION,
-       OPCODE_BLEND_FUNC,
+       OPCODE_BLEND_EQUATION_SEPARATE,
        OPCODE_BLEND_FUNC_SEPARATE,
         OPCODE_CALL_LIST,
         OPCODE_CALL_LIST_OFFSET,
@@ -293,12 +314,47 @@ typedef enum {
         /* GL_ARB_vertex/fragment_program */
         OPCODE_PROGRAM_STRING_ARB,
         OPCODE_PROGRAM_ENV_PARAMETER_ARB,
+        /* GL_ARB_occlusion_query */
+        OPCODE_BEGIN_QUERY_ARB,
+        OPCODE_END_QUERY_ARB,
+       /* GL_ARB_draw_buffers */
+        OPCODE_DRAW_BUFFERS_ARB,
+       /* GL_ATI_fragment_shader */
+       OPCODE_BIND_FRAGMENT_SHADER_ATI,
+       OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
+        /* OpenGL 2.0 */
+        OPCODE_STENCIL_FUNC_SEPARATE,
+        OPCODE_STENCIL_OP_SEPARATE,
+        OPCODE_STENCIL_MASK_SEPARATE,
+       
+       /* Vertex attributes -- fallback for when optimized display
+        * list build isn't active.
+        */
+       OPCODE_ATTR_1F_NV,
+       OPCODE_ATTR_2F_NV,
+       OPCODE_ATTR_3F_NV,
+       OPCODE_ATTR_4F_NV,
+       OPCODE_ATTR_1F_ARB,
+       OPCODE_ATTR_2F_ARB,
+       OPCODE_ATTR_3F_ARB,
+       OPCODE_ATTR_4F_ARB,
+       OPCODE_MATERIAL,
+       OPCODE_INDEX,
+       OPCODE_EDGEFLAG,
+       OPCODE_BEGIN,
+       OPCODE_END,
+       OPCODE_RECTF,
+       OPCODE_EVAL_C1,
+       OPCODE_EVAL_C2,
+       OPCODE_EVAL_P1,
+       OPCODE_EVAL_P2,
+
 
        /* The following three are meta instructions */
        OPCODE_ERROR,           /* raise compiled-in error */
        OPCODE_CONTINUE,
        OPCODE_END_OF_LIST,
-       OPCODE_DRV_0
+       OPCODE_EXT_0
 } OpCode;
 
 
@@ -356,11 +412,13 @@ void mesa_print_display_list( GLuint list );
  * Make an empty display list.  This is used by glGenLists() to
  * reserver display list IDs.
  */
-static Node *make_empty_list( void )
+static struct mesa_display_list *make_list( GLuint list, GLuint count )
 {
-   Node *n = (Node *) MALLOC( sizeof(Node) );
-   n[0].opcode = OPCODE_END_OF_LIST;
-   return n;
+   struct mesa_display_list *dlist = CALLOC_STRUCT( mesa_display_list );
+   dlist->id = list;
+   dlist->node = (Node *) MALLOC( sizeof(Node) * count );
+   dlist->node[0].opcode = OPCODE_END_OF_LIST;
+   return dlist;
 }
 
 
@@ -371,24 +429,28 @@ static Node *make_empty_list( void )
  */
 void _mesa_destroy_list( GLcontext *ctx, GLuint list )
 {
+   struct mesa_display_list *dlist;
    Node *n, *block;
    GLboolean done;
 
    if (list==0)
       return;
 
-   block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
-   n = block;
+   dlist = (struct mesa_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+   if (!dlist)
+      return;
+   
+   n = block = dlist->node;
 
    done = block ? GL_FALSE : GL_TRUE;
    while (!done) {
 
       /* check for extension opcodes first */
 
-      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;
+      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
+      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+        ctx->ListExt.Opcode[i].Destroy(ctx, &n[1]);
+        n += ctx->ListExt.Opcode[i].Size;
       }
       else {
         switch (n[0].opcode) {
@@ -516,6 +578,7 @@ void _mesa_destroy_list( GLcontext *ctx, GLuint list )
       }
    }
 
+   FREE( dlist );
    _mesa_HashRemove(ctx->Shared->DisplayList, list);
 }
 
@@ -582,7 +645,11 @@ static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
 /*****                        Public                              *****/
 /**********************************************************************/
 
-void _mesa_init_lists( void )
+/**
+ * Do one-time initialiazations for display lists.
+ */
+void
+_mesa_init_lists( void )
 {
    static int init_flag = 0;
 
@@ -593,7 +660,7 @@ void _mesa_init_lists( void )
       InstSize[OPCODE_BITMAP] = 8;
       InstSize[OPCODE_BLEND_COLOR] = 5;
       InstSize[OPCODE_BLEND_EQUATION] = 2;
-      InstSize[OPCODE_BLEND_FUNC] = 3;
+      InstSize[OPCODE_BLEND_EQUATION_SEPARATE] = 3;
       InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
       InstSize[OPCODE_CALL_LIST] = 2;
       InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
@@ -734,11 +801,69 @@ void _mesa_init_lists( void )
       InstSize[OPCODE_PROGRAM_STRING_ARB] = 5;
       InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7;
 #endif
+#if FEATURE_ARB_occlusion_query
+      InstSize[OPCODE_BEGIN_QUERY_ARB] = 3;
+      InstSize[OPCODE_END_QUERY_ARB] = 2;
+#endif
+      InstSize[OPCODE_DRAW_BUFFERS_ARB] = 2 + MAX_DRAW_BUFFERS;
+#if FEATURE_ATI_fragment_shader
+      InstSize[OPCODE_BIND_FRAGMENT_SHADER_ATI] = 2;
+      InstSize[OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI] = 6;
+#endif
+      /* OpenGL 2.0 */
+      InstSize[OPCODE_STENCIL_FUNC_SEPARATE] = 5;
+      InstSize[OPCODE_STENCIL_MASK_SEPARATE] = 3;
+      InstSize[OPCODE_STENCIL_OP_SEPARATE] = 5;
+
+      InstSize[OPCODE_ATTR_1F_NV] = 3;
+      InstSize[OPCODE_ATTR_2F_NV] = 4;
+      InstSize[OPCODE_ATTR_3F_NV] = 5;
+      InstSize[OPCODE_ATTR_4F_NV] = 6;
+      InstSize[OPCODE_ATTR_1F_ARB] = 3;
+      InstSize[OPCODE_ATTR_2F_ARB] = 4;
+      InstSize[OPCODE_ATTR_3F_ARB] = 5;
+      InstSize[OPCODE_ATTR_4F_ARB] = 6;
+      InstSize[OPCODE_MATERIAL] = 7;
+      InstSize[OPCODE_INDEX] = 2;
+      InstSize[OPCODE_EDGEFLAG] = 2;
+      InstSize[OPCODE_BEGIN] = 2;
+      InstSize[OPCODE_END] = 1;
+      InstSize[OPCODE_RECTF] = 5;
+      InstSize[OPCODE_EVAL_C1] = 2;
+      InstSize[OPCODE_EVAL_C2] = 3;
+      InstSize[OPCODE_EVAL_P1] = 2;
+      InstSize[OPCODE_EVAL_P2] = 3;
    }
    init_flag = 1;
 }
 
 
+
+/**
+ * Wrapper for _mesa_unpack_image() that handles pixel buffer objects.
+ * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
+ */
+static GLvoid *
+unpack_image( GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth,
+              GLenum format, GLenum type, const GLvoid *pixels,
+              const struct gl_pixelstore_attrib *unpack )
+{
+   if (unpack->BufferObj->Name == 0) {
+      /* no PBO */
+      return _mesa_unpack_image(dimensions, width, height, depth, format, type,
+                                pixels, unpack);
+   }
+   else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
+                                      format, type, pixels)) {
+      const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
+      return _mesa_unpack_image(dimensions, width, height, depth, format, type,
+                                src, unpack);
+   }
+   /* bad access! */
+   return NULL;
+}
+
+
 /*
  * Allocate space for a display list instruction.
  * \param opcode - type of instruction
@@ -753,14 +878,14 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
    GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
 
 #ifdef DEBUG
-   if (opcode < (int) OPCODE_DRV_0) {
+   if (opcode < (int) OPCODE_EXT_0) {
       assert( count == InstSize[opcode] );
    }
 #endif
 
-   if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
+   if (ctx->ListState.CurrentPos + count + 2 > BLOCK_SIZE) {
       /* This block is full.  Allocate a new block and chain to it */
-      n = ctx->CurrentBlock + ctx->CurrentPos;
+      n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
       n[0].opcode = OPCODE_CONTINUE;
       newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
       if (!newblock) {
@@ -768,12 +893,12 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
          return NULL;
       }
       n[1].next = (Node *) newblock;
-      ctx->CurrentBlock = newblock;
-      ctx->CurrentPos = 0;
+      ctx->ListState.CurrentBlock = newblock;
+      ctx->ListState.CurrentPos = 0;
    }
 
-   n = ctx->CurrentBlock + ctx->CurrentPos;
-   ctx->CurrentPos += count;
+   n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
+   ctx->ListState.CurrentPos += count;
 
    n[0].opcode = (OpCode) opcode;
 
@@ -781,22 +906,30 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
 }
 
 
-/* Allow modules and drivers to get their own opcodes.
+/**
+ * This function allows modules and drivers to get their own opcodes
+ * for extending display list functionality.
+ * \param ctx  the rendering context
+ * \param size  number of bytes for storing the new display list command
+ * \param execute  function to execute the new display list command
+ * \param destroy  function to destroy the new display list command
+ * \param print  function to print the new display list command
+ * \return  the new opcode number or -1 if error
  */
-int
+GLint
 _mesa_alloc_opcode( GLcontext *ctx,
-                   GLuint sz,
+                   GLuint size,
                    void (*execute)( GLcontext *, void * ),
                    void (*destroy)( GLcontext *, void * ),
                    void (*print)( GLcontext *, void * ) )
 {
-   if (ctx->listext.nr_opcodes < GL_MAX_EXT_OPCODES) {
-      GLuint i = ctx->listext.nr_opcodes++;
-      ctx->listext.opcode[i].size = 1 + (sz + sizeof(Node) - 1)/sizeof(Node);
-      ctx->listext.opcode[i].execute = execute;
-      ctx->listext.opcode[i].destroy = destroy;
-      ctx->listext.opcode[i].print = print;
-      return i + OPCODE_DRV_0;
+   if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
+      const GLuint i = ctx->ListExt.NumOpcodes++;
+      ctx->ListExt.Opcode[i].Size = 1 + (size + sizeof(Node) - 1)/sizeof(Node);
+      ctx->ListExt.Opcode[i].Execute = execute;
+      ctx->ListExt.Opcode[i].Destroy = destroy;
+      ctx->ListExt.Opcode[i].Print = print;
+      return i + OPCODE_EXT_0;
    }
    return -1;
 }
@@ -908,18 +1041,19 @@ static void GLAPIENTRY save_BlendEquation( GLenum mode )
 }
 
 
-static void GLAPIENTRY save_BlendFunc( GLenum sfactor, GLenum dfactor )
+static void GLAPIENTRY save_BlendEquationSeparateEXT( GLenum modeRGB,
+                                                     GLenum modeA )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC, 2 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2 );
    if (n) {
-      n[1].e = sfactor;
-      n[2].e = dfactor;
+      n[1].e = modeRGB;
+      n[2].e = modeA;
    }
    if (ctx->ExecuteFlag) {
-      (*ctx->Exec->BlendFunc)( sfactor, dfactor );
+      (*ctx->Exec->BlendEquationSeparateEXT)( modeRGB, modeA );
    }
 }
 
@@ -967,13 +1101,17 @@ void GLAPIENTRY _mesa_save_CallList( GLuint list )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
+   SAVE_FLUSH_VERTICES(ctx);
 
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
    if (n) {
       n[1].ui = list;
    }
+   
+   /* After this, we don't know what begin/end state we're in:
+    */
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->CallList)( list );
    }
@@ -986,8 +1124,7 @@ void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *list
    GLint i;
    GLboolean typeErrorFlag;
 
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
+   SAVE_FLUSH_VERTICES(ctx);
 
    switch (type) {
       case GL_BYTE:
@@ -1014,6 +1151,11 @@ void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *list
          n[2].b = typeErrorFlag;
       }
    }
+
+   /* After this, we don't know what begin/end state we're in:
+    */
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->CallLists)( n, type, lists );
    }
@@ -1162,7 +1304,6 @@ static void GLAPIENTRY 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) {
@@ -1189,8 +1330,8 @@ static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
                                 format, type, table );
    }
    else {
-      GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
-                                         &ctx->Unpack);
+      GLvoid *image = unpack_image(1, width, 1, 1, format, type, table,
+                                   &ctx->Unpack);
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
       n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
@@ -1278,8 +1419,8 @@ static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei
                                 const GLvoid *table)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
-                                      &ctx->Unpack);
+   GLvoid *image = unpack_image(1, count, 1, 1, format, type, table,
+                                &ctx->Unpack);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
@@ -1349,8 +1490,8 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
                          GLenum format, GLenum type, const GLvoid *filter)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
-                                      &ctx->Unpack);
+   GLvoid *image = unpack_image(1, width, 1, 1, format, type, filter,
+                                &ctx->Unpack);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
@@ -1378,8 +1519,8 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
                          GLenum type, const GLvoid *filter)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
-                                      &ctx->Unpack);
+   GLvoid *image = unpack_image(2, width, height, 1, format, type, filter,
+                                &ctx->Unpack);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
@@ -1743,8 +1884,8 @@ static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
                              const GLvoid *pixels )
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
-                                      pixels, &ctx->Unpack);
+   GLvoid *image = unpack_image(2, width, height, 1, format, type,
+                                pixels, &ctx->Unpack);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
@@ -2728,7 +2869,6 @@ static void GLAPIENTRY 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)();
@@ -2773,7 +2913,6 @@ static void GLAPIENTRY 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;
@@ -2815,7 +2954,6 @@ static void GLAPIENTRY save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloa
    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;
@@ -3137,6 +3275,61 @@ static void GLAPIENTRY save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
 }
 
 
+static void GLAPIENTRY
+save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   if (n) {
+      n[1].e = face;
+      n[2].e = func;
+      n[3].i = ref;
+      n[4].ui = mask;
+   }
+   if (ctx->ExecuteFlag) {
+      ctx->Exec->StencilFuncSeparate(face, func, ref, mask);
+   }
+}
+
+
+static void GLAPIENTRY
+save_StencilMaskSeparate(GLenum face, GLuint mask)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
+   if (n) {
+      n[1].e = face;
+      n[2].ui = mask;
+   }
+   if (ctx->ExecuteFlag) {
+      ctx->Exec->StencilMaskSeparate(face, mask);
+   }
+}
+
+
+static void GLAPIENTRY
+save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP_SEPARATE, 4 );
+   if (n) {
+      n[1].e = face;
+      n[2].e = fail;
+      n[3].e = zfail;
+      n[4].e = zpass;
+   }
+   if (ctx->ExecuteFlag) {
+      ctx->Exec->StencilOpSeparate(face, fail, zfail, zpass);
+   }
+}
+
+
 static void GLAPIENTRY save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -3146,10 +3339,16 @@ static void GLAPIENTRY save_TexEnvfv( GLenum target, GLenum pname, const GLfloat
    if (n) {
       n[1].e = target;
       n[2].e = pname;
-      n[3].f = params[0];
-      n[4].f = params[1];
-      n[5].f = params[2];
-      n[6].f = params[3];
+      if (pname == GL_TEXTURE_ENV_COLOR) {
+         n[3].f = params[0];
+         n[4].f = params[1];
+         n[5].f = params[2];
+         n[6].f = params[3];
+      }
+      else {
+         n[3].f = params[0];
+         n[4].f = n[5].f = n[6].f = 0.0F;
+      }
    }
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->TexEnvfv)( target, pname, params );
@@ -3175,10 +3374,16 @@ static void GLAPIENTRY save_TexEnvi( GLenum target, GLenum pname, GLint param )
 static void GLAPIENTRY save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
 {
    GLfloat p[4];
-   p[0] = INT_TO_FLOAT( param[0] );
-   p[1] = INT_TO_FLOAT( param[1] );
-   p[2] = INT_TO_FLOAT( param[2] );
-   p[3] = INT_TO_FLOAT( param[3] );
+   if (pname == GL_TEXTURE_ENV_COLOR) {
+      p[0] = INT_TO_FLOAT( param[0] );
+      p[1] = INT_TO_FLOAT( param[1] );
+      p[2] = INT_TO_FLOAT( param[2] );
+      p[3] = INT_TO_FLOAT( param[3] );
+   }
+   else {
+      p[0] = (GLfloat) param[0];
+      p[1] = p[2] = p[3] = 0.0F;
+   }
    save_TexEnvfv( target, pname, p );
 }
 
@@ -3302,8 +3507,8 @@ static void GLAPIENTRY save_TexImage1D( GLenum target,
                                border, format, type, pixels );
    }
    else {
-      GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
-                                         pixels, &ctx->Unpack);
+      GLvoid *image = unpack_image(1, width, 1, 1, format, type,
+                                   pixels, &ctx->Unpack);
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
       n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
@@ -3341,8 +3546,8 @@ static void GLAPIENTRY save_TexImage2D( GLenum target,
                                height, border, format, type, pixels );
    }
    else {
-      GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
-                                         pixels, &ctx->Unpack);
+      GLvoid *image = unpack_image(2, width, height, 1, format, type,
+                                   pixels, &ctx->Unpack);
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
       n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
@@ -3383,8 +3588,8 @@ static void GLAPIENTRY save_TexImage3D( GLenum target,
    }
    else {
       Node *n;
-      GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
-                                         pixels, &ctx->Unpack);
+      GLvoid *image = unpack_image(3, width, height, depth, format, type,
+                                   pixels, &ctx->Unpack);
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
       n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
       if (n) {
@@ -3416,8 +3621,8 @@ static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xof
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
-                                      pixels, &ctx->Unpack);
+   GLvoid *image = unpack_image(1, width, 1, 1, format, type,
+                                pixels, &ctx->Unpack);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
    if (n) {
@@ -3447,8 +3652,8 @@ static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level,
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
-                                      pixels, &ctx->Unpack);
+   GLvoid *image = unpack_image(2, width, height, 1, format, type,
+                                pixels, &ctx->Unpack);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
    if (n) {
@@ -3480,8 +3685,8 @@ static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level,
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
-                                      pixels, &ctx->Unpack);
+   GLvoid *image = unpack_image(3, width, height, depth, format, type,
+                                pixels, &ctx->Unpack);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
    if (n) {
@@ -3555,7 +3760,6 @@ static void GLAPIENTRY save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GL
    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;
@@ -4074,7 +4278,7 @@ save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
 /*
  * GL_NV_vertex_program
  */
-#if FEATURE_NV_vertex_program
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
 static void GLAPIENTRY
 save_BindProgramNV(GLenum target, GLuint id)
 {
@@ -4090,7 +4294,9 @@ save_BindProgramNV(GLenum target, GLuint id)
       (*ctx->Exec->BindProgramNV)( target, id );
    }
 }
+#endif /* FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
 
+#if FEATURE_NV_vertex_program
 static void GLAPIENTRY
 save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
 {
@@ -4432,7 +4638,7 @@ static void GLAPIENTRY save_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 2 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_BOUNDS_EXT, 2 );
    if (n) {
       n[1].f = (GLfloat) zmin;
       n[2].f = (GLfloat) zmax;
@@ -4532,107 +4738,964 @@ save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
 
 
+#ifdef FEATURE_ARB_occlusion_query
 
-/* KW: Compile commands
- *
- * 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
-_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
+static void GLAPIENTRY
+save_BeginQueryARB(GLenum target, GLuint id)
 {
+   GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN_QUERY_ARB, 2 );
    if (n) {
-      n[1].e = error;
-      n[2].data = (void *) s;
+      n[1].e = target;
+      n[2].ui = id;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->BeginQueryARB)( target, id );
    }
-   /* execute already done */
 }
 
 
-/*
- * Compile an error into current display list.
- */
-void
-_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
+static void GLAPIENTRY
+save_EndQueryARB(GLenum target)
 {
-   if (ctx->CompileFlag)
-      _mesa_save_error( ctx, error, s );
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_END_QUERY_ARB, 1 );
+   if (n) {
+      n[1].e = target;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EndQueryARB)( target );
+   }
+}
 
-   if (ctx->ExecuteFlag)
-      _mesa_error( ctx, error, s );
+#endif /* FEATURE_ARB_occlusion_query */
+
+
+static void GLAPIENTRY
+save_DrawBuffersARB(GLsizei count, const GLenum *buffers)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS );
+   if (n) {
+      GLint i;
+      n[1].i = count;
+      if (count > MAX_DRAW_BUFFERS)
+        count = MAX_DRAW_BUFFERS;
+      for (i = 0; i < count; i++) {
+        n[2 + i].e = buffers[i];
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->DrawBuffersARB)(count, buffers);
+   }
 }
 
+#if FEATURE_ATI_fragment_shader
+static void GLAPIENTRY
+save_BindFragmentShaderATI(GLuint id)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
+   if (n) {
+     n[1].ui = id;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->BindFragmentShaderATI)(id);
+   }
+}
 
+static void GLAPIENTRY
+save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
+   if (n) {
+     n[1].ui = dst;
+     n[2].f = value[0];
+     n[3].f = value[1];
+     n[4].f = value[2];
+     n[5].f = value[3];
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->SetFragmentShaderConstantATI)(dst, value);
+   }
+}
+#endif
 
-static GLboolean
-islist(GLcontext *ctx, GLuint list)
+static void save_Attr1fNV( GLenum attr, GLfloat x )
 {
-   if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
-      return GL_TRUE;
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F_NV, 2 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
    }
-   else {
-      return GL_FALSE;
+
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 1;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib1fNV)( attr, x );
    }
 }
 
+static void save_Attr2fNV( GLenum attr, GLfloat x, GLfloat y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F_NV, 3 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+   }
+
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 2;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
 
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib2fNV)( attr, x, y );
+   }
+}
 
-/**********************************************************************/
-/*                     Display list execution                         */
-/**********************************************************************/
+static void save_Attr3fNV( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F_NV, 4 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+      n[4].f = z;
+   }
 
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 3;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
 
-/*
- * Execute a display list.  Note that the ListBase offset must have already
- * been added before calling this function.  I.e. the list argument is
- * the absolute list number, not relative to ListBase.
- * \param list - display list number
- */
-static void GLAPIENTRY
-execute_list( GLcontext *ctx, GLuint list )
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib3fNV)( attr, x, y, z );
+   }
+}
+
+static void save_Attr4fNV( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
+                           GLfloat w )
 {
+   GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   GLboolean done;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F_NV, 5 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+      n[4].f = z;
+      n[5].f = w;
+   }
 
-   if (list == 0 || !islist(ctx,list))
-      return;
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 4;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
 
-   if (ctx->Driver.BeginCallList)
-      ctx->Driver.BeginCallList( ctx, list );
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib4fNV)( attr, x, y, z, w );
+   }
+}
 
-   ctx->CallDepth++;
 
-   n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+static void save_Attr1fARB( GLenum attr, GLfloat x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F_ARB, 2 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+   }
 
-   done = GL_FALSE;
-   while (!done) {
-      OpCode opcode = n[0].opcode;
-      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 1;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
 
-      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:
-           _mesa_error( ctx, n[1].e, (const char *) n[2].data );
-           break;
-         case OPCODE_ACCUM:
-           (*ctx->Exec->Accum)( n[1].e, n[2].f );
-           break;
-         case OPCODE_ALPHA_FUNC:
-           (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
-           break;
-         case OPCODE_BIND_TEXTURE:
-            (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib1fARB)( attr, x );
+   }
+}
+
+static void save_Attr2fARB( GLenum attr, GLfloat x, GLfloat y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F_ARB, 3 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+   }
+
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 2;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib2fARB)( attr, x, y );
+   }
+}
+
+static void save_Attr3fARB( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F_ARB, 4 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+      n[4].f = z;
+   }
+
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 3;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib3fARB)( attr, x, y, z );
+   }
+}
+
+static void save_Attr4fARB( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
+                           GLfloat w )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F_ARB, 5 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+      n[4].f = z;
+      n[5].f = w;
+   }
+
+   ASSERT(attr < VERT_ATTRIB_MAX);
+   ctx->ListState.ActiveAttribSize[attr] = 4;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib4fARB)( attr, x, y, z, w );
+   }
+}
+
+
+static void GLAPIENTRY save_EvalCoord1f( GLfloat x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C1, 1 );
+   if (n) {
+      n[1].f = x;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalCoord1f)( x );
+   }
+}
+
+static void GLAPIENTRY save_EvalCoord1fv( const GLfloat *v )
+{
+   save_EvalCoord1f( v[0] );
+}
+
+static void GLAPIENTRY save_EvalCoord2f( GLfloat x, GLfloat y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C2, 2 );
+   if (n) {
+      n[1].f = x;
+      n[2].f = y;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalCoord2f)( x, y );
+   }
+}
+
+static void GLAPIENTRY save_EvalCoord2fv( const GLfloat *v )
+{
+   save_EvalCoord2f( v[0], v[1] );
+}
+
+
+static void GLAPIENTRY save_EvalPoint1( GLint x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P1, 1 );
+   if (n) {
+      n[1].i = x;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalPoint1)( x );
+   }
+}
+
+static void GLAPIENTRY save_EvalPoint2( GLint x, GLint y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P2, 2 );
+   if (n) {
+      n[1].i = x;
+      n[2].i = y;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalPoint2)( x, y );
+   }
+}
+
+static void GLAPIENTRY save_Indexf( GLfloat x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX, 1 );
+   if (n) {
+      n[1].f = x;
+   }
+
+   ctx->ListState.ActiveIndex = 1;
+   ctx->ListState.CurrentIndex = x;
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Indexi)( (GLint) x );
+   }
+}
+
+static void GLAPIENTRY save_Indexfv( const GLfloat *v )
+{
+   save_Indexf( v[0] );
+}
+
+static void GLAPIENTRY save_EdgeFlag( GLboolean x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EDGEFLAG, 1 );
+   if (n) {
+      n[1].b = x;
+   }
+
+   ctx->ListState.ActiveEdgeFlag = 1;
+   ctx->ListState.CurrentEdgeFlag = x;
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EdgeFlag)( x );
+   }
+}
+
+static void GLAPIENTRY save_EdgeFlagv( const GLboolean *v )
+{
+   save_EdgeFlag( v[0] );
+}
+
+static void GLAPIENTRY save_Materialfv( GLenum face, GLenum pname, const GLfloat *param )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   int args, i;
+
+   SAVE_FLUSH_VERTICES( ctx );
+
+   switch (face) {
+   case GL_BACK:
+   case GL_FRONT:
+   case GL_FRONT_AND_BACK:
+      break;
+   default:
+      _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(face)" );
+      return;
+   }
+
+   switch (pname) {
+   case GL_EMISSION:
+   case GL_AMBIENT:
+   case GL_DIFFUSE:
+   case GL_SPECULAR:
+   case GL_AMBIENT_AND_DIFFUSE:
+      args = 4;
+      break;
+   case GL_SHININESS:
+      args = 1;
+      break;
+   case GL_COLOR_INDEXES:
+      args = 3;
+      break;
+   default:
+      _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(pname)" );
+      return;
+   }
+
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_MATERIAL, 6 );
+   if (n) {
+      n[1].e = face;
+      n[2].e = pname;
+      for (i = 0 ; i < args ; i++)
+        n[3+i].f = param[i];
+   }
+
+   {
+      GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, NULL );
+      for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
+        if (bitmask & (1<<i)) {
+           ctx->ListState.ActiveMaterialSize[i] = args;
+           COPY_SZ_4V( ctx->ListState.CurrentMaterial[i], args, param );
+        }
+   }
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Materialfv)( face, pname, param );
+   }
+}
+
+static void GLAPIENTRY save_Begin( GLenum mode )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   GLboolean error = GL_FALSE;
+
+   if (/*mode < GL_POINTS ||*/ mode > GL_POLYGON) {
+      _mesa_compile_error( ctx, GL_INVALID_ENUM, "Begin (mode)");
+      error = GL_TRUE;
+   }
+   else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
+      /* Typically the first begin.  This may raise an error on
+       * playback, depending on whether CallList is issued from inside
+       * a begin/end or not.
+       */
+      ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
+   }
+   else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
+      ctx->Driver.CurrentSavePrimitive = mode;
+   }
+   else {
+      _mesa_compile_error( ctx, GL_INVALID_OPERATION, "recursive begin" );
+      error = GL_TRUE;
+   }
+
+   if (!error) {
+      /* Give the driver an opportunity to hook in an optimized
+       * display list compiler.
+       */
+      if (ctx->Driver.NotifySaveBegin( ctx, mode ))
+        return;
+
+      SAVE_FLUSH_VERTICES( ctx );
+      n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN, 1 );
+      if (n) {
+        n[1].e = mode;
+      }
+   }
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Begin)( mode );
+   }
+}
+
+static void GLAPIENTRY save_End( void )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   SAVE_FLUSH_VERTICES( ctx );
+   (void) ALLOC_INSTRUCTION( ctx, OPCODE_END, 0 );
+   ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->End)( );
+   }
+}
+
+static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_RECTF, 4 );
+   if (n) {
+      n[1].f = a;
+      n[2].f = b;
+      n[3].f = c;
+      n[4].f = d;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Rectf)( a, b, c, d );
+   }
+}
+
+
+static void GLAPIENTRY save_Vertex2f( GLfloat x, GLfloat y )
+{
+   save_Attr2fNV( VERT_ATTRIB_POS, x, y );
+}
+
+static void GLAPIENTRY save_Vertex2fv( const GLfloat *v )
+{
+   save_Attr2fNV( VERT_ATTRIB_POS, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3fNV( VERT_ATTRIB_POS, x, y, z );
+}
+
+static void GLAPIENTRY save_Vertex3fv( const GLfloat *v )
+{
+   save_Attr3fNV( VERT_ATTRIB_POS, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   save_Attr4fNV( VERT_ATTRIB_POS, x, y, z, w );
+}
+
+static void GLAPIENTRY save_Vertex4fv( const GLfloat *v )
+{
+   save_Attr4fNV( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_TexCoord1f( GLfloat x )
+{
+   save_Attr1fNV( VERT_ATTRIB_TEX0, x );
+}
+
+static void GLAPIENTRY save_TexCoord1fv( const GLfloat *v )
+{
+   save_Attr1fNV( VERT_ATTRIB_TEX0, v[0] );
+}
+
+static void GLAPIENTRY save_TexCoord2f( GLfloat x, GLfloat y )
+{
+   save_Attr2fNV( VERT_ATTRIB_TEX0, x, y );
+}
+
+static void GLAPIENTRY save_TexCoord2fv( const GLfloat *v )
+{
+   save_Attr2fNV( VERT_ATTRIB_TEX0, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3fNV( VERT_ATTRIB_TEX0, x, y, z );
+}
+
+static void GLAPIENTRY save_TexCoord3fv( const GLfloat *v )
+{
+   save_Attr3fNV( VERT_ATTRIB_TEX0, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   save_Attr4fNV( VERT_ATTRIB_TEX0, x, y, z, w );
+}
+
+static void GLAPIENTRY save_TexCoord4fv( const GLfloat *v )
+{
+   save_Attr4fNV( VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3fNV( VERT_ATTRIB_NORMAL, x, y, z );
+}
+
+static void GLAPIENTRY save_Normal3fv( const GLfloat *v )
+{
+   save_Attr3fNV( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_FogCoordfEXT( GLfloat x )
+{
+   save_Attr1fNV( VERT_ATTRIB_FOG, x );
+}
+
+static void GLAPIENTRY save_FogCoordfvEXT( const GLfloat *v )
+{
+   save_Attr1fNV( VERT_ATTRIB_FOG, v[0] );
+}
+
+static void GLAPIENTRY save_Color3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3fNV( VERT_ATTRIB_COLOR0, x, y, z );
+}
+
+static void GLAPIENTRY save_Color3fv( const GLfloat *v )
+{
+   save_Attr3fNV( VERT_ATTRIB_COLOR0, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   save_Attr4fNV( VERT_ATTRIB_COLOR0, x, y, z, w );
+}
+
+static void GLAPIENTRY save_Color4fv( const GLfloat *v )
+{
+   save_Attr4fNV( VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3fNV( VERT_ATTRIB_COLOR1, x, y, z );
+}
+
+static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
+{
+   save_Attr3fNV( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
+}
+
+
+/* Just call the respective ATTR for texcoord
+ */
+static void GLAPIENTRY save_MultiTexCoord1f( GLenum target, GLfloat x  )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr1fNV( attr, x );
+}
+
+static void GLAPIENTRY save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr1fNV( attr, v[0] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr2fNV( attr, x, y );
+}
+
+static void GLAPIENTRY save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr2fNV( attr, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
+                                   GLfloat z)
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr3fNV( attr, x, y, z );
+}
+
+static void GLAPIENTRY save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr3fNV( attr, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
+                                 GLfloat z, GLfloat w )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr4fNV( attr, x, y, z, w );
+}
+
+static void GLAPIENTRY save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr4fNV( attr, v[0], v[1], v[2], v[3] );
+}
+
+
+static void enum_error( void )
+{
+   GET_CURRENT_CONTEXT( ctx );
+   _mesa_error( ctx, GL_INVALID_ENUM, "VertexAttribfNV" );
+}
+
+/* First level for NV_vertex_program:
+ *
+ * Check for errors at compile time?.
+ */
+static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr1fNV( index, x );
+   else
+      enum_error(); 
+}
+
+static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr1fNV( index, v[0] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr2fNV( index, x, y );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr2fNV( index, v[0], v[1] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, 
+                                  GLfloat z )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr3fNV( index, x, y, z );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr3fNV( index, v[0], v[1], v[2] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
+                                  GLfloat z, GLfloat w )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr4fNV( index, x, y, z, w );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr4fNV( index, v[0], v[1], v[2], v[3] );
+   else
+      enum_error();
+}
+
+
+
+
+static void GLAPIENTRY
+save_VertexAttrib1fARB( GLuint index, GLfloat x )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr1fARB( index, x );
+   else
+      enum_error(); 
+}
+
+static void GLAPIENTRY
+save_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr1fARB( index, v[0] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr2fARB( index, x, y );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr2fARB( index, v[0], v[1] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr3fARB( index, x, y, z );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr3fARB( index, v[0], v[1], v[2] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr4fARB( index, x, y, z, w );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr4fARB( index, v[0], v[1], v[2], v[3] );
+   else
+      enum_error();
+}
+
+
+
+
+
+/* KW: Compile commands
+ *
+ * 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
+_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
+{
+   Node *n;
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
+   if (n) {
+      n[1].e = error;
+      n[2].data = (void *) s;
+   }
+   /* execute already done */
+}
+
+
+/*
+ * Compile an error into current display list.
+ */
+void
+_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
+{
+   if (ctx->CompileFlag)
+      _mesa_save_error( ctx, error, s );
+
+   if (ctx->ExecuteFlag)
+      _mesa_error( ctx, error, s );
+}
+
+
+
+static GLboolean
+islist(GLcontext *ctx, GLuint list)
+{
+   if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
+      return GL_TRUE;
+   }
+   else {
+      return GL_FALSE;
+   }
+}
+
+
+
+/**********************************************************************/
+/*                     Display list execution                         */
+/**********************************************************************/
+
+
+/*
+ * Execute a display list.  Note that the ListBase offset must have already
+ * been added before calling this function.  I.e. the list argument is
+ * the absolute list number, not relative to ListBase.
+ * \param list - display list number
+ */
+static void GLAPIENTRY
+execute_list( GLcontext *ctx, GLuint list )
+{
+   struct mesa_display_list *dlist;
+   Node *n;
+   GLboolean done;
+
+   if (list == 0 || !islist(ctx,list))
+      return;
+
+   if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
+      /* raise an error? */
+      return;
+   }
+
+
+   dlist = (struct mesa_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+   if (!dlist)
+      return;
+
+   ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist;
+
+   if (ctx->Driver.BeginCallList)
+      ctx->Driver.BeginCallList( ctx, dlist );
+
+   n = dlist->node;
+
+   done = GL_FALSE;
+   while (!done) {
+      OpCode opcode = n[0].opcode;
+      int i = (int)n[0].opcode - (int)OPCODE_EXT_0;
+
+      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+         /* this is a driver-extended opcode */
+        ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
+        n += ctx->ListExt.Opcode[i].Size;
+      }
+      else {
+        switch (opcode) {
+        case OPCODE_ERROR:
+           _mesa_error( ctx, n[1].e, (const char *) n[2].data );
+           break;
+         case OPCODE_ACCUM:
+           (*ctx->Exec->Accum)( n[1].e, n[2].f );
+           break;
+         case OPCODE_ALPHA_FUNC:
+           (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
+           break;
+         case OPCODE_BIND_TEXTURE:
+            (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
             break;
         case OPCODE_BITMAP:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
                  n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
                ctx->Unpack = save;  /* restore */
@@ -4644,15 +5707,15 @@ execute_list( GLcontext *ctx, GLuint list )
         case OPCODE_BLEND_EQUATION:
            (*ctx->Exec->BlendEquation)( n[1].e );
            break;
-        case OPCODE_BLEND_FUNC:
-           (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
+        case OPCODE_BLEND_EQUATION_SEPARATE:
+           (*ctx->Exec->BlendEquationSeparateEXT)( n[1].e, n[2].e );
            break;
         case OPCODE_BLEND_FUNC_SEPARATE:
            (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
            break;
          case OPCODE_CALL_LIST:
            /* Generated by glCallList(), don't add ListBase */
-            if (ctx->CallDepth<MAX_LIST_NESTING) {
+            if (ctx->ListState.CallDepth<MAX_LIST_NESTING) {
                execute_list( ctx, n[1].ui );
             }
             break;
@@ -4662,7 +5725,7 @@ execute_list( GLcontext *ctx, GLuint list )
                /* user specified a bad data type at compile time */
                _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
             }
-            else if (ctx->CallDepth < MAX_LIST_NESTING) {
+            else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
                execute_list( ctx, ctx->List.ListBase + n[1].ui );
             }
             break;
@@ -4702,8 +5765,8 @@ execute_list( GLcontext *ctx, GLuint list )
            break;
          case OPCODE_COLOR_TABLE:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
                                          n[5].e, n[6].data );
                ctx->Unpack = save;  /* restore */
@@ -4731,8 +5794,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
          case OPCODE_COLOR_SUB_TABLE:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
                                             n[4].e, n[5].e, n[6].data );
                ctx->Unpack = save;  /* restore */
@@ -4740,8 +5803,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
          case OPCODE_CONVOLUTION_FILTER_1D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
                                                   n[4].e, n[5].e, n[6].data );
                ctx->Unpack = save;  /* restore */
@@ -4749,8 +5812,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
          case OPCODE_CONVOLUTION_FILTER_2D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
                                        n[4].i, n[5].e, n[6].e, n[7].data );
                ctx->Unpack = save;  /* restore */
@@ -4834,8 +5897,8 @@ execute_list( GLcontext *ctx, GLuint list )
            break;
         case OPCODE_DRAW_PIXELS:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
                                         n[5].data );
                ctx->Unpack = save;  /* restore */
@@ -5071,6 +6134,15 @@ execute_list( GLcontext *ctx, GLuint list )
         case OPCODE_STENCIL_OP:
            (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
            break;
+        case OPCODE_STENCIL_FUNC_SEPARATE:
+           ctx->Exec->StencilFuncSeparate( n[1].e, n[2].e, n[3].i, n[4].ui );
+           break;
+        case OPCODE_STENCIL_MASK_SEPARATE:
+           ctx->Exec->StencilMaskSeparate( n[1].e, n[2].ui );
+           break;
+        case OPCODE_STENCIL_OP_SEPARATE:
+           ctx->Exec->StencilOpSeparate( n[1].e, n[2].e, n[3].e, n[4].e );
+           break;
          case OPCODE_TEXENV:
             {
                GLfloat params[4];
@@ -5103,8 +6175,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
         case OPCODE_TEX_IMAGE1D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->TexImage1D)(
                                         n[1].e, /* target */
                                         n[2].i, /* level */
@@ -5119,8 +6191,8 @@ execute_list( GLcontext *ctx, GLuint list )
            break;
         case OPCODE_TEX_IMAGE2D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->TexImage2D)(
                                         n[1].e, /* target */
                                         n[2].i, /* level */
@@ -5136,8 +6208,8 @@ execute_list( GLcontext *ctx, GLuint list )
            break;
          case OPCODE_TEX_IMAGE3D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->TexImage3D)(
                                         n[1].e, /* target */
                                         n[2].i, /* level */
@@ -5154,8 +6226,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
          case OPCODE_TEX_SUB_IMAGE1D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
                                            n[4].i, n[5].e,
                                            n[6].e, n[7].data );
@@ -5164,8 +6236,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
          case OPCODE_TEX_SUB_IMAGE2D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
                                            n[4].i, n[5].e,
                                            n[6].i, n[7].e, n[8].e, n[9].data );
@@ -5174,8 +6246,8 @@ execute_list( GLcontext *ctx, GLuint list )
             break;
          case OPCODE_TEX_SUB_IMAGE3D:
             {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
                (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
                                            n[4].i, n[5].i, n[6].i, n[7].i,
                                            n[8].i, n[9].e, n[10].e,
@@ -5233,10 +6305,12 @@ execute_list( GLcontext *ctx, GLuint list )
         case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
             (*ctx->Exec->WindowPos3fMESA)( n[1].f, n[2].f, n[3].f );
            break;
-#if FEATURE_NV_vertex_program
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
          case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
             (*ctx->Exec->BindProgramNV)( n[1].e, n[2].ui );
             break;
+#endif
+#if FEATURE_NV_vertex_program
          case OPCODE_EXECUTE_PROGRAM_NV:
             {
                GLfloat v[4];
@@ -5291,6 +6365,139 @@ execute_list( GLcontext *ctx, GLuint list )
                                                    n[4].f, n[5].f, n[6].f);
             break;
 #endif
+#if FEATURE_ARB_occlusion_query
+         case OPCODE_BEGIN_QUERY_ARB:
+            ctx->Exec->BeginQueryARB(n[1].e, n[2].ui);
+            break;
+         case OPCODE_END_QUERY_ARB:
+            ctx->Exec->EndQueryARB(n[1].e);
+            break;
+#endif
+         case OPCODE_DRAW_BUFFERS_ARB:
+           {
+              GLenum buffers[MAX_DRAW_BUFFERS];
+              GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
+              for (i = 0; i < count; i++)
+                 buffers[i] = n[2 + i].e;
+              ctx->Exec->DrawBuffersARB(n[1].i, buffers);
+           }
+            break;
+#if FEATURE_ATI_fragment_shader
+        case OPCODE_BIND_FRAGMENT_SHADER_ATI:
+           ctx->Exec->BindFragmentShaderATI(n[1].i);
+           break;
+        case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: 
+           {
+              GLfloat values[4];
+              GLuint i, dst = n[1].ui;
+              
+              for (i = 0; i < 4; i++)
+                 values[i] = n[1+i].f;
+              ctx->Exec->SetFragmentShaderConstantATI(dst, values);
+           }
+           break;
+#endif
+        case OPCODE_ATTR_1F_NV:
+           (*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f);
+           break;
+        case OPCODE_ATTR_2F_NV:
+           /* Really shouldn't have to do this - the Node structure
+            * is convenient, but it would be better to store the data
+            * packed appropriately so that it can be sent directly
+            * on.  With x86_64 becoming common, this will start to
+            * matter more.
+            */
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
+           else
+              (*ctx->Exec->VertexAttrib2fNV)(n[1].e, n[2].f, n[3].f);
+           break;
+        case OPCODE_ATTR_3F_NV:
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
+           else
+              (*ctx->Exec->VertexAttrib3fNV)(n[1].e, n[2].f, n[3].f,
+                                             n[4].f);
+           break;
+        case OPCODE_ATTR_4F_NV:
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
+           else
+              (*ctx->Exec->VertexAttrib4fNV)(n[1].e, n[2].f, n[3].f,
+                                             n[4].f, n[5].f);
+           break;
+        case OPCODE_ATTR_1F_ARB:
+           (*ctx->Exec->VertexAttrib1fARB)(n[1].e, n[2].f);
+           break;
+        case OPCODE_ATTR_2F_ARB:
+           /* Really shouldn't have to do this - the Node structure
+            * is convenient, but it would be better to store the data
+            * packed appropriately so that it can be sent directly
+            * on.  With x86_64 becoming common, this will start to
+            * matter more.
+            */
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->VertexAttrib2fvARB)(n[1].e, &n[2].f);
+           else
+              (*ctx->Exec->VertexAttrib2fARB)(n[1].e, n[2].f, n[3].f);
+           break;
+        case OPCODE_ATTR_3F_ARB:
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->VertexAttrib3fvARB)(n[1].e, &n[2].f);
+           else
+              (*ctx->Exec->VertexAttrib3fARB)(n[1].e, n[2].f, n[3].f,
+                                             n[4].f);
+           break;
+        case OPCODE_ATTR_4F_ARB:
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->VertexAttrib4fvARB)(n[1].e, &n[2].f);
+           else
+              (*ctx->Exec->VertexAttrib4fARB)(n[1].e, n[2].f, n[3].f,
+                                             n[4].f, n[5].f);
+           break;
+        case OPCODE_MATERIAL:
+           if (sizeof(Node)==sizeof(GLfloat)) 
+              (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
+           else {
+              GLfloat f[4];
+              f[0] = n[3].f;
+              f[1] = n[4].f;
+              f[2] = n[5].f;
+              f[3] = n[6].f;
+              (*ctx->Exec->Materialfv)(n[1].e, n[2].e, f);
+           }
+           break;
+        case OPCODE_INDEX:
+           (*ctx->Exec->Indexi)(n[1].i);
+           break;
+        case OPCODE_EDGEFLAG:
+           (*ctx->Exec->EdgeFlag)(n[1].b);
+           break;
+        case OPCODE_BEGIN:
+           (*ctx->Exec->Begin)(n[1].e);
+           break;
+        case OPCODE_END:
+           (*ctx->Exec->End)();
+           break;
+        case OPCODE_RECTF:
+           (*ctx->Exec->Rectf)(n[1].f, n[2].f, n[3].f, n[4].f);
+           break;
+        case OPCODE_EVAL_C1:
+           (*ctx->Exec->EvalCoord1f)(n[1].f);
+           break;
+        case OPCODE_EVAL_C2:
+           (*ctx->Exec->EvalCoord2f)(n[1].f, n[2].f);
+           break;
+        case OPCODE_EVAL_P1:
+           (*ctx->Exec->EvalPoint1)(n[1].i);
+           break;
+        case OPCODE_EVAL_P2:
+           (*ctx->Exec->EvalPoint2)(n[1].i, n[2].i);
+           break;
+
+
+
+
         case OPCODE_CONTINUE:
            n = (Node *) n[1].next;
            break;
@@ -5312,10 +6519,11 @@ execute_list( GLcontext *ctx, GLuint list )
         }
       }
    }
-   ctx->CallDepth--;
 
    if (ctx->Driver.EndCallList)
       ctx->Driver.EndCallList( ctx );
+
+   ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL;
 }
 
 
@@ -5394,7 +6602,7 @@ _mesa_GenLists(GLsizei range )
       /* reserve the list IDs by with empty/dummy lists */
       GLint i;
       for (i=0; i<range; i++) {
-         _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
+         _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_list(base+i, 1));
       }
    }
 
@@ -5412,6 +6620,8 @@ void GLAPIENTRY
 _mesa_NewList( GLuint list, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
+   GLint i;
+
    FLUSH_CURRENT(ctx, 0);      /* must be called before assert */
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -5429,20 +6639,34 @@ _mesa_NewList( GLuint list, GLenum mode )
       return;
    }
 
-   if (ctx->CurrentListPtr) {
+   if (ctx->ListState.CurrentListPtr) {
       /* already compiling a display list */
       _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
       return;
    }
 
-   /* Allocate new display list */
-   ctx->CurrentListNum = list;
-   ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
-   ctx->CurrentListPtr = ctx->CurrentBlock;
-   ctx->CurrentPos = 0;
    ctx->CompileFlag = GL_TRUE;
    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
 
+   /* Allocate new display list */
+   ctx->ListState.CurrentListNum = list;
+   ctx->ListState.CurrentList = make_list( list, BLOCK_SIZE );
+   ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->node;
+   ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
+   ctx->ListState.CurrentPos = 0;
+
+   /* Reset acumulated list state:
+    */
+   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+      ctx->ListState.ActiveAttribSize[i] = 0;
+
+   for (i = 0; i < MAT_ATTRIB_MAX; i++)
+      ctx->ListState.ActiveMaterialSize[i] = 0;
+      
+   ctx->ListState.ActiveIndex = 0;
+   ctx->ListState.ActiveEdgeFlag = 0;
+
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
    ctx->Driver.NewList( ctx, list, mode );
 
    ctx->CurrentDispatch = ctx->Save;
@@ -5452,22 +6676,20 @@ _mesa_NewList( GLuint list, GLenum mode )
 
 
 /*
- * 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?
+ * End definition of current display list. 
  */
 void GLAPIENTRY
 _mesa_EndList( void )
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_CURRENT(ctx, 0);      /* must be called before assert */
+   SAVE_FLUSH_VERTICES(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    if (MESA_VERBOSE&VERBOSE_API)
       _mesa_debug(ctx, "glEndList\n");
 
    /* Check that a list is under construction */
-   if (!ctx->CurrentListPtr) {
+   if (!ctx->ListState.CurrentListPtr) {
       _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
       return;
    }
@@ -5475,21 +6697,22 @@ _mesa_EndList( void )
    (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
 
    /* Destroy old list, if any */
-   _mesa_destroy_list(ctx, ctx->CurrentListNum);
+   _mesa_destroy_list(ctx, ctx->ListState.CurrentListNum);
    /* Install the list */
-   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
+   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentList);
 
 
    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
-      mesa_print_display_list(ctx->CurrentListNum);
+      mesa_print_display_list(ctx->ListState.CurrentListNum);
+
+   ctx->Driver.EndList( ctx );
 
-   ctx->CurrentListNum = 0;
-   ctx->CurrentListPtr = NULL;
+   ctx->ListState.CurrentList = NULL;
+   ctx->ListState.CurrentListNum = 0;
+   ctx->ListState.CurrentListPtr = NULL;
    ctx->ExecuteFlag = GL_TRUE;
    ctx->CompileFlag = GL_FALSE;
 
-   ctx->Driver.EndList( ctx );
-
    ctx->CurrentDispatch = ctx->Exec;
    _glapi_set_dispatch( ctx->CurrentDispatch );
 }
@@ -6284,17 +7507,15 @@ static void GLAPIENTRY exec_MultiModeDrawElementsIBM(const GLenum *mode,
  * struct.
  */
 void
-_mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
+_mesa_init_dlist_table( struct _glapi_table *table )
 {
-   _mesa_init_no_op_table(table, tableSize);
-
-   _mesa_loopback_init_api_table( table, GL_TRUE );
+   _mesa_loopback_init_api_table( table );
 
    /* GL 1.0 */
    table->Accum = save_Accum;
    table->AlphaFunc = save_AlphaFunc;
    table->Bitmap = save_Bitmap;
-   table->BlendFunc = save_BlendFunc;
+   table->BlendFunc = _mesa_BlendFunc; /* loops-back to BlendFuncSeparate */
    table->CallList = _mesa_save_CallList;
    table->CallLists = _mesa_save_CallLists;
    table->Clear = save_Clear;
@@ -6501,6 +7722,11 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->TexImage3D = save_TexImage3D;
    table->TexSubImage3D = save_TexSubImage3D;
 
+   /* GL 2.0 */
+   table->StencilFuncSeparate = save_StencilFuncSeparate;
+   table->StencilMaskSeparate = save_StencilMaskSeparate;
+   table->StencilOpSeparate = save_StencilOpSeparate;
+
    /* GL_ARB_imaging */
    /* Not all are supported */
    table->BlendColor = save_BlendColor;
@@ -6686,6 +7912,12 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
 #endif
 
+   /* 245. GL_ATI_fragment_shader */
+#if FEATURE_ATI_fragment_shader
+   table->BindFragmentShaderATI = save_BindFragmentShaderATI;
+   table->SetFragmentShaderConstantATI = save_SetFragmentShaderConstantATI;
+#endif
+
    /* 282. GL_NV_fragment_program */
 #if FEATURE_NV_fragment_program
    table->ProgramNamedParameter4fNV = save_ProgramNamedParameter4fNV;
@@ -6748,7 +7980,7 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->EnableVertexAttribArrayARB = _mesa_EnableVertexAttribArrayARB;
    table->DisableVertexAttribArrayARB = _mesa_DisableVertexAttribArrayARB;
    table->ProgramStringARB = save_ProgramStringARB;
-   table->BindProgramNV = _mesa_BindProgram;
+   table->BindProgramNV = save_BindProgramNV;
    table->DeleteProgramsNV = _mesa_DeletePrograms;
    table->GenProgramsNV = _mesa_GenPrograms;
    table->IsProgramNV = _mesa_IsProgram;
@@ -6787,6 +8019,21 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->MapBufferARB = _mesa_MapBufferARB;
    table->UnmapBufferARB = _mesa_UnmapBufferARB;
 #endif
+
+#if FEATURE_ARB_occlusion_query
+   table->BeginQueryARB = save_BeginQueryARB;
+   table->EndQueryARB = save_EndQueryARB;
+   table->GenQueriesARB = _mesa_GenQueriesARB;
+   table->DeleteQueriesARB = _mesa_DeleteQueriesARB;
+   table->IsQueryARB = _mesa_IsQueryARB;
+   table->GetQueryivARB = _mesa_GetQueryivARB;
+   table->GetQueryObjectivARB = _mesa_GetQueryObjectivARB;
+   table->GetQueryObjectuivARB = _mesa_GetQueryObjectuivARB;
+#endif
+   table->DrawBuffersARB = save_DrawBuffersARB;
+
+   /* 299. GL_EXT_blend_equation_separate */
+   table->BlendEquationSeparateEXT = save_BlendEquationSeparateEXT;
 }
 
 
@@ -6806,26 +8053,32 @@ static const char *enum_string( GLenum k )
  */
 static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
 {
+   struct mesa_display_list *dlist;
    Node *n;
    GLboolean done;
 
-   if (!glIsList(list)) {
+   if (!GL_CALL(IsList)(list)) {
       _mesa_printf("%u is not a display list ID\n", list);
       return;
    }
 
-   n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+   dlist = (struct mesa_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+   if (!dlist)
+      return;
 
+   n = dlist->node;
+   
    _mesa_printf("START-LIST %u, address %p\n", list, (void*)n );
 
    done = n ? GL_FALSE : GL_TRUE;
    while (!done) {
       OpCode opcode = n[0].opcode;
-      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
+      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
 
-      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
-        ctx->listext.opcode[i].print(ctx, &n[1]);
-        n += ctx->listext.opcode[i].size;
+      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+         /* this is a driver-extended opcode */
+        ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
+        n += ctx->ListExt.Opcode[i].Size;
       }
       else {
         switch (opcode) {
@@ -6963,6 +8216,73 @@ static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
                          n[1].i, n[2].i, n[3].i, n[4].i);
            break;
 
+        case OPCODE_ATTR_1F_NV:
+           _mesa_printf("ATTR_1F_NV attr %d: %f\n",
+                        n[1].i, n[2].f);
+           break;
+        case OPCODE_ATTR_2F_NV:
+           _mesa_printf("ATTR_2F_NV attr %d: %f %f\n",
+                        n[1].i, n[2].f, n[3].f);
+           break;
+        case OPCODE_ATTR_3F_NV:
+           _mesa_printf("ATTR_3F_NV attr %d: %f %f %f\n",
+                        n[1].i, n[2].f, n[3].f, n[4].f);
+           break;
+        case OPCODE_ATTR_4F_NV:
+           _mesa_printf("ATTR_4F_NV attr %d: %f %f %f %f\n",
+                        n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
+           break;
+        case OPCODE_ATTR_1F_ARB:
+           _mesa_printf("ATTR_1F_ARB attr %d: %f\n",
+                        n[1].i, n[2].f);
+           break;
+        case OPCODE_ATTR_2F_ARB:
+           _mesa_printf("ATTR_2F_ARB attr %d: %f %f\n",
+                        n[1].i, n[2].f, n[3].f);
+           break;
+        case OPCODE_ATTR_3F_ARB:
+           _mesa_printf("ATTR_3F_ARB attr %d: %f %f %f\n",
+                        n[1].i, n[2].f, n[3].f, n[4].f);
+           break;
+        case OPCODE_ATTR_4F_ARB:
+           _mesa_printf("ATTR_4F_ARB attr %d: %f %f %f %f\n",
+                        n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
+           break;
+
+        case OPCODE_MATERIAL:
+           _mesa_printf("MATERIAL %x %x: %f %f %f %f\n",
+                        n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
+           break;
+        case OPCODE_INDEX:
+           _mesa_printf("INDEX: %f\n", n[1].f);
+           break;
+        case OPCODE_EDGEFLAG:
+           _mesa_printf("EDGEFLAG: %d\n", n[1].i);
+           break;
+        case OPCODE_BEGIN:
+           _mesa_printf("BEGIN %x\n", n[1].i);
+           break;
+        case OPCODE_END:
+           _mesa_printf("END\n");
+           break;
+        case OPCODE_RECTF:
+           _mesa_printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, n[4].f);
+           break;
+        case OPCODE_EVAL_C1:
+           _mesa_printf("EVAL_C1 %f\n", n[1].f);
+           break;
+        case OPCODE_EVAL_C2:
+           _mesa_printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
+           break;
+        case OPCODE_EVAL_P1:
+           _mesa_printf("EVAL_P1 %d\n", n[1].i);
+           break;
+        case OPCODE_EVAL_P2:
+           _mesa_printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
+           break;
+
+
+
         /*
          * meta opcodes/commands
          */
@@ -7014,18 +8334,106 @@ void mesa_print_display_list( GLuint list )
 /*****                      Initialization                        *****/
 /**********************************************************************/
 
+
+void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
+{
+   vfmt->ArrayElement = _ae_loopback_array_elt;                /* generic helper */
+   vfmt->Begin = save_Begin;
+   vfmt->CallList = _mesa_save_CallList;
+   vfmt->CallLists = _mesa_save_CallLists;
+   vfmt->Color3f = save_Color3f;
+   vfmt->Color3fv = save_Color3fv;
+   vfmt->Color4f = save_Color4f;
+   vfmt->Color4fv = save_Color4fv;
+   vfmt->EdgeFlag = save_EdgeFlag;
+   vfmt->EdgeFlagv = save_EdgeFlagv;
+   vfmt->End = save_End;
+   vfmt->EvalCoord1f = save_EvalCoord1f;
+   vfmt->EvalCoord1fv = save_EvalCoord1fv;
+   vfmt->EvalCoord2f = save_EvalCoord2f;
+   vfmt->EvalCoord2fv = save_EvalCoord2fv;
+   vfmt->EvalPoint1 = save_EvalPoint1;
+   vfmt->EvalPoint2 = save_EvalPoint2;
+   vfmt->FogCoordfEXT = save_FogCoordfEXT;
+   vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
+   vfmt->Indexf = save_Indexf;
+   vfmt->Indexfv = save_Indexfv;
+   vfmt->Materialfv = save_Materialfv;
+   vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
+   vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
+   vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
+   vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
+   vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
+   vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
+   vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
+   vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
+   vfmt->Normal3f = save_Normal3f;
+   vfmt->Normal3fv = save_Normal3fv;
+   vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
+   vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
+   vfmt->TexCoord1f = save_TexCoord1f;
+   vfmt->TexCoord1fv = save_TexCoord1fv;
+   vfmt->TexCoord2f = save_TexCoord2f;
+   vfmt->TexCoord2fv = save_TexCoord2fv;
+   vfmt->TexCoord3f = save_TexCoord3f;
+   vfmt->TexCoord3fv = save_TexCoord3fv;
+   vfmt->TexCoord4f = save_TexCoord4f;
+   vfmt->TexCoord4fv = save_TexCoord4fv;
+   vfmt->Vertex2f = save_Vertex2f;
+   vfmt->Vertex2fv = save_Vertex2fv;
+   vfmt->Vertex3f = save_Vertex3f;
+   vfmt->Vertex3fv = save_Vertex3fv;
+   vfmt->Vertex4f = save_Vertex4f;
+   vfmt->Vertex4fv = save_Vertex4fv;
+   vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
+   vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
+   vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
+   vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
+   vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
+   vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
+   vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
+   vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
+   vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB;
+   vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB;
+   vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB;
+   vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB;
+   vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB;
+   vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
+   vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
+   vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
+
+   vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
+   vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
+   vfmt->Rectf = save_Rectf;
+
+   /* The driver is required to implement these as
+    * 1) They can probably do a better job.
+    * 2) A lot of new mechanisms would have to be added to this module
+    *     to support it.  That code would probably never get used,
+    *     because of (1).
+    */
+#if 0
+   vfmt->DrawArrays = 0;
+   vfmt->DrawElements = 0;
+   vfmt->DrawRangeElements = 0;
+#endif
+}
+
+
+
 void _mesa_init_display_list( GLcontext * ctx )
 {
    /* Display list */
-   ctx->CallDepth = 0;
+   ctx->ListState.CallDepth = 0;
    ctx->ExecuteFlag = GL_TRUE;
    ctx->CompileFlag = GL_FALSE;
-   ctx->CurrentListPtr = NULL;
-   ctx->CurrentBlock = NULL;
-   ctx->CurrentListNum = 0;
-   ctx->CurrentPos = 0;
+   ctx->ListState.CurrentListPtr = NULL;
+   ctx->ListState.CurrentBlock = NULL;
+   ctx->ListState.CurrentListNum = 0;
+   ctx->ListState.CurrentPos = 0;
 
    /* Display List group */
    ctx->List.ListBase = 0;
 
+   _mesa_save_vtxfmt_init( &ctx->ListState.ListVtxfmt );
 }