mesa: Make condrender.[ch] prototypes match.
[mesa.git] / src / mesa / main / dlist.c
index 35f9a3cf03ae577829684900ce266f958bc0f4f4..21a8216254bebc11e128fddaf6f934aa4c7aa3d1 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
+ * Version:  7.7
  *
- * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, Inc.  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"),
@@ -73,6 +74,7 @@
 #include "texstate.h"
 #include "mtypes.h"
 #include "varray.h"
+#include "vtxfmt.h"
 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
 #include "shader/arbprogram.h"
 #include "shader/program.h"
 #include "glapi/dispatch.h"
 
 
+
+/**
+ * Other parts of Mesa (such as the VBO module) can plug into the display
+ * list system.  This structure describes new display list instructions.
+ */
+struct gl_list_instruction
+{
+   GLuint Size;
+   void (*Execute)( GLcontext *ctx, void *data );
+   void (*Destroy)( GLcontext *ctx, void *data );
+   void (*Print)( GLcontext *ctx, void *data );
+};
+
+
+#define MAX_DLIST_EXT_OPCODES 16
+
+/**
+ * Used by device drivers to hook new commands into display lists.
+ */
+struct gl_list_extensions
+{
+   struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
+   GLuint NumOpcodes;
+};
+
+
+
 /**
  * Flush vertices.
  *
@@ -189,8 +218,13 @@ typedef enum
    OPCODE_CLEAR_DEPTH,
    OPCODE_CLEAR_INDEX,
    OPCODE_CLEAR_STENCIL,
+   OPCODE_CLEAR_BUFFER_IV,
+   OPCODE_CLEAR_BUFFER_UIV,
+   OPCODE_CLEAR_BUFFER_FV,
+   OPCODE_CLEAR_BUFFER_FI,
    OPCODE_CLIP_PLANE,
    OPCODE_COLOR_MASK,
+   OPCODE_COLOR_MASK_INDEXED,
    OPCODE_COLOR_MATERIAL,
    OPCODE_COLOR_TABLE,
    OPCODE_COLOR_TABLE_PARAMETER_FV,
@@ -215,9 +249,11 @@ typedef enum
    OPCODE_DEPTH_MASK,
    OPCODE_DEPTH_RANGE,
    OPCODE_DISABLE,
+   OPCODE_DISABLE_INDEXED,
    OPCODE_DRAW_BUFFER,
    OPCODE_DRAW_PIXELS,
    OPCODE_ENABLE,
+   OPCODE_ENABLE_INDEXED,
    OPCODE_EVALMESH1,
    OPCODE_EVALMESH2,
    OPCODE_FOG,
@@ -438,6 +474,10 @@ typedef union gl_dlist_node Node;
  */
 static GLuint InstSize[OPCODE_END_OF_LIST + 1];
 
+
+#if FEATURE_dlist
+
+
 void mesa_print_display_list(GLuint list);
 
 
@@ -472,6 +512,49 @@ lookup_list(GLcontext *ctx, GLuint list)
 }
 
 
+/** Is the given opcode an extension code? */
+static INLINE GLboolean
+is_ext_opcode(OpCode opcode)
+{
+   return (opcode >= OPCODE_EXT_0);
+}
+
+
+/** Destroy an extended opcode instruction */
+static GLint
+ext_opcode_destroy(GLcontext *ctx, Node *node)
+{
+   const GLint i = node[0].opcode - OPCODE_EXT_0;
+   GLint step;
+   ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]);
+   step = ctx->ListExt->Opcode[i].Size;
+   return step;
+}
+
+
+/** Execute an extended opcode instruction */
+static GLint
+ext_opcode_execute(GLcontext *ctx, Node *node)
+{
+   const GLint i = node[0].opcode - OPCODE_EXT_0;
+   GLint step;
+   ctx->ListExt->Opcode[i].Execute(ctx, &node[1]);
+   step = ctx->ListExt->Opcode[i].Size;
+   return step;
+}
+
+
+/** Print an extended opcode instruction */
+static GLint
+ext_opcode_print(GLcontext *ctx, Node *node)
+{
+   const GLint i = node[0].opcode - OPCODE_EXT_0;
+   GLint step;
+   ctx->ListExt->Opcode[i].Print(ctx, &node[1]);
+   step = ctx->ListExt->Opcode[i].Size;
+   return step;
+}
+
 
 /**
  * Delete the named display list, but don't remove from hash table.
@@ -487,16 +570,14 @@ _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist)
 
    done = block ? GL_FALSE : GL_TRUE;
    while (!done) {
+      const OpCode opcode = n[0].opcode;
 
       /* check for extension opcodes first */
-
-      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;
+      if (is_ext_opcode(opcode)) {
+         n += ext_opcode_destroy(ctx, n);
       }
       else {
-         switch (n[0].opcode) {
+         switch (opcode) {
             /* for some commands, we need to free malloc'd memory */
          case OPCODE_MAP1:
             _mesa_free(n[6].data);
@@ -784,14 +865,13 @@ unpack_image(GLcontext *ctx, GLuint dimensions,
 
 
 /**
- * Allocate space for a display list instruction.
+ * Allocate space for a display list instruction (opcode + payload space).
  * \param opcode  the instruction opcode (OPCODE_* value)
- * \param bytes   instruction size in bytes, not counting opcode.
- * \return pointer to the usable data area (not including the internal
- *         opcode).
+ * \param bytes   instruction payload size (not counting opcode)
+ * \return pointer to allocated memory (the opcode space)
  */
-void *
-_mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
+static Node *
+dlist_alloc(GLcontext *ctx, OpCode opcode, GLuint bytes)
 {
    const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
    Node *n;
@@ -825,9 +905,30 @@ _mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
    n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
    ctx->ListState.CurrentPos += numNodes;
 
-   n[0].opcode = (OpCode) opcode;
+   n[0].opcode = opcode;
 
-   return (void *) (n + 1);     /* return ptr to node following opcode */
+   return n;
+}
+
+
+
+/**
+ * Allocate space for a display list instruction.  Used by callers outside
+ * this file for things like VBO vertex data.
+ *
+ * \param opcode  the instruction opcode (OPCODE_* value)
+ * \param bytes   instruction size in bytes, not counting opcode.
+ * \return pointer to the usable data area (not including the internal
+ *         opcode).
+ */
+void *
+_mesa_dlist_alloc(GLcontext *ctx, GLuint opcode, GLuint bytes)
+{
+   Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes);
+   if (n)
+      return n + 1;  /* return pointer to payload area, after opcode */
+   else
+      return NULL;
 }
 
 
@@ -842,35 +943,39 @@ _mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
  * \return  the new opcode number or -1 if error
  */
 GLint
-_mesa_alloc_opcode(GLcontext *ctx,
-                   GLuint size,
-                   void (*execute) (GLcontext *, void *),
-                   void (*destroy) (GLcontext *, void *),
-                   void (*print) (GLcontext *, void *))
-{
-   if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
-      const GLuint i = ctx->ListExt.NumOpcodes++;
-      ctx->ListExt.Opcode[i].Size =
+_mesa_dlist_alloc_opcode(GLcontext *ctx,
+                         GLuint size,
+                         void (*execute) (GLcontext *, void *),
+                         void (*destroy) (GLcontext *, void *),
+                         void (*print) (GLcontext *, void *))
+{
+   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;
+      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;
 }
 
 
-
 /**
- * Allocate display list instruction.  Returns Node ptr to where the opcode
- * is stored.
- *   - nParams is the number of function parameters
- *   - return value a pointer to sizeof(Node) before the actual
- *     usable data area.
+ * Allocate space for a display list instruction.  The space is basically
+ * an array of Nodes where node[0] holds the opcode, node[1] is the first
+ * function parameter, node[2] is the second parameter, etc.
+ *
+ * \param opcode  one of OPCODE_x
+ * \param nparams  number of function parameters
+ * \return  pointer to start of instruction space
  */
-#define ALLOC_INSTRUCTION(CTX, OPCODE, NPARAMS) \
-    ((Node *)_mesa_alloc_instruction(CTX, OPCODE, (NPARAMS)*sizeof(Node)) - 1)
+static INLINE Node *
+alloc_instruction(GLcontext *ctx, OpCode opcode, GLuint nparams)
+{
+   return dlist_alloc(ctx, opcode, nparams * sizeof(Node));
+}
 
 
 
@@ -883,7 +988,7 @@ save_Accum(GLenum op, GLfloat value)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACCUM, 2);
+   n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
    if (n) {
       n[1].e = op;
       n[2].f = value;
@@ -900,7 +1005,7 @@ save_AlphaFunc(GLenum func, GLclampf ref)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ALPHA_FUNC, 2);
+   n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
    if (n) {
       n[1].e = func;
       n[2].f = (GLfloat) ref;
@@ -917,7 +1022,7 @@ save_BindTexture(GLenum target, GLuint texture)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_TEXTURE, 2);
+   n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
    if (n) {
       n[1].e = target;
       n[2].ui = texture;
@@ -936,7 +1041,7 @@ save_Bitmap(GLsizei width, GLsizei height,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BITMAP, 7);
+   n = alloc_instruction(ctx, OPCODE_BITMAP, 7);
    if (n) {
       n[1].i = (GLint) width;
       n[2].i = (GLint) height;
@@ -959,7 +1064,7 @@ save_BlendEquation(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_EQUATION, 1);
+   n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -975,7 +1080,7 @@ 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_EQUATION_SEPARATE, 2);
+   n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
    if (n) {
       n[1].e = modeRGB;
       n[2].e = modeA;
@@ -993,7 +1098,7 @@ save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = sfactorRGB;
       n[2].e = dfactorRGB;
@@ -1020,7 +1125,7 @@ save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_COLOR, 4);
+   n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
    if (n) {
       n[1].f = red;
       n[2].f = green;
@@ -1047,14 +1152,14 @@ static void invalidate_saved_current_state( GLcontext *ctx )
    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
 }
 
-void GLAPIENTRY
-_mesa_save_CallList(GLuint list)
+static void GLAPIENTRY
+save_CallList(GLuint list)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST, 1);
+   n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
    if (n) {
       n[1].ui = list;
    }
@@ -1070,8 +1175,8 @@ _mesa_save_CallList(GLuint list)
 }
 
 
-void GLAPIENTRY
-_mesa_save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
+static void GLAPIENTRY
+save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
 {
    GET_CURRENT_CONTEXT(ctx);
    GLint i;
@@ -1098,7 +1203,7 @@ _mesa_save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
 
    for (i = 0; i < num; i++) {
       GLint list = translate_id(i, type, lists);
-      Node *n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST_OFFSET, 2);
+      Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2);
       if (n) {
          n[1].i = list;
          n[2].b = typeErrorFlag;
@@ -1122,7 +1227,7 @@ save_Clear(GLbitfield mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
    if (n) {
       n[1].bf = mask;
    }
@@ -1132,13 +1237,117 @@ save_Clear(GLbitfield mask)
 }
 
 
+static void GLAPIENTRY
+save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].i = value[0];
+      if (buffer == GL_COLOR) {
+         n[4].i = value[1];
+         n[5].i = value[2];
+         n[6].i = value[3];
+      }
+      else {
+         n[4].i = 0;
+         n[5].i = 0;
+         n[6].i = 0;
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/
+   }
+}
+
+
+static void GLAPIENTRY
+save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].ui = value[0];
+      if (buffer == GL_COLOR) {
+         n[4].ui = value[1];
+         n[5].ui = value[2];
+         n[6].ui = value[3];
+      }
+      else {
+         n[4].ui = 0;
+         n[5].ui = 0;
+         n[6].ui = 0;
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/
+   }
+}
+
+
+static void GLAPIENTRY
+save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].f = value[0];
+      if (buffer == GL_COLOR) {
+         n[4].f = value[1];
+         n[5].f = value[2];
+         n[6].f = value[3];
+      }
+      else {
+         n[4].f = 0.0F;
+         n[5].f = 0.0F;
+         n[6].f = 0.0F;
+      }
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/
+   }
+}
+
+
+static void GLAPIENTRY
+save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
+                   GLfloat depth, GLint stencil)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
+   if (n) {
+      n[1].e = buffer;
+      n[2].i = drawbuffer;
+      n[3].f = depth;
+      n[4].i = stencil;
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/
+   }
+}
+
+
 static void GLAPIENTRY
 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_ACCUM, 4);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
    if (n) {
       n[1].f = red;
       n[2].f = green;
@@ -1157,7 +1366,7 @@ save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_COLOR, 4);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
    if (n) {
       n[1].f = red;
       n[2].f = green;
@@ -1176,7 +1385,7 @@ save_ClearDepth(GLclampd depth)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_DEPTH, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
    if (n) {
       n[1].f = (GLfloat) depth;
    }
@@ -1192,7 +1401,7 @@ save_ClearIndex(GLfloat c)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_INDEX, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
    if (n) {
       n[1].f = c;
    }
@@ -1208,7 +1417,7 @@ save_ClearStencil(GLint s)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_STENCIL, 1);
+   n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
    if (n) {
       n[1].i = s;
    }
@@ -1224,7 +1433,7 @@ save_ClipPlane(GLenum plane, const GLdouble * equ)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLIP_PLANE, 5);
+   n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
    if (n) {
       n[1].e = plane;
       n[2].f = (GLfloat) equ[0];
@@ -1246,7 +1455,7 @@ save_ColorMask(GLboolean red, GLboolean green,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_MASK, 4);
+   n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
    if (n) {
       n[1].b = red;
       n[2].b = green;
@@ -1259,6 +1468,27 @@ save_ColorMask(GLboolean red, GLboolean green,
 }
 
 
+static void GLAPIENTRY
+save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green,
+                      GLboolean blue, GLboolean alpha)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
+   if (n) {
+      n[1].ui = buf;
+      n[2].b = red;
+      n[3].b = green;
+      n[4].b = blue;
+      n[5].b = alpha;
+   }
+   if (ctx->ExecuteFlag) {
+      /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/
+   }
+}
+
+
 static void GLAPIENTRY
 save_ColorMaterial(GLenum face, GLenum mode)
 {
@@ -1266,7 +1496,7 @@ save_ColorMaterial(GLenum face, GLenum mode)
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_MATERIAL, 2);
+   n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
    if (n) {
       n[1].e = face;
       n[2].e = mode;
@@ -1291,7 +1521,7 @@ save_ColorTable(GLenum target, GLenum internalFormat,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE, 6);
+      n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6);
       if (n) {
          n[1].e = target;
          n[2].e = internalFormat;
@@ -1319,7 +1549,7 @@ save_ColorTableParameterfv(GLenum target, GLenum pname,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
+   n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1348,7 +1578,7 @@ save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
+   n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1377,7 +1607,7 @@ save_ColorSubTable(GLenum target, GLsizei start, GLsizei count,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_SUB_TABLE, 6);
+   n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6);
    if (n) {
       n[1].e = target;
       n[2].i = start;
@@ -1402,7 +1632,7 @@ save_CopyColorSubTable(GLenum target, GLsizei start,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
+   n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
    if (n) {
       n[1].e = target;
       n[2].i = start;
@@ -1424,7 +1654,7 @@ save_CopyColorTable(GLenum target, GLenum internalformat,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_COLOR_TABLE, 5);
+   n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5);
    if (n) {
       n[1].e = target;
       n[2].e = internalformat;
@@ -1447,7 +1677,7 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
    if (n) {
       n[1].e = target;
       n[2].e = internalFormat;
@@ -1474,7 +1704,7 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
    if (n) {
       n[1].e = target;
       n[2].e = internalFormat;
@@ -1499,7 +1729,7 @@ save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1517,7 +1747,7 @@ save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1545,7 +1775,7 @@ save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1564,7 +1794,7 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
+   n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1592,7 +1822,7 @@ save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_PIXELS, 5);
+   n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -1614,7 +1844,7 @@ save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1640,7 +1870,7 @@ save_CopyTexImage2D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1666,7 +1896,7 @@ save_CopyTexSubImage1D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1690,7 +1920,7 @@ save_CopyTexSubImage2D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1716,7 +1946,7 @@ save_CopyTexSubImage3D(GLenum target, GLint level,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
+   n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -1742,7 +1972,7 @@ save_CullFace(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_CULL_FACE, 1);
+   n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -1758,7 +1988,7 @@ save_DepthFunc(GLenum func)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_FUNC, 1);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
    if (n) {
       n[1].e = func;
    }
@@ -1774,7 +2004,7 @@ save_DepthMask(GLboolean mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_MASK, 1);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
    if (n) {
       n[1].b = mask;
    }
@@ -1790,7 +2020,7 @@ save_DepthRange(GLclampd nearval, GLclampd farval)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_RANGE, 2);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
    if (n) {
       n[1].f = (GLfloat) nearval;
       n[2].f = (GLfloat) farval;
@@ -1807,7 +2037,7 @@ save_Disable(GLenum cap)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DISABLE, 1);
+   n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
    if (n) {
       n[1].e = cap;
    }
@@ -1817,13 +2047,30 @@ save_Disable(GLenum cap)
 }
 
 
+static void GLAPIENTRY
+save_DisableIndexed(GLuint index, GLenum cap)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
+   if (n) {
+      n[1].ui = index;
+      n[2].e = cap;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_DisableIndexedEXT(ctx->Exec, (index, cap));
+   }
+}
+
+
 static void GLAPIENTRY
 save_DrawBuffer(GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_BUFFER, 1);
+   n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -1842,7 +2089,7 @@ save_DrawPixels(GLsizei width, GLsizei height,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_PIXELS, 5);
+   n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5);
    if (n) {
       n[1].i = width;
       n[2].i = height;
@@ -1864,7 +2111,7 @@ save_Enable(GLenum cap)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ENABLE, 1);
+   n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
    if (n) {
       n[1].e = cap;
    }
@@ -1876,12 +2123,30 @@ save_Enable(GLenum cap)
 
 
 static void GLAPIENTRY
-_mesa_save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
+save_EnableIndexed(GLuint index, GLenum cap)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVALMESH1, 3);
+   n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
+   if (n) {
+      n[1].ui = index;
+      n[2].e = cap;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_EnableIndexedEXT(ctx->Exec, (index, cap));
+   }
+}
+
+
+
+static void GLAPIENTRY
+save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
    if (n) {
       n[1].e = mode;
       n[2].i = i1;
@@ -1894,12 +2159,12 @@ _mesa_save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
 
 
 static void GLAPIENTRY
-_mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
+save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVALMESH2, 5);
+   n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
    if (n) {
       n[1].e = mode;
       n[2].i = i1;
@@ -1921,7 +2186,7 @@ save_Fogfv(GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_FOG, 5);
+   n = alloc_instruction(ctx, OPCODE_FOG, 5);
    if (n) {
       n[1].e = pname;
       n[2].f = params[0];
@@ -1956,6 +2221,9 @@ save_Fogiv(GLenum pname, const GLint *params)
    case GL_FOG_END:
    case GL_FOG_INDEX:
       p[0] = (GLfloat) *params;
+      p[1] = 0.0f;
+      p[2] = 0.0f;
+      p[3] = 0.0f;
       break;
    case GL_FOG_COLOR:
       p[0] = INT_TO_FLOAT(params[0]);
@@ -1987,7 +2255,7 @@ save_FrontFace(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_FRONT_FACE, 1);
+   n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -2004,7 +2272,7 @@ save_Frustum(GLdouble left, GLdouble right,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_FRUSTUM, 6);
+   n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
    if (n) {
       n[1].f = (GLfloat) left;
       n[2].f = (GLfloat) right;
@@ -2025,7 +2293,7 @@ save_Hint(GLenum target, GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_HINT, 2);
+   n = alloc_instruction(ctx, OPCODE_HINT, 2);
    if (n) {
       n[1].e = target;
       n[2].e = mode;
@@ -2044,7 +2312,7 @@ save_Histogram(GLenum target, GLsizei width, GLenum internalFormat,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_HISTOGRAM, 4);
+   n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4);
    if (n) {
       n[1].e = target;
       n[2].i = width;
@@ -2063,7 +2331,7 @@ save_IndexMask(GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_INDEX_MASK, 1);
+   n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
    if (n) {
       n[1].ui = mask;
    }
@@ -2078,7 +2346,7 @@ save_InitNames(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_INIT_NAMES, 0);
+   (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
    if (ctx->ExecuteFlag) {
       CALL_InitNames(ctx->Exec, ());
    }
@@ -2091,7 +2359,7 @@ save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6);
+   n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
    if (n) {
       GLint i, nParams;
       n[1].e = light;
@@ -2205,7 +2473,7 @@ save_LightModelfv(GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT_MODEL, 5);
+   n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
    if (n) {
       n[1].e = pname;
       n[2].f = params[0];
@@ -2244,6 +2512,9 @@ save_LightModeliv(GLenum pname, const GLint *params)
    case GL_LIGHT_MODEL_TWO_SIDE:
    case GL_LIGHT_MODEL_COLOR_CONTROL:
       fparam[0] = (GLfloat) params[0];
+      fparam[1] = 0.0F;
+      fparam[2] = 0.0F;
+      fparam[3] = 0.0F;
       break;
    default:
       /* Error will be caught later in gl_LightModelfv */
@@ -2269,7 +2540,7 @@ save_LineStipple(GLint factor, GLushort pattern)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_STIPPLE, 2);
+   n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
    if (n) {
       n[1].i = factor;
       n[2].us = pattern;
@@ -2286,7 +2557,7 @@ save_LineWidth(GLfloat width)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_WIDTH, 1);
+   n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
    if (n) {
       n[1].f = width;
    }
@@ -2302,7 +2573,7 @@ save_ListBase(GLuint base)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIST_BASE, 1);
+   n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
    if (n) {
       n[1].ui = base;
    }
@@ -2317,7 +2588,7 @@ save_LoadIdentity(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_IDENTITY, 0);
+   (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
    if (ctx->ExecuteFlag) {
       CALL_LoadIdentity(ctx->Exec, ());
    }
@@ -2330,7 +2601,7 @@ save_LoadMatrixf(const GLfloat * m)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_MATRIX, 16);
+   n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
    if (n) {
       GLuint i;
       for (i = 0; i < 16; i++) {
@@ -2361,7 +2632,7 @@ save_LoadName(GLuint name)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_NAME, 1);
+   n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
    if (n) {
       n[1].ui = name;
    }
@@ -2377,7 +2648,7 @@ save_LogicOp(GLenum opcode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOGIC_OP, 1);
+   n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
    if (n) {
       n[1].e = opcode;
    }
@@ -2394,7 +2665,7 @@ save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
+   n = alloc_instruction(ctx, OPCODE_MAP1, 6);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
       n[1].e = target;
@@ -2416,7 +2687,7 @@ save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
+   n = alloc_instruction(ctx, OPCODE_MAP1, 6);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
       n[1].e = target;
@@ -2441,7 +2712,7 @@ save_Map2d(GLenum target,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
+   n = alloc_instruction(ctx, OPCODE_MAP2, 10);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
                                               vstride, vorder, points);
@@ -2474,7 +2745,7 @@ save_Map2f(GLenum target,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
+   n = alloc_instruction(ctx, OPCODE_MAP2, 10);
    if (n) {
       GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
                                               vstride, vorder, points);
@@ -2503,7 +2774,7 @@ save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID1, 3);
+   n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
    if (n) {
       n[1].i = un;
       n[2].f = u1;
@@ -2529,7 +2800,7 @@ save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID2, 6);
+   n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
    if (n) {
       n[1].i = un;
       n[2].f = u1;
@@ -2560,7 +2831,7 @@ save_MatrixMode(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MATRIX_MODE, 1);
+   n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -2577,7 +2848,7 @@ save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MIN_MAX, 3);
+   n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3);
    if (n) {
       n[1].e = target;
       n[2].e = internalFormat;
@@ -2595,7 +2866,7 @@ save_MultMatrixf(const GLfloat * m)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MULT_MATRIX, 16);
+   n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
    if (n) {
       GLuint i;
       for (i = 0; i < 16; i++) {
@@ -2639,7 +2910,7 @@ save_Ortho(GLdouble left, GLdouble right,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ORTHO, 6);
+   n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
    if (n) {
       n[1].f = (GLfloat) left;
       n[2].f = (GLfloat) right;
@@ -2660,7 +2931,7 @@ save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_MAP, 3);
+   n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3);
    if (n) {
       n[1].e = map;
       n[2].i = mapsize;
@@ -2717,7 +2988,7 @@ save_PixelTransferf(GLenum pname, GLfloat param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_TRANSFER, 2);
+   n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
    if (n) {
       n[1].e = pname;
       n[2].f = param;
@@ -2741,7 +3012,7 @@ save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_ZOOM, 2);
+   n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
    if (n) {
       n[1].f = xfactor;
       n[2].f = yfactor;
@@ -2758,7 +3029,7 @@ save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_PARAMETERS, 4);
+   n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
    if (n) {
       n[1].e = pname;
       n[2].f = params[0];
@@ -2805,7 +3076,7 @@ save_PointSize(GLfloat size)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_SIZE, 1);
+   n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
    if (n) {
       n[1].f = size;
    }
@@ -2821,7 +3092,7 @@ save_PolygonMode(GLenum face, GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_MODE, 2);
+   n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
    if (n) {
       n[1].e = face;
       n[2].e = mode;
@@ -2840,7 +3111,7 @@ save_PolygonStipple(const GLubyte * pattern)
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_STIPPLE, 1);
+   n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1);
    if (n) {
       n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
                                pattern, &ctx->Unpack);
@@ -2857,7 +3128,7 @@ save_PolygonOffset(GLfloat factor, GLfloat units)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_OFFSET, 2);
+   n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
    if (n) {
       n[1].f = factor;
       n[2].f = units;
@@ -2882,7 +3153,7 @@ save_PopAttrib(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_ATTRIB, 0);
+   (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
    if (ctx->ExecuteFlag) {
       CALL_PopAttrib(ctx->Exec, ());
    }
@@ -2894,7 +3165,7 @@ save_PopMatrix(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_MATRIX, 0);
+   (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
    if (ctx->ExecuteFlag) {
       CALL_PopMatrix(ctx->Exec, ());
    }
@@ -2906,7 +3177,7 @@ save_PopName(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_NAME, 0);
+   (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
    if (ctx->ExecuteFlag) {
       CALL_PopName(ctx->Exec, ());
    }
@@ -2923,7 +3194,7 @@ save_PrioritizeTextures(GLsizei num, const GLuint * textures,
 
    for (i = 0; i < num; i++) {
       Node *n;
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
+      n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
       if (n) {
          n[1].ui = textures[i];
          n[2].f = priorities[i];
@@ -2941,7 +3212,7 @@ save_PushAttrib(GLbitfield mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_ATTRIB, 1);
+   n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
    if (n) {
       n[1].bf = mask;
    }
@@ -2956,7 +3227,7 @@ save_PushMatrix(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_MATRIX, 0);
+   (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
    if (ctx->ExecuteFlag) {
       CALL_PushMatrix(ctx->Exec, ());
    }
@@ -2969,7 +3240,7 @@ save_PushName(GLuint name)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_NAME, 1);
+   n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
    if (n) {
       n[1].ui = name;
    }
@@ -2985,7 +3256,7 @@ save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RASTER_POS, 4);
+   n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -3144,7 +3415,7 @@ save_PassThrough(GLfloat token)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PASSTHROUGH, 1);
+   n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
    if (n) {
       n[1].f = token;
    }
@@ -3160,7 +3431,7 @@ save_ReadBuffer(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_READ_BUFFER, 1);
+   n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -3176,7 +3447,7 @@ save_ResetHistogram(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_HISTOGRAM, 1);
+   n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1);
    if (n) {
       n[1].e = target;
    }
@@ -3192,7 +3463,7 @@ save_ResetMinmax(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_MIN_MAX, 1);
+   n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1);
    if (n) {
       n[1].e = target;
    }
@@ -3208,7 +3479,7 @@ save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ROTATE, 4);
+   n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
    if (n) {
       n[1].f = angle;
       n[2].f = x;
@@ -3234,7 +3505,7 @@ save_Scalef(GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SCALE, 3);
+   n = alloc_instruction(ctx, OPCODE_SCALE, 3);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -3259,7 +3530,7 @@ save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SCISSOR, 4);
+   n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -3293,7 +3564,7 @@ save_ShadeModel(GLenum mode)
    if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
       ctx->ListState.Current.ShadeModel = mode;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1);
+   n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -3306,7 +3577,7 @@ save_StencilFunc(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, 3);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
    if (n) {
       n[1].e = func;
       n[2].i = ref;
@@ -3324,7 +3595,7 @@ save_StencilMask(GLuint mask)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK, 1);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
    if (n) {
       n[1].ui = mask;
    }
@@ -3340,7 +3611,7 @@ save_StencilOp(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, 3);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
    if (n) {
       n[1].e = fail;
       n[2].e = zfail;
@@ -3358,7 +3629,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = face;
       n[2].e = func;
@@ -3379,7 +3650,7 @@ save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    /* GL_FRONT */
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = GL_FRONT;
       n[2].e = frontfunc;
@@ -3387,7 +3658,7 @@ save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
       n[4].ui = mask;
    }
    /* GL_BACK */
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
    if (n) {
       n[1].e = GL_BACK;
       n[2].e = backfunc;
@@ -3407,7 +3678,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
    if (n) {
       n[1].e = face;
       n[2].ui = mask;
@@ -3424,7 +3695,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
    if (n) {
       n[1].e = face;
       n[2].e = fail;
@@ -3443,7 +3714,7 @@ save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXENV, 6);
+   n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -3508,7 +3779,7 @@ save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXGEN, 6);
+   n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
    if (n) {
       n[1].e = coord;
       n[2].e = pname;
@@ -3583,7 +3854,7 @@ save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXPARAMETER, 6);
+   n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -3643,7 +3914,7 @@ save_TexImage1D(GLenum target,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE1D, 8);
+      n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3678,7 +3949,7 @@ save_TexImage2D(GLenum target,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE2D, 9);
+      n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3716,7 +3987,7 @@ save_TexImage3D(GLenum target,
    else {
       Node *n;
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE3D, 10);
+      n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3749,7 +4020,7 @@ save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
+   n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3778,7 +4049,7 @@ save_TexSubImage2D(GLenum target, GLint level,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
+   n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3809,7 +4080,7 @@ save_TexSubImage3D(GLenum target, GLint level,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
+   n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3839,7 +4110,7 @@ save_Translatef(GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRANSLATE, 3);
+   n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -3865,7 +4136,7 @@ save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_VIEWPORT, 4);
+   n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -3884,7 +4155,7 @@ save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_WINDOW_POS, 4);
+   n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -4045,7 +4316,7 @@ save_ActiveTextureARB(GLenum target)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_TEXTURE, 1);
+   n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
    if (n) {
       n[1].e = target;
    }
@@ -4118,7 +4389,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
+      n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -4164,7 +4435,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
+      n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -4211,7 +4482,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
+      n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -4254,7 +4525,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
+   n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -4294,7 +4565,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
+   n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -4336,7 +4607,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
+   n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -4369,7 +4640,7 @@ save_SampleCoverageARB(GLclampf value, GLboolean invert)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SAMPLE_COVERAGE, 2);
+   n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
    if (n) {
       n[1].f = value;
       n[2].b = invert;
@@ -4390,7 +4661,7 @@ save_BindProgramNV(GLenum target, GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_PROGRAM_NV, 2);
+   n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2);
    if (n) {
       n[1].e = target;
       n[2].ui = id;
@@ -4407,7 +4678,7 @@ save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4444,7 +4715,7 @@ save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
       const GLfloat * p = params;
 
       for (i = 0 ; i < count ; i++) {
-        n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
+        n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
         if (n) {
            n[1].e = target;
            n[2].ui = index;
@@ -4492,7 +4763,7 @@ save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
+   n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = id;
@@ -4538,7 +4809,7 @@ save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
+   n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
    if (n) {
       GLubyte *programCopy = (GLubyte *) _mesa_malloc(len);
       if (!programCopy) {
@@ -4565,7 +4836,7 @@ save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids)
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 2);
+   n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2);
    if (n) {
       GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
       if (!idCopy) {
@@ -4589,7 +4860,7 @@ save_TrackMatrixNV(GLenum target, GLuint address,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 4);
+   n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4);
    if (n) {
       n[1].e = target;
       n[2].ui = address;
@@ -4614,7 +4885,7 @@ save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4636,7 +4907,7 @@ save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4664,7 +4935,7 @@ save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
       const GLfloat * p = params;
 
       for (i = 0 ; i < count ; i++) {
-        n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+        n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
         if (n) {
            n[1].e = target;
            n[2].ui = index;
@@ -4691,7 +4962,7 @@ save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4713,7 +4984,7 @@ save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
       n[2].ui = index;
@@ -4736,7 +5007,7 @@ save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
    if (n) {
       GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
       if (!nameCopy) {
@@ -4795,7 +5066,7 @@ save_ActiveStencilFaceEXT(GLenum face)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
+   n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
    if (n) {
       n[1].e = face;
    }
@@ -4812,7 +5083,7 @@ 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_DEPTH_BOUNDS_EXT, 2);
+   n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
    if (n) {
       n[1].f = (GLfloat) zmin;
       n[2].f = (GLfloat) zmax;
@@ -4835,7 +5106,7 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
+   n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
    if (n) {
       GLubyte *programCopy = (GLubyte *) _mesa_malloc(len);
       if (!programCopy) {
@@ -4864,7 +5135,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
    if (n) {
       n[1].e = target;
       n[2].ui = id;
@@ -4881,7 +5152,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
    if (n) {
       n[1].e = target;
    }
@@ -4899,7 +5170,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
    if (n) {
       GLint i;
       n[1].i = count;
@@ -4920,7 +5191,7 @@ save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
+   n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
    if (n) {
       n[1].ui = pname;
       n[2].f = param[0];
@@ -4951,7 +5222,7 @@ save_BindFragmentShaderATI(GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
+   n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
    if (n) {
       n[1].ui = id;
    }
@@ -4966,7 +5237,7 @@ save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
+   n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
    if (n) {
       n[1].ui = dst;
       n[2].f = value[0];
@@ -4986,7 +5257,7 @@ save_Attr1fNV(GLenum attr, GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_NV, 2);
+   n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5007,7 +5278,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5029,7 +5300,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5052,7 +5323,7 @@ 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_NV, 5);
+   n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5077,7 +5348,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5098,7 +5369,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5120,7 +5391,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5143,7 +5414,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5);
    if (n) {
       n[1].e = attr;
       n[2].f = x;
@@ -5168,7 +5439,7 @@ save_EvalCoord1f(GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C1, 1);
+   n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
    if (n) {
       n[1].f = x;
    }
@@ -5189,7 +5460,7 @@ save_EvalCoord2f(GLfloat x, GLfloat y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C2, 2);
+   n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
    if (n) {
       n[1].f = x;
       n[2].f = y;
@@ -5212,7 +5483,7 @@ save_EvalPoint1(GLint x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P1, 1);
+   n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
    if (n) {
       n[1].i = x;
    }
@@ -5227,7 +5498,7 @@ save_EvalPoint2(GLint x, GLint y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    SAVE_FLUSH_VERTICES(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P2, 2);
+   n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
    if (n) {
       n[1].i = x;
       n[2].i = y;
@@ -5330,7 +5601,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
 
    SAVE_FLUSH_VERTICES(ctx);
 
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6);
+   n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
    if (n) {
       n[1].e = face;
       n[2].e = pname;
@@ -5373,7 +5644,7 @@ save_Begin(GLenum mode)
          return;
 
       SAVE_FLUSH_VERTICES(ctx);
-      n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN, 1);
+      n = alloc_instruction(ctx, OPCODE_BEGIN, 1);
       if (n) {
          n[1].e = mode;
       }
@@ -5389,7 +5660,7 @@ save_End(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    SAVE_FLUSH_VERTICES(ctx);
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_END, 0);
+   (void) alloc_instruction(ctx, OPCODE_END, 0);
    ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
    if (ctx->ExecuteFlag) {
       CALL_End(ctx->Exec, ());
@@ -5402,7 +5673,7 @@ 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);
+   n = alloc_instruction(ctx, OPCODE_RECTF, 4);
    if (n) {
       n[1].f = a;
       n[2].f = b;
@@ -5816,7 +6087,7 @@ save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
+   n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
    if (n) {
       n[1].i = srcX0;
       n[2].i = srcY0;
@@ -5845,7 +6116,7 @@ save_ProvokingVertexEXT(GLenum mode)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROVOKING_VERTEX, 1);
+   n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1);
    if (n) {
       n[1].e = mode;
    }
@@ -5863,7 +6134,7 @@ save_UseProgramObjectARB(GLhandleARB program)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_USE_PROGRAM, 1);
+   n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1);
    if (n) {
       n[1].ui = program;
    }
@@ -5879,7 +6150,7 @@ save_Uniform1fARB(GLint location, GLfloat x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1F, 2);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5896,7 +6167,7 @@ save_Uniform2fARB(GLint location, GLfloat x, GLfloat y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2F, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5914,7 +6185,7 @@ save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3F, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5933,7 +6204,7 @@ save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4F, 5);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5);
    if (n) {
       n[1].i = location;
       n[2].f = x;
@@ -5964,7 +6235,7 @@ save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -5981,7 +6252,7 @@ save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -5998,7 +6269,7 @@ save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6015,7 +6286,7 @@ save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4FV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6033,7 +6304,7 @@ save_Uniform1iARB(GLint location, GLint x)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1I, 2);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6049,7 +6320,7 @@ save_Uniform2iARB(GLint location, GLint x, GLint y)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2I, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6066,7 +6337,7 @@ save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3I, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6084,7 +6355,7 @@ save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4I, 5);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5);
    if (n) {
       n[1].i = location;
       n[2].i = x;
@@ -6105,7 +6376,7 @@ save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_1IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6122,7 +6393,7 @@ save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_2IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6139,7 +6410,7 @@ save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_3IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6156,7 +6427,7 @@ save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_4IV, 3);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6175,7 +6446,7 @@ save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX22, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6194,7 +6465,7 @@ save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX33, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6213,7 +6484,7 @@ save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX44, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6233,7 +6504,7 @@ save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX23, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6252,7 +6523,7 @@ save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX32, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6272,7 +6543,7 @@ save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX24, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6291,7 +6562,7 @@ save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX42, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6311,7 +6582,7 @@ save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX34, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6330,7 +6601,7 @@ save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_UNIFORM_MATRIX43, 4);
+   n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4);
    if (n) {
       n[1].i = location;
       n[2].i = count;
@@ -6354,7 +6625,7 @@ static void
 save_error(GLcontext *ctx, GLenum error, const char *s)
 {
    Node *n;
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_ERROR, 2);
+   n = alloc_instruction(ctx, OPCODE_ERROR, 2);
    if (n) {
       n[1].e = error;
       n[2].data = (void *) s;
@@ -6430,13 +6701,10 @@ execute_list(GLcontext *ctx, GLuint list)
 
    done = GL_FALSE;
    while (!done) {
-      OpCode opcode = n[0].opcode;
-      int i = (int) n[0].opcode - (int) OPCODE_EXT_0;
+      const OpCode opcode = n[0].opcode;
 
-      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;
+      if (is_ext_opcode(opcode)) {
+         n += ext_opcode_execute(ctx, n);
       }
       else {
          switch (opcode) {
@@ -6495,6 +6763,39 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_CLEAR:
             CALL_Clear(ctx->Exec, (n[1].bf));
             break;
+         case OPCODE_CLEAR_BUFFER_IV:
+            {
+               GLint value[4];
+               value[0] = n[3].i;
+               value[1] = n[4].i;
+               value[2] = n[5].i;
+               value[3] = n[6].i;
+               /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/
+            }
+            break;
+         case OPCODE_CLEAR_BUFFER_UIV:
+            {
+               GLuint value[4];
+               value[0] = n[3].ui;
+               value[1] = n[4].ui;
+               value[2] = n[5].ui;
+               value[3] = n[6].ui;
+               /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/
+            }
+            break;
+         case OPCODE_CLEAR_BUFFER_FV:
+            {
+               GLfloat value[4];
+               value[0] = n[3].f;
+               value[1] = n[4].f;
+               value[2] = n[5].f;
+               value[3] = n[6].f;
+               /*CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/
+            }
+            break;
+         case OPCODE_CLEAR_BUFFER_FI:
+            /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/
+            break;
          case OPCODE_CLEAR_COLOR:
             CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
             break;
@@ -6523,6 +6824,10 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_COLOR_MASK:
             CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
             break;
+         case OPCODE_COLOR_MASK_INDEXED:
+            CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b,
+                                                 n[4].b, n[5].b));
+            break;
          case OPCODE_COLOR_MATERIAL:
             CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
             break;
@@ -6665,6 +6970,9 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_DISABLE:
             CALL_Disable(ctx->Exec, (n[1].e));
             break;
+         case OPCODE_DISABLE_INDEXED:
+            CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e));
+            break;
          case OPCODE_DRAW_BUFFER:
             CALL_DrawBuffer(ctx->Exec, (n[1].e));
             break;
@@ -6680,6 +6988,9 @@ execute_list(GLcontext *ctx, GLuint list)
          case OPCODE_ENABLE:
             CALL_Enable(ctx->Exec, (n[1].e));
             break;
+         case OPCODE_ENABLE_INDEXED:
+            CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e));
+            break;
          case OPCODE_EVALMESH1:
             CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
             break;
@@ -7426,7 +7737,7 @@ execute_list(GLcontext *ctx, GLuint list)
 /**
  * Test if a display list number is valid.
  */
-GLboolean GLAPIENTRY
+static GLboolean GLAPIENTRY
 _mesa_IsList(GLuint list)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -7439,7 +7750,7 @@ _mesa_IsList(GLuint list)
 /**
  * Delete a sequence of consecutive display lists.
  */
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_DeleteLists(GLuint list, GLsizei range)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -7461,7 +7772,7 @@ _mesa_DeleteLists(GLuint list, GLsizei range)
  * Return a display list number, n, such that lists n through n+range-1
  * are free.
  */
-GLuint GLAPIENTRY
+static GLuint GLAPIENTRY
 _mesa_GenLists(GLsizei range)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -7501,7 +7812,7 @@ _mesa_GenLists(GLsizei range)
 /**
  * Begin a new display list.
  */
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_NewList(GLuint name, GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -7551,7 +7862,7 @@ _mesa_NewList(GLuint name, GLenum mode)
 /**
  * End definition of current display list. 
  */
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_EndList(void)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -7572,7 +7883,7 @@ _mesa_EndList(void)
     */
    ctx->Driver.EndList(ctx);
 
-   (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0);
+   (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
 
    /* Destroy old list, if any */
    destroy_list(ctx, ctx->ListState.CurrentList->Name);
@@ -7685,7 +7996,7 @@ _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
 /**
  * Set the offset added to list numbers in glCallLists.
  */
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_ListBase(GLuint base)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -8420,7 +8731,7 @@ exec_MultiModeDrawElementsIBM(const GLenum * mode,
  * struct.
  */
 void
-_mesa_init_dlist_table(struct _glapi_table *table)
+_mesa_init_save_table(struct _glapi_table *table)
 {
    _mesa_loopback_init_api_table(table);
 
@@ -8429,8 +8740,8 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_AlphaFunc(table, save_AlphaFunc);
    SET_Bitmap(table, save_Bitmap);
    SET_BlendFunc(table, save_BlendFunc);
-   SET_CallList(table, _mesa_save_CallList);
-   SET_CallLists(table, _mesa_save_CallLists);
+   SET_CallList(table, save_CallList);
+   SET_CallLists(table, save_CallLists);
    SET_Clear(table, save_Clear);
    SET_ClearAccum(table, save_ClearAccum);
    SET_ClearColor(table, save_ClearColor);
@@ -8439,6 +8750,7 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_ClearStencil(table, save_ClearStencil);
    SET_ClipPlane(table, save_ClipPlane);
    SET_ColorMask(table, save_ColorMask);
+   SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed);
    SET_ColorMaterial(table, save_ColorMaterial);
    SET_CopyPixels(table, save_CopyPixels);
    SET_CullFace(table, save_CullFace);
@@ -8447,12 +8759,14 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_DepthMask(table, save_DepthMask);
    SET_DepthRange(table, save_DepthRange);
    SET_Disable(table, save_Disable);
+   SET_DisableIndexedEXT(table, save_DisableIndexed);
    SET_DrawBuffer(table, save_DrawBuffer);
    SET_DrawPixels(table, save_DrawPixels);
    SET_Enable(table, save_Enable);
+   SET_EnableIndexedEXT(table, save_EnableIndexed);
    SET_EndList(table, _mesa_EndList);
-   SET_EvalMesh1(table, _mesa_save_EvalMesh1);
-   SET_EvalMesh2(table, _mesa_save_EvalMesh2);
+   SET_EvalMesh1(table, save_EvalMesh1);
+   SET_EvalMesh2(table, save_EvalMesh2);
    SET_Finish(table, exec_Finish);
    SET_Flush(table, exec_Flush);
    SET_Fogf(table, save_Fogf);
@@ -8993,6 +9307,19 @@ _mesa_init_dlist_table(struct _glapi_table *table)
 
    /* 364. GL_EXT_provoking_vertex */
    SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT);
+
+   /* GL 3.0 */
+#if 0
+   SET_ClearBufferiv(table, save_ClearBufferiv);
+   SET_ClearBufferuiv(table, save_ClearBufferuiv);
+   SET_ClearBufferfv(table, save_ClearBufferfv);
+   SET_ClearBufferfi(table, save_ClearBufferfi);
+#else
+   (void) save_ClearBufferiv;
+   (void) save_ClearBufferuiv;
+   (void) save_ClearBufferfv;
+   (void) save_ClearBufferfi;
+#endif
 }
 
 
@@ -9030,13 +9357,10 @@ print_list(GLcontext *ctx, GLuint list)
 
    done = n ? GL_FALSE : GL_TRUE;
    while (!done) {
-      OpCode opcode = n[0].opcode;
-      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
+      const OpCode opcode = n[0].opcode;
 
-      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;
+      if (is_ext_opcode(opcode)) {
+         n += ext_opcode_print(ctx, n);
       }
       else {
          switch (opcode) {
@@ -9294,20 +9618,18 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt)
    _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_);
 
    vfmt->Begin = save_Begin;
-   vfmt->CallList = _mesa_save_CallList;
-   vfmt->CallLists = _mesa_save_CallLists;
+
+   _MESA_INIT_DLIST_VTXFMT(vfmt, save_);
+
    vfmt->Color3f = save_Color3f;
    vfmt->Color3fv = save_Color3fv;
    vfmt->Color4f = save_Color4f;
    vfmt->Color4fv = save_Color4fv;
    vfmt->EdgeFlag = save_EdgeFlag;
    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;
+
+   _MESA_INIT_EVAL_VTXFMT(vfmt, save_);
+
    vfmt->FogCoordfEXT = save_FogCoordfEXT;
    vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
    vfmt->Indexf = save_Indexf;
@@ -9356,8 +9678,6 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt)
    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
@@ -9378,6 +9698,32 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt)
 }
 
 
+void
+_mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
+                           const GLvertexformat *vfmt)
+{
+   SET_CallList(disp, vfmt->CallList);
+   SET_CallLists(disp, vfmt->CallLists);
+}
+
+
+void _mesa_init_dlist_dispatch(struct _glapi_table *disp)
+{
+   SET_CallList(disp, _mesa_CallList);
+   SET_CallLists(disp, _mesa_CallLists);
+
+   SET_DeleteLists(disp, _mesa_DeleteLists);
+   SET_EndList(disp, _mesa_EndList);
+   SET_GenLists(disp, _mesa_GenLists);
+   SET_IsList(disp, _mesa_IsList);
+   SET_ListBase(disp, _mesa_ListBase);
+   SET_NewList(disp, _mesa_NewList);
+}
+
+
+#endif /* FEATURE_dlist */
+
+
 /**
  * Initialize display list state for given context.
  */
@@ -9392,6 +9738,9 @@ _mesa_init_display_list(GLcontext *ctx)
       tableInitialized = GL_TRUE;
    }
 
+   /* extension info */
+   ctx->ListExt = CALLOC_STRUCT(gl_list_extensions);
+
    /* Display list */
    ctx->ListState.CallDepth = 0;
    ctx->ExecuteFlag = GL_TRUE;
@@ -9402,5 +9751,15 @@ _mesa_init_display_list(GLcontext *ctx)
    /* Display List group */
    ctx->List.ListBase = 0;
 
+#if FEATURE_dlist
    _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt);
+#endif
+}
+
+
+void
+_mesa_free_display_list_data(GLcontext *ctx)
+{
+   free(ctx->ListExt);
+   ctx->ListExt = NULL;
 }