mesa: don't include m_xform.h where not needed
[mesa.git] / src / mesa / main / dlist.c
index 5b9391096a036399e70d84af2c6a13ac7a2ef9f1..76b33150346daa21ad6c3d6b9623ff63f03e2d98 100644 (file)
@@ -41,7 +41,6 @@
 #endif
 #include "arrayobj.h"
 #include "clip.h"
-#include "colormac.h"
 #include "colortab.h"
 #include "context.h"
 #include "convolve.h"
@@ -52,6 +51,7 @@
 #include "eval.h"
 #include "extensions.h"
 #include "feedback.h"
+#include "framebuffer.h"
 #include "get.h"
 #include "glapi/glapi.h"
 #include "hash.h"
@@ -85,7 +85,6 @@
 #endif
 
 #include "math/m_matrix.h"
-#include "math/m_xform.h"
 
 #include "glapi/dispatch.h"
 
@@ -303,7 +302,6 @@ typedef enum
    OPCODE_EXECUTE_PROGRAM_NV,
    OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
    OPCODE_LOAD_PROGRAM_NV,
-   OPCODE_PROGRAM_PARAMETER4F_NV,
    OPCODE_TRACK_MATRIX_NV,
    /* GL_NV_fragment_program */
    OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
@@ -371,7 +369,7 @@ typedef enum
  * contiguous nodes in memory.
  * Each node is the union of a variety of data types.
  */
-union node
+union gl_dlist_node
 {
    OpCode opcode;
    GLboolean b;
@@ -388,6 +386,9 @@ union node
 };
 
 
+typedef union gl_dlist_node Node;
+
+
 /**
  * How many nodes to allocate at a time.
  *
@@ -415,13 +416,13 @@ void mesa_print_display_list(GLuint list);
  * Make an empty display list.  This is used by glGenLists() to
  * reserve display list IDs.
  */
-static struct mesa_display_list *
-make_list(GLuint list, GLuint count)
+static struct gl_display_list *
+make_list(GLuint name, GLuint count)
 {
-   struct mesa_display_list *dlist = CALLOC_STRUCT(mesa_display_list);
-   dlist->id = list;
-   dlist->node = (Node *) _mesa_malloc(sizeof(Node) * count);
-   dlist->node[0].opcode = OPCODE_END_OF_LIST;
+   struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
+   dlist->Name = name;
+   dlist->Head = (Node *) _mesa_malloc(sizeof(Node) * count);
+   dlist->Head[0].opcode = OPCODE_END_OF_LIST;
    return dlist;
 }
 
@@ -429,10 +430,10 @@ make_list(GLuint list, GLuint count)
 /**
  * Lookup function to just encapsulate casting.
  */
-static INLINE struct mesa_display_list *
+static INLINE struct gl_display_list *
 lookup_list(GLcontext *ctx, GLuint list)
 {
-   return (struct mesa_display_list *)
+   return (struct gl_display_list *)
       _mesa_HashLookup(ctx->Shared->DisplayList, list);
 }
 
@@ -443,12 +444,12 @@ lookup_list(GLcontext *ctx, GLuint list)
  * \param dlist - display list pointer
  */
 void
-_mesa_delete_list(GLcontext *ctx, struct mesa_display_list *dlist)
+_mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist)
 {
    Node *n, *block;
    GLboolean done;
 
-   n = block = dlist->node;
+   n = block = dlist->Head;
 
    done = block ? GL_FALSE : GL_TRUE;
    while (!done) {
@@ -597,7 +598,7 @@ _mesa_delete_list(GLcontext *ctx, struct mesa_display_list *dlist)
 static void
 destroy_list(GLcontext *ctx, GLuint list)
 {
-   struct mesa_display_list *dlist;
+   struct gl_display_list *dlist;
 
    if (list == 0)
       return;
@@ -612,9 +613,9 @@ destroy_list(GLcontext *ctx, GLuint list)
 
 
 /*
- * Translate the nth element of list from type to GLuint.
+ * Translate the nth element of list from <type> to GLint.
  */
-static GLuint
+static GLint
 translate_id(GLsizei n, GLenum type, const GLvoid * list)
 {
    GLbyte *bptr;
@@ -628,37 +629,40 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list)
    switch (type) {
    case GL_BYTE:
       bptr = (GLbyte *) list;
-      return (GLuint) *(bptr + n);
+      return (GLint) bptr[n];
    case GL_UNSIGNED_BYTE:
       ubptr = (GLubyte *) list;
-      return (GLuint) *(ubptr + n);
+      return (GLint) ubptr[n];
    case GL_SHORT:
       sptr = (GLshort *) list;
-      return (GLuint) *(sptr + n);
+      return (GLint) sptr[n];
    case GL_UNSIGNED_SHORT:
       usptr = (GLushort *) list;
-      return (GLuint) *(usptr + n);
+      return (GLint) usptr[n];
    case GL_INT:
       iptr = (GLint *) list;
-      return (GLuint) *(iptr + n);
+      return iptr[n];
    case GL_UNSIGNED_INT:
       uiptr = (GLuint *) list;
-      return (GLuint) *(uiptr + n);
+      return (GLint) uiptr[n];
    case GL_FLOAT:
       fptr = (GLfloat *) list;
-      return (GLuint) *(fptr + n);
+      return (GLint) FLOORF(fptr[n]);
    case GL_2_BYTES:
       ubptr = ((GLubyte *) list) + 2 * n;
-      return (GLuint) *ubptr * 256 + (GLuint) * (ubptr + 1);
+      return (GLint) ubptr[0] * 256
+           + (GLint) ubptr[1];
    case GL_3_BYTES:
       ubptr = ((GLubyte *) list) + 3 * n;
-      return (GLuint) * ubptr * 65536
-           + (GLuint) *(ubptr + 1) * 256 + (GLuint) * (ubptr + 2);
+      return (GLint) ubptr[0] * 65536
+           + (GLint) ubptr[1] * 256
+           + (GLint) ubptr[2];
    case GL_4_BYTES:
       ubptr = ((GLubyte *) list) + 4 * n;
-      return (GLuint) *ubptr * 16777216
-           + (GLuint) *(ubptr + 1) * 65536
-           + (GLuint) *(ubptr + 2) * 256 + (GLuint) * (ubptr + 3);
+      return (GLint) ubptr[0] * 16777216
+           + (GLint) ubptr[1] * 65536
+           + (GLint) ubptr[2] * 256
+           + (GLint) ubptr[3];
    default:
       return 0;
    }
@@ -925,6 +929,13 @@ save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
 }
 
 
+static void GLAPIENTRY
+save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
+{
+   save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor);
+}
+
+
 static void GLAPIENTRY
 save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
 {
@@ -993,10 +1004,10 @@ _mesa_save_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
    }
 
    for (i = 0; i < n; i++) {
-      GLuint list = translate_id(i, type, lists);
+      GLint list = translate_id(i, type, lists);
       Node *n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST_OFFSET, 2);
       if (n) {
-         n[1].ui = list;
+         n[1].i = list;
          n[2].b = typeErrorFlag;
       }
    }
@@ -1995,7 +2006,7 @@ save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6);
-   if (OPCODE_LIGHT) {
+   if (n) {
       GLint i, nParams;
       n[1].e = light;
       n[2].e = pname;
@@ -2512,12 +2523,12 @@ save_MultMatrixd(const GLdouble * m)
 
 
 static void GLAPIENTRY
-save_NewList(GLuint list, GLenum mode)
+save_NewList(GLuint name, GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    /* It's an error to call this function while building a display list */
    _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
-   (void) list;
+   (void) name;
    (void) mode;
 }
 
@@ -3245,6 +3256,36 @@ save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
 }
 
 
+static void GLAPIENTRY
+save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
+                            GLuint mask)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   /* GL_FRONT */
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   if (n) {
+      n[1].e = GL_FRONT;
+      n[2].e = frontfunc;
+      n[3].i = ref;
+      n[4].ui = mask;
+   }
+   /* GL_BACK */
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   if (n) {
+      n[1].e = GL_BACK;
+      n[2].e = backfunc;
+      n[3].i = ref;
+      n[4].ui = mask;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
+      CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
+   }
+}
+
+
 static void GLAPIENTRY
 save_StencilMaskSeparate(GLenum face, GLuint mask)
 {
@@ -4247,77 +4288,111 @@ save_BindProgramNV(GLenum target, GLuint id)
       CALL_BindProgramNV(ctx->Exec, (target, id));
    }
 }
-#endif /* FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
 
-#if FEATURE_NV_vertex_program
 static void GLAPIENTRY
-save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
+save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
+                              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_EXECUTE_PROGRAM_NV, 6);
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
    if (n) {
       n[1].e = target;
-      n[2].ui = id;
-      n[3].f = params[0];
-      n[4].f = params[1];
-      n[5].f = params[2];
-      n[6].f = params[3];
+      n[2].ui = index;
+      n[3].f = x;
+      n[4].f = y;
+      n[5].f = z;
+      n[6].f = w;
    }
    if (ctx->ExecuteFlag) {
-      CALL_ExecuteProgramNV(ctx->Exec, (target, id, params));
+      CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
    }
 }
 
 
 static void GLAPIENTRY
-save_ProgramParameter4fNV(GLenum target, GLuint index,
-                          GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
+                               const GLfloat *params)
+{
+   save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
+                                 params[2], params[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
+                               const GLfloat * params)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6);
-   if (n) {
-      n[1].e = target;
-      n[2].ui = index;
-      n[3].f = x;
-      n[4].f = y;
-      n[5].f = z;
-      n[6].f = w;
+
+   if (count > 0) {
+      GLint i;
+      const GLfloat * p = params;
+
+      for (i = 0 ; i < count ; i++) {
+        n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
+        if (n) {
+           n[1].e = target;
+           n[2].ui = index;
+           n[3].f = p[0];
+           n[4].f = p[1];
+           n[5].f = p[2];
+           n[6].f = p[3];
+           p += 4;
+        }
+      }
    }
+
    if (ctx->ExecuteFlag) {
-      CALL_ProgramParameter4fNV(ctx->Exec, (target, index, x, y, z, w));
+      CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
    }
 }
 
 
 static void GLAPIENTRY
-save_ProgramParameter4fvNV(GLenum target, GLuint index,
-                           const GLfloat *params)
+save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
+                              GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
-   save_ProgramParameter4fNV(target, index, params[0], params[1],
-                             params[2], params[3]);
+   save_ProgramEnvParameter4fARB(target, index,
+                                 (GLfloat) x,
+                                 (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 
 static void GLAPIENTRY
-save_ProgramParameter4dNV(GLenum target, GLuint index,
-                          GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
+                               const GLdouble *params)
 {
-   save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y,
-                             (GLfloat) z, (GLfloat) w);
+   save_ProgramEnvParameter4fARB(target, index,
+                                 (GLfloat) params[0],
+                                 (GLfloat) params[1],
+                                 (GLfloat) params[2], (GLfloat) params[3]);
 }
 
+#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */
 
+#if FEATURE_NV_vertex_program
 static void GLAPIENTRY
-save_ProgramParameter4dvNV(GLenum target, GLuint index,
-                           const GLdouble *params)
+save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
 {
-   save_ProgramParameter4fNV(target, index, (GLfloat) params[0],
-                             (GLfloat) params[1], (GLfloat) params[2],
-                             (GLfloat) params[3]);
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
+   if (n) {
+      n[1].e = target;
+      n[2].ui = id;
+      n[3].f = params[0];
+      n[4].f = params[1];
+      n[5].f = params[2];
+      n[6].f = params[3];
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_ExecuteProgramNV(ctx->Exec, (target, id, params));
+   }
 }
 
 
@@ -4327,7 +4402,7 @@ save_ProgramParameters4dvNV(GLenum target, GLuint index,
 {
    GLuint i;
    for (i = 0; i < num; i++) {
-      save_ProgramParameter4dvNV(target, index + i, params + 4 * i);
+      save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i);
    }
 }
 
@@ -4338,7 +4413,7 @@ save_ProgramParameters4fvNV(GLenum target, GLuint index,
 {
    GLuint i;
    for (i = 0; i < num; i++) {
-      save_ProgramParameter4fvNV(target, index + i, params + 4 * i);
+      save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i);
    }
 }
 
@@ -4666,90 +4741,6 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
    }
 }
 
-
-static void GLAPIENTRY
-save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
-                              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_PROGRAM_ENV_PARAMETER_ARB, 6);
-   if (n) {
-      n[1].e = target;
-      n[2].ui = index;
-      n[3].f = x;
-      n[4].f = y;
-      n[5].f = z;
-      n[6].f = w;
-   }
-   if (ctx->ExecuteFlag) {
-      CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
-   }
-}
-
-
-static void GLAPIENTRY
-save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
-                               const GLfloat *params)
-{
-   save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
-                                 params[2], params[3]);
-}
-
-
-static void GLAPIENTRY
-save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
-                               const GLfloat * params)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   Node *n;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-
-   if (count > 0) {
-      GLint i;
-      const GLfloat * p = params;
-
-      for (i = 0 ; i < count ; i++) {
-        n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
-        if (n) {
-           n[1].e = target;
-           n[2].ui = index;
-           n[3].f = p[0];
-           n[4].f = p[1];
-           n[5].f = p[2];
-           n[6].f = p[3];
-           p += 4;
-        }
-      }
-   }
-
-   if (ctx->ExecuteFlag) {
-      CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
-   }
-}
-
-
-static void GLAPIENTRY
-save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
-                              GLdouble x, GLdouble y, GLdouble z, GLdouble w)
-{
-   save_ProgramEnvParameter4fARB(target, index,
-                                 (GLfloat) x,
-                                 (GLfloat) y, (GLfloat) z, (GLfloat) w);
-}
-
-
-static void GLAPIENTRY
-save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
-                               const GLdouble *params)
-{
-   save_ProgramEnvParameter4fARB(target, index,
-                                 (GLfloat) params[0],
-                                 (GLfloat) params[1],
-                                 (GLfloat) params[2], (GLfloat) params[3]);
-}
-
 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
 
 
@@ -5119,7 +5110,7 @@ save_Indexfv(const GLfloat * v)
 static void GLAPIENTRY
 save_EdgeFlag(GLboolean x)
 {
-   save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? 1.0 : 0.0);
+   save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0);
 }
 
 static void GLAPIENTRY
@@ -5629,6 +5620,27 @@ save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
 }
 
 
+/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
+
+static void GLAPIENTRY
+exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   CALL_BindAttribLocationARB(ctx->Exec, (program, index, name));
+}
+
+static GLint GLAPIENTRY
+exec_GetAttribLocationARB(GLuint program, const GLchar *name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   return CALL_GetAttribLocationARB(ctx->Exec, (program, name));
+}
+/* XXX more shader functions needed here */
+
+
+
 #if FEATURE_EXT_framebuffer_blit
 static void GLAPIENTRY
 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
@@ -5721,7 +5733,7 @@ islist(GLcontext *ctx, GLuint list)
 static void
 execute_list(GLcontext *ctx, GLuint list)
 {
-   struct mesa_display_list *dlist;
+   struct gl_display_list *dlist;
    Node *n;
    GLboolean done;
 
@@ -5737,10 +5749,12 @@ execute_list(GLcontext *ctx, GLuint list)
    if (!dlist)
       return;
 
+   ctx->ListState.CallDepth++;
+
    if (ctx->Driver.BeginCallList)
       ctx->Driver.BeginCallList(ctx, dlist);
 
-   n = dlist->node;
+   n = dlist->Head;
 
    done = GL_FALSE;
    while (!done) {
@@ -5802,7 +5816,8 @@ execute_list(GLcontext *ctx, GLuint list)
                _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
             }
             else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
-               execute_list(ctx, ctx->List.ListBase + n[1].ui);
+               GLuint list = (GLuint) (ctx->List.ListBase + n[1].i);
+               execute_list(ctx, list);
             }
             break;
          case OPCODE_CLEAR:
@@ -6427,10 +6442,6 @@ execute_list(GLcontext *ctx, GLuint list)
             CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i,
                                            (const GLubyte *) n[4].data));
             break;
-         case OPCODE_PROGRAM_PARAMETER4F_NV:
-            CALL_ProgramParameter4fNV(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
-                                                  n[4].f, n[5].f, n[6].f));
-            break;
          case OPCODE_TRACK_MATRIX_NV:
             CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e));
             break;
@@ -6461,6 +6472,8 @@ execute_list(GLcontext *ctx, GLuint list)
             CALL_ProgramStringARB(ctx->Exec,
                                   (n[1].e, n[2].e, n[3].i, n[4].data));
             break;
+#endif
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program
          case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
             CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
                                                       n[4].f, n[5].f,
@@ -6623,6 +6636,8 @@ execute_list(GLcontext *ctx, GLuint list)
 
    if (ctx->Driver.EndCallList)
       ctx->Driver.EndCallList(ctx);
+
+   ctx->ListState.CallDepth--;
 }
 
 
@@ -6710,7 +6725,7 @@ _mesa_GenLists(GLsizei range)
  * Begin a new display list.
  */
 void GLAPIENTRY
-_mesa_NewList(GLuint list, GLenum mode)
+_mesa_NewList(GLuint name, GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    GLint i;
@@ -6719,10 +6734,10 @@ _mesa_NewList(GLuint list, GLenum mode)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
-      _mesa_debug(ctx, "glNewList %u %s\n", list,
+      _mesa_debug(ctx, "glNewList %u %s\n", name,
                   _mesa_lookup_enum_by_nr(mode));
 
-   if (list == 0) {
+   if (name == 0) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
       return;
    }
@@ -6732,7 +6747,7 @@ _mesa_NewList(GLuint list, GLenum mode)
       return;
    }
 
-   if (ctx->ListState.CurrentListPtr) {
+   if (ctx->ListState.CurrentList) {
       /* already compiling a display list */
       _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
       return;
@@ -6742,10 +6757,8 @@ _mesa_NewList(GLuint list, GLenum mode)
    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
 
    /* Allocate new display list */
-   ctx->ListState.CurrentListNum = list;
-   ctx->ListState.CurrentList = make_list(list, BLOCK_SIZE);
-   ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->node;
-   ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
+   ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
+   ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
    ctx->ListState.CurrentPos = 0;
 
    /* Reset acumulated list state:
@@ -6757,7 +6770,7 @@ _mesa_NewList(GLuint list, GLenum mode)
       ctx->ListState.ActiveMaterialSize[i] = 0;
 
    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
-   ctx->Driver.NewList(ctx, list, mode);
+   ctx->Driver.NewList(ctx, name, mode);
 
    ctx->CurrentDispatch = ctx->Save;
    _glapi_set_dispatch(ctx->CurrentDispatch);
@@ -6778,28 +6791,31 @@ _mesa_EndList(void)
       _mesa_debug(ctx, "glEndList\n");
 
    /* Check that a list is under construction */
-   if (!ctx->ListState.CurrentListPtr) {
+   if (!ctx->ListState.CurrentList) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
       return;
    }
+   
+   /* Call before emitting END_OF_LIST, in case the driver wants to
+    * emit opcodes itself.
+    */
+   ctx->Driver.EndList(ctx);
 
    (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0);
 
    /* Destroy old list, if any */
-   destroy_list(ctx, ctx->ListState.CurrentListNum);
-   /* Install the list */
-   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum,
+   destroy_list(ctx, ctx->ListState.CurrentList->Name);
+
+   /* Install the new list */
+   _mesa_HashInsert(ctx->Shared->DisplayList,
+                    ctx->ListState.CurrentList->Name,
                     ctx->ListState.CurrentList);
 
 
    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
-      mesa_print_display_list(ctx->ListState.CurrentListNum);
-
-   ctx->Driver.EndList(ctx);
+      mesa_print_display_list(ctx->ListState.CurrentList->Name);
 
    ctx->ListState.CurrentList = NULL;
-   ctx->ListState.CurrentListNum = 0;
-   ctx->ListState.CurrentListPtr = NULL;
    ctx->ExecuteFlag = GL_TRUE;
    ctx->CompileFlag = GL_FALSE;
 
@@ -6850,7 +6866,6 @@ void GLAPIENTRY
 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLuint list;
    GLint i;
    GLboolean save_compile_flag;
 
@@ -6882,8 +6897,8 @@ _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
    ctx->CompileFlag = GL_FALSE;
 
    for (i = 0; i < n; i++) {
-      list = translate_id(i, type, lists);
-      execute_list(ctx, ctx->List.ListBase + list);
+      GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
+      execute_list(ctx, list);
    }
 
    ctx->CompileFlag = save_compile_flag;
@@ -7654,7 +7669,7 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_Accum(table, save_Accum);
    SET_AlphaFunc(table, save_AlphaFunc);
    SET_Bitmap(table, save_Bitmap);
-   SET_BlendFunc(table, _mesa_BlendFunc);       /* loops-back to BlendFuncSeparate */
+   SET_BlendFunc(table, save_BlendFunc);
    SET_CallList(table, _mesa_save_CallList);
    SET_CallLists(table, _mesa_save_CallLists);
    SET_Clear(table, save_Clear);
@@ -7863,6 +7878,9 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
    SET_StencilOpSeparate(table, save_StencilOpSeparate);
 
+   /* ATI_separate_stencil */ 
+   SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
+
    /* GL_ARB_imaging */
    /* Not all are supported */
    SET_BlendColor(table, save_BlendColor);
@@ -8014,10 +8032,10 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
    SET_IsProgramNV(table, _mesa_IsProgramARB);
    SET_LoadProgramNV(table, save_LoadProgramNV);
-   SET_ProgramParameter4dNV(table, save_ProgramParameter4dNV);
-   SET_ProgramParameter4dvNV(table, save_ProgramParameter4dvNV);
-   SET_ProgramParameter4fNV(table, save_ProgramParameter4fNV);
-   SET_ProgramParameter4fvNV(table, save_ProgramParameter4fvNV);
+   SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
+   SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
+   SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
+   SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
    SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV);
    SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV);
    SET_TrackMatrixNV(table, save_TrackMatrixNV);
@@ -8160,6 +8178,11 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT);
 #endif
 
+   /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
+   SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
+   SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
+   /* XXX additional functions need to be implemented here! */
+
    /* 299. GL_EXT_blend_equation_separate */
    SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT);
 
@@ -8186,7 +8209,7 @@ enum_string(GLenum k)
 static void GLAPIENTRY
 print_list(GLcontext *ctx, GLuint list)
 {
-   struct mesa_display_list *dlist;
+   struct gl_display_list *dlist;
    Node *n;
    GLboolean done;
 
@@ -8199,7 +8222,7 @@ print_list(GLcontext *ctx, GLuint list)
    if (!dlist)
       return;
 
-   n = dlist->node;
+   n = dlist->Head;
 
    _mesa_printf("START-LIST %u, address %p\n", list, (void *) n);
 
@@ -8561,9 +8584,7 @@ _mesa_init_display_list(GLcontext *ctx)
    ctx->ListState.CallDepth = 0;
    ctx->ExecuteFlag = GL_TRUE;
    ctx->CompileFlag = GL_FALSE;
-   ctx->ListState.CurrentListPtr = NULL;
    ctx->ListState.CurrentBlock = NULL;
-   ctx->ListState.CurrentListNum = 0;
    ctx->ListState.CurrentPos = 0;
 
    /* Display List group */