set table size to 1023 and use new HASH_FUNC() macro
[mesa.git] / src / mesa / main / dlist.c
index aada62d1f9f580b1c1297962117cfba358281519..effdb7702a7de5faa8727f0983cc09681e92742d 100644 (file)
@@ -1,11 +1,6 @@
-/**
- * \file dlist.c
- * Display lists management functions.
- */
-
 /*
  * Mesa 3-D graphics library
- * Version:  6.0
+ * Version:  6.3
  *
  * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
  */
 
 
+/**
+ * \file dlist.c
+ * Display lists management functions.
+ */
+
 #include "glheader.h"
 #include "imports.h"
 #include "api_arrayelt.h"
@@ -65,6 +65,7 @@
 #include "dlist.h"
 #include "macros.h"
 #include "matrix.h"
+#include "occlude.h"
 #include "pixel.h"
 #include "points.h"
 #include "polygon.h"
@@ -78,6 +79,9 @@
 #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"
@@ -164,6 +168,7 @@ 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,
@@ -309,15 +314,30 @@ 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,
-       OPCODE_ATTR_2F,
-       OPCODE_ATTR_3F,
-       OPCODE_ATTR_4F,
+       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,
@@ -334,7 +354,7 @@ typedef enum {
        OPCODE_ERROR,           /* raise compiled-in error */
        OPCODE_CONTINUE,
        OPCODE_END_OF_LIST,
-       OPCODE_DRV_0
+       OPCODE_EXT_0
 } OpCode;
 
 
@@ -392,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;
 }
 
 
@@ -407,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) {
@@ -552,6 +578,7 @@ void _mesa_destroy_list( GLcontext *ctx, GLuint list )
       }
    }
 
+   FREE( dlist );
    _mesa_HashRemove(ctx->Shared->DisplayList, list);
 }
 
@@ -618,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;
 
@@ -770,10 +801,28 @@ void _mesa_init_lists( void )
       InstSize[OPCODE_PROGRAM_STRING_ARB] = 5;
       InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7;
 #endif
-      InstSize[OPCODE_ATTR_1F] = 3;
-      InstSize[OPCODE_ATTR_2F] = 4;
-      InstSize[OPCODE_ATTR_3F] = 5;
-      InstSize[OPCODE_ATTR_4F] = 6;
+#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;
@@ -789,6 +838,32 @@ void _mesa_init_lists( void )
 }
 
 
+
+/**
+ * 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
@@ -803,7 +878,7 @@ _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
@@ -831,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;
 }
@@ -1247,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 );
@@ -1336,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 );
@@ -1407,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 );
@@ -1436,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 );
@@ -1801,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 );
@@ -3192,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);
@@ -3201,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 );
@@ -3230,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 );
 }
 
@@ -3357,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 );
@@ -3396,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 );
@@ -3438,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) {
@@ -3471,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) {
@@ -3502,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) {
@@ -3535,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) {
@@ -4488,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;
@@ -4588,19 +4738,112 @@ save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
 
 
+#ifdef FEATURE_ARB_occlusion_query
+
+static void GLAPIENTRY
+save_BeginQueryARB(GLenum target, GLuint id)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN_QUERY_ARB, 2 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = id;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->BeginQueryARB)( target, id );
+   }
+}
+
+
+static void GLAPIENTRY
+save_EndQueryARB(GLenum target)
+{
+   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 );
+   }
+}
+
+#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 void save_Attr1f( GLenum attr, GLfloat x )
+static void save_Attr1fNV( GLenum attr, GLfloat x )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES( ctx );
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F, 2 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F_NV, 2 );
    if (n) {
       n[1].e = attr;
       n[2].f = x;
    }
 
+   ASSERT(attr < VERT_ATTRIB_MAX);
    ctx->ListState.ActiveAttribSize[attr] = 1;
    ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
 
@@ -4609,18 +4852,19 @@ static void save_Attr1f( GLenum attr, GLfloat x )
    }
 }
 
-static void save_Attr2f( GLenum attr, GLfloat x, GLfloat y )
+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, 3 );
+   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);
 
@@ -4629,12 +4873,12 @@ static void save_Attr2f( GLenum attr, GLfloat x, GLfloat y )
    }
 }
 
-static void save_Attr3f( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
+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, 4 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F_NV, 4 );
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -4642,6 +4886,7 @@ static void save_Attr3f( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
       n[4].f = z;
    }
 
+   ASSERT(attr < VERT_ATTRIB_MAX);
    ctx->ListState.ActiveAttribSize[attr] = 3;
    ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
 
@@ -4650,13 +4895,13 @@ static void save_Attr3f( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
    }
 }
 
-static void save_Attr4f( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
-                        GLfloat w )
+static void save_Attr4fNV( 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, 5 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F_NV, 5 );
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -4665,6 +4910,7 @@ static void save_Attr4f( GLenum attr, GLfloat x, GLfloat y, GLfloat 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);
 
@@ -4673,6 +4919,95 @@ static void save_Attr4f( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
    }
 }
 
+
+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;
+   }
+
+   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->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);
@@ -4834,7 +5169,7 @@ static void GLAPIENTRY save_Materialfv( GLenum face, GLenum pname, const GLfloat
    }
 
    {
-      GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, 0 );
+      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;
@@ -4853,7 +5188,7 @@ static void GLAPIENTRY save_Begin( GLenum mode )
    Node *n;
    GLboolean error = GL_FALSE;
 
-   if (mode < GL_POINTS || mode > GL_POLYGON) {
+   if (/*mode < GL_POINTS ||*/ mode > GL_POLYGON) {
       _mesa_compile_error( ctx, GL_INVALID_ENUM, "Begin (mode)");
       error = GL_TRUE;
    }
@@ -4902,8 +5237,7 @@ static void GLAPIENTRY save_End( void )
    }
 }
 
-static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b,
-                       GLfloat c, GLfloat d )
+static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -4920,126 +5254,125 @@ static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b,
    }
 }
 
-/*
- */
+
 static void GLAPIENTRY save_Vertex2f( GLfloat x, GLfloat y )
 {
-   save_Attr2f( VERT_ATTRIB_POS, x, y );
+   save_Attr2fNV( VERT_ATTRIB_POS, x, y );
 }
 
 static void GLAPIENTRY save_Vertex2fv( const GLfloat *v )
 {
-   save_Attr2f( VERT_ATTRIB_POS, v[0], v[1] );
+   save_Attr2fNV( VERT_ATTRIB_POS, v[0], v[1] );
 }
 
 static void GLAPIENTRY save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
 {
-   save_Attr3f( VERT_ATTRIB_POS, x, y, z );
+   save_Attr3fNV( VERT_ATTRIB_POS, x, y, z );
 }
 
 static void GLAPIENTRY save_Vertex3fv( const GLfloat *v )
 {
-   save_Attr3f( VERT_ATTRIB_POS, v[0], v[1], v[2] );
+   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_Attr4f( VERT_ATTRIB_POS, x, y, z, w );
+   save_Attr4fNV( VERT_ATTRIB_POS, x, y, z, w );
 }
 
 static void GLAPIENTRY save_Vertex4fv( const GLfloat *v )
 {
-   save_Attr4f( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
+   save_Attr4fNV( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
 }
 
 static void GLAPIENTRY save_TexCoord1f( GLfloat x )
 {
-   save_Attr1f( VERT_ATTRIB_TEX0, x );
+   save_Attr1fNV( VERT_ATTRIB_TEX0, x );
 }
 
 static void GLAPIENTRY save_TexCoord1fv( const GLfloat *v )
 {
-   save_Attr1f( VERT_ATTRIB_TEX0, v[0] );
+   save_Attr1fNV( VERT_ATTRIB_TEX0, v[0] );
 }
 
 static void GLAPIENTRY save_TexCoord2f( GLfloat x, GLfloat y )
 {
-   save_Attr2f( VERT_ATTRIB_TEX0, x, y );
+   save_Attr2fNV( VERT_ATTRIB_TEX0, x, y );
 }
 
 static void GLAPIENTRY save_TexCoord2fv( const GLfloat *v )
 {
-   save_Attr2f( VERT_ATTRIB_TEX0, v[0], v[1] );
+   save_Attr2fNV( VERT_ATTRIB_TEX0, v[0], v[1] );
 }
 
 static void GLAPIENTRY save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
 {
-   save_Attr3f( VERT_ATTRIB_TEX0, x, y, z );
+   save_Attr3fNV( VERT_ATTRIB_TEX0, x, y, z );
 }
 
 static void GLAPIENTRY save_TexCoord3fv( const GLfloat *v )
 {
-   save_Attr3f( VERT_ATTRIB_TEX0, v[0], v[1], v[2] );
+   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_Attr4f( VERT_ATTRIB_TEX0, x, y, z, w );
+   save_Attr4fNV( VERT_ATTRIB_TEX0, x, y, z, w );
 }
 
 static void GLAPIENTRY save_TexCoord4fv( const GLfloat *v )
 {
-   save_Attr4f( VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3] );
+   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_Attr3f( VERT_ATTRIB_NORMAL, x, y, z );
+   save_Attr3fNV( VERT_ATTRIB_NORMAL, x, y, z );
 }
 
 static void GLAPIENTRY save_Normal3fv( const GLfloat *v )
 {
-   save_Attr3f( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
+   save_Attr3fNV( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
 }
 
 static void GLAPIENTRY save_FogCoordfEXT( GLfloat x )
 {
-   save_Attr1f( VERT_ATTRIB_FOG, x );
+   save_Attr1fNV( VERT_ATTRIB_FOG, x );
 }
 
 static void GLAPIENTRY save_FogCoordfvEXT( const GLfloat *v )
 {
-   save_Attr1f( VERT_ATTRIB_FOG, v[0] );
+   save_Attr1fNV( VERT_ATTRIB_FOG, v[0] );
 }
 
 static void GLAPIENTRY save_Color3f( GLfloat x, GLfloat y, GLfloat z )
 {
-   save_Attr3f( VERT_ATTRIB_COLOR0, x, y, z );
+   save_Attr3fNV( VERT_ATTRIB_COLOR0, x, y, z );
 }
 
 static void GLAPIENTRY save_Color3fv( const GLfloat *v )
 {
-   save_Attr3f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2] );
+   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_Attr4f( VERT_ATTRIB_COLOR0, x, y, z, w );
+   save_Attr4fNV( VERT_ATTRIB_COLOR0, x, y, z, w );
 }
 
 static void GLAPIENTRY save_Color4fv( const GLfloat *v )
 {
-   save_Attr4f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3] );
+   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_Attr3f( VERT_ATTRIB_COLOR1, x, y, z );
+   save_Attr3fNV( VERT_ATTRIB_COLOR1, x, y, z );
 }
 
 static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
 {
-   save_Attr3f( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
+   save_Attr3fNV( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
 }
 
 
@@ -5048,51 +5381,51 @@ static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
 static void GLAPIENTRY save_MultiTexCoord1f( GLenum target, GLfloat x  )
 {
    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
-   save_Attr1f( attr, x );
+   save_Attr1fNV( attr, x );
 }
 
 static void GLAPIENTRY save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
-   save_Attr1f( attr, v[0] );
+   save_Attr1fNV( attr, v[0] );
 }
 
 static void GLAPIENTRY save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
 {
    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
-   save_Attr2f( attr, x, y );
+   save_Attr2fNV( attr, x, y );
 }
 
 static void GLAPIENTRY save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
-   save_Attr2f( attr, v[0], v[1] );
+   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_Attr3f( attr, x, y, z );
+   save_Attr3fNV( attr, x, y, z );
 }
 
 static void GLAPIENTRY save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
-   save_Attr3f( attr, v[0], v[1], v[2] );
+   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_Attr4f( attr, x, y, z, w );
+   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_Attr4f( attr, v[0], v[1], v[2], v[3] );
+   save_Attr4fNV( attr, v[0], v[1], v[2], v[3] );
 }
 
 
@@ -5109,7 +5442,7 @@ static void enum_error( void )
 static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr1f( index, x );
+      save_Attr1fNV( index, x );
    else
       enum_error(); 
 }
@@ -5117,7 +5450,7 @@ static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
 static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr1f( index, v[0] );
+      save_Attr1fNV( index, v[0] );
    else
       enum_error();
 }
@@ -5125,7 +5458,7 @@ static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
 static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr2f( index, x, y );
+      save_Attr2fNV( index, x, y );
    else
       enum_error();
 }
@@ -5133,7 +5466,7 @@ static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y
 static void GLAPIENTRY save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr2f( index, v[0], v[1] );
+      save_Attr2fNV( index, v[0], v[1] );
    else
       enum_error();
 }
@@ -5142,7 +5475,7 @@ static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y
                                   GLfloat z )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr3f( index, x, y, z );
+      save_Attr3fNV( index, x, y, z );
    else
       enum_error();
 }
@@ -5150,7 +5483,7 @@ static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y
 static void GLAPIENTRY save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr3f( index, v[0], v[1], v[2] );
+      save_Attr3fNV( index, v[0], v[1], v[2] );
    else
       enum_error();
 }
@@ -5159,7 +5492,7 @@ static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y
                                   GLfloat z, GLfloat w )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr4f( index, x, y, z, w );
+      save_Attr4fNV( index, x, y, z, w );
    else
       enum_error();
 }
@@ -5167,7 +5500,82 @@ static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y
 static void GLAPIENTRY save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
 {
    if (index < VERT_ATTRIB_MAX)
-      save_Attr4f( index, v[0], v[1], v[2], v[3] );
+      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();
 }
@@ -5236,27 +5644,39 @@ islist(GLcontext *ctx, GLuint list)
 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->Driver.BeginCallList)
-      ctx->Driver.BeginCallList( ctx, list );
+   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.CallDepth++;
+   ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist;
 
-   n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+   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_DRV_0;
+      int i = (int)n[0].opcode - (int)OPCODE_EXT_0;
 
-      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
-        ctx->listext.opcode[i].execute(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].Execute(ctx, &n[1]);
+        n += ctx->ListExt.Opcode[i].Size;
       }
       else {
         switch (opcode) {
@@ -5274,8 +5694,8 @@ execute_list( GLcontext *ctx, GLuint list )
             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 */
@@ -5345,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 */
@@ -5374,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 */
@@ -5383,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 */
@@ -5392,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 */
@@ -5477,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 */
@@ -5714,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];
@@ -5746,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 */
@@ -5762,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 */
@@ -5779,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 */
@@ -5797,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 );
@@ -5807,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 );
@@ -5817,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,
@@ -5936,21 +6365,107 @@ execute_list( GLcontext *ctx, GLuint list )
                                                    n[4].f, n[5].f, n[6].f);
             break;
 #endif
-
-        case OPCODE_ATTR_1F:
+#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:
-           (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
+        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_3F:
-           (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
+        case OPCODE_ATTR_1F_ARB:
+           (*ctx->Exec->VertexAttrib1fARB)(n[1].e, n[2].f);
            break;
-        case OPCODE_ATTR_4F:
-           (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
+        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:
-           (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
+           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);
@@ -5971,7 +6486,7 @@ execute_list( GLcontext *ctx, GLuint list )
            (*ctx->Exec->EvalCoord1f)(n[1].f);
            break;
         case OPCODE_EVAL_C2:
-           (*ctx->Exec->EvalCoord2fv)(&n[1].f);
+           (*ctx->Exec->EvalCoord2f)(n[1].f, n[2].f);
            break;
         case OPCODE_EVAL_P1:
            (*ctx->Exec->EvalPoint1)(n[1].i);
@@ -6004,10 +6519,11 @@ execute_list( GLcontext *ctx, GLuint list )
         }
       }
    }
-   ctx->ListState.CallDepth--;
 
    if (ctx->Driver.EndCallList)
       ctx->Driver.EndCallList( ctx );
+
+   ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL;
 }
 
 
@@ -6086,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));
       }
    }
 
@@ -6134,7 +6650,8 @@ _mesa_NewList( GLuint list, GLenum mode )
 
    /* Allocate new display list */
    ctx->ListState.CurrentListNum = list;
-   ctx->ListState.CurrentBlock = (Node *) CALLOC( sizeof(Node) * BLOCK_SIZE );
+   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;
 
@@ -6182,19 +6699,20 @@ _mesa_EndList( void )
    /* Destroy old list, if any */
    _mesa_destroy_list(ctx, ctx->ListState.CurrentListNum);
    /* Install the list */
-   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentListPtr);
+   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentList);
 
 
    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
       mesa_print_display_list(ctx->ListState.CurrentListNum);
 
+   ctx->Driver.EndList( ctx );
+
+   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 );
 }
@@ -6989,16 +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 1.0 */
    table->Accum = save_Accum;
    table->AlphaFunc = save_AlphaFunc;
    table->Bitmap = save_Bitmap;
+   table->BlendFunc = _mesa_BlendFunc; /* loops-back to BlendFuncSeparate */
    table->CallList = _mesa_save_CallList;
    table->CallLists = _mesa_save_CallLists;
    table->Clear = save_Clear;
@@ -7205,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;
@@ -7390,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;
@@ -7492,6 +8020,18 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    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;
 }
@@ -7513,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) {
@@ -7670,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
          */
@@ -7780,6 +8393,14 @@ void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
    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;