added device driver hooks for BindProgram, NewProgram, DeleteProgram
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index c3f4bb6..3c638be 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -27,6 +27,7 @@
 #include "imports.h"
 #include "buffers.h"
 #include "context.h"
+#include "program.h"
 #include "texformat.h"
 #include "teximage.h"
 #include "texobj.h"
@@ -106,6 +107,11 @@
    driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
    driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
 
+   /* Vertex/fragment programs */
+   driver->BindProgram = NULL;
+   driver->NewProgram = _mesa_new_program;
+   driver->DeleteProgram = _mesa_delete_program;
+
    /* simple state commands */
    driver->AlphaFunc = NULL;
    driver->BlendColor = NULL;
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b2ab491..89154eb 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -6,9 +6,9 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.1
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -827,12 +827,12 @@
 #endif
 
 #if FEATURE_ARB_vertex_program
-   ss->DefaultVertexProgram = _mesa_alloc_program(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+   ss->DefaultVertexProgram = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
    if (!ss->DefaultVertexProgram)
       goto cleanup;
 #endif
 #if FEATURE_ARB_fragment_program
-   ss->DefaultFragmentProgram = _mesa_alloc_program(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+   ss->DefaultFragmentProgram = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
    if (!ss->DefaultFragmentProgram)
       goto cleanup;
 #endif
@@ -880,11 +880,11 @@
 #endif
 #if FEATURE_ARB_vertex_program
    if (ss->DefaultVertexProgram)
-      _mesa_delete_program(ctx, ss->DefaultVertexProgram);
+      ctx->Driver.DeleteProgram(ctx, ss->DefaultVertexProgram);
 #endif
 #if FEATURE_ARB_fragment_program
    if (ss->DefaultFragmentProgram)
-      _mesa_delete_program(ctx, ss->DefaultFragmentProgram);
+      ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram);
 #endif
    if (ss->BufferObjects)
       _mesa_DeleteHashTable(ss->BufferObjects);
@@ -956,7 +956,7 @@
          struct program *p = (struct program *) _mesa_HashLookup(ss->Programs,
                                                                  prog);
          ASSERT(p);
-         _mesa_delete_program(ctx, p);
+         ctx->Driver.DeleteProgram(ctx, p);
          _mesa_HashRemove(ss->Programs, prog);
       }
       else {
@@ -974,7 +974,11 @@
 }
 
 
-static void _mesa_init_current( GLcontext *ctx )
+/**
+ * Initialize fields of gl_current_attrib (aka ctx->Current.*)
+ */
+static void
+_mesa_init_current( GLcontext *ctx )
 {
    int i;
 
@@ -995,6 +999,11 @@
 }
 
 
+/**
+ * Initialize fields of gl_constants (aka ctx->Const.*).
+ * Use defaults from config.h.  The device drivers will often override
+ * some of these values (such as number of texture units).
+ */
 static void 
 _mesa_init_constants( GLcontext *ctx )
 {
@@ -1067,6 +1076,7 @@
    ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
 }
 
+
 /**
  * Initialize the attribute groups in a GL context.
  *
@@ -1510,14 +1520,14 @@
    if (ctx->VertexProgram.Current) {
       ctx->VertexProgram.Current->Base.RefCount--;
       if (ctx->VertexProgram.Current->Base.RefCount <= 0)
-         _mesa_delete_program(ctx, &(ctx->VertexProgram.Current->Base));
+         ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base));
    }
 #endif
 #if FEATURE_NV_fragment_program
    if (ctx->FragmentProgram.Current) {
       ctx->FragmentProgram.Current->Base.RefCount--;
       if (ctx->FragmentProgram.Current->Base.RefCount <= 0)
-         _mesa_delete_program(ctx, &(ctx->FragmentProgram.Current->Base));
+         ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base));
    }
 #endif
 
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 5538377..cb23e0b 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -564,6 +564,19 @@
 
 
    /**
+    * \name Vertex/fragment program functions
+    */
+   /*@{*/
+   /** Bind a vertex/fragment program */
+   void (*BindProgram)(GLcontext *ctx, GLenum target, struct program *prog);
+   /** Allocate a new program */
+   struct program * (*NewProgram)(GLcontext *ctx, GLenum target, GLuint id);
+   /** Delete a program */
+   void (*DeleteProgram)(GLcontext *ctx, struct program *prog);
+   /*@}*/
+
+
+   /**
     * \name State-changing functions.
     *
     * \note drawing functions are above.
diff --git a/src/mesa/main/program.c b/src/mesa/main/program.c
index 7294d6c..e32e8a3 100644
--- a/src/mesa/main/program.c
+++ b/src/mesa/main/program.c
@@ -140,14 +140,17 @@
 
 
 /**
- * Allocate and initialize a new fragment/vertex program object
+ * Allocate and initialize a new fragment/vertex program object but don't
+ * put it into the program hash table.
+ * Called via ctx->Driver.NewProgram.  May be wrapped (OO deriviation)
+ * by a device driver function.
  * \param ctx  context
  * \param id   program id/number
  * \param target  program target/type
  * \return  pointer to new program object
  */
 struct program *
-_mesa_alloc_program(GLcontext *ctx, GLenum target, GLuint id)
+_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id)
 {
    struct program *prog;
 
@@ -168,7 +171,7 @@
       prog = &(fprog->Base);
    }
    else {
-      _mesa_problem(ctx, "bad target in _mesa_alloc_program");
+      _mesa_problem(ctx, "bad target in _mesa_new_program");
       return NULL;
    }
    prog->Id = id;
@@ -182,6 +185,8 @@
 /**
  * Delete a program and remove it from the hash table, ignoring the
  * reference count.
+ * Called via ctx->Driver.DeleteProgram.  May be wrapped (OO deriviation)
+ * by a device driver function.
  */
 void
 _mesa_delete_program(GLcontext *ctx, struct program *prog)
@@ -812,7 +817,7 @@
          ctx->VertexProgram.Current->Base.RefCount--;
          /* and delete if refcount goes below one */
          if (ctx->VertexProgram.Current->Base.RefCount <= 0) {
-            _mesa_delete_program(ctx, &(ctx->VertexProgram.Current->Base));
+            ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base));
             _mesa_HashRemove(ctx->Shared->Programs, id);
          }
       }
@@ -829,7 +834,7 @@
          ctx->FragmentProgram.Current->Base.RefCount--;
          /* and delete if refcount goes below one */
          if (ctx->FragmentProgram.Current->Base.RefCount <= 0) {
-            _mesa_delete_program(ctx, &(ctx->FragmentProgram.Current->Base));
+            ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base));
             _mesa_HashRemove(ctx->Shared->Programs, id);
          }
       }
@@ -865,7 +870,7 @@
       }
       else {
          /* allocate a new program now */
-         prog = _mesa_alloc_program(ctx, target, id);
+         prog = ctx->Driver.NewProgram(ctx, target, id);
          if (!prog) {
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV/ARB");
             return;
@@ -888,6 +893,9 @@
 
    if (prog)
       prog->RefCount++;
+
+   if (ctx->Driver.BindProgram)
+      ctx->Driver.BindProgram(ctx, target, prog);
 }
 
 
@@ -935,7 +943,7 @@
             }
             prog->RefCount--;
             if (prog->RefCount <= 0) {
-               _mesa_delete_program(ctx, prog);
+               ctx->Driver.DeleteProgram(ctx, prog);
             }
          }
       }
diff --git a/src/mesa/main/program.h b/src/mesa/main/program.h
index 4dbc5cf..0217a00 100644
--- a/src/mesa/main/program.h
+++ b/src/mesa/main/program.h
@@ -59,7 +59,7 @@
                        GLint *line, GLint *col);
 
 extern struct program *
-_mesa_alloc_program(GLcontext *ctx, GLenum target, GLuint id);
+_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id);
 
 extern void
 _mesa_delete_program(GLcontext *ctx, struct program *prog);