Mesa (master): mesa: Enable remap table in core.

Brian Paul brianp at kemper.freedesktop.org
Fri Oct 23 15:10:47 UTC 2009


Module: Mesa
Branch: master
Commit: 17ef1f6074d6107c167f1956a5c60993904c0b72
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=17ef1f6074d6107c167f1956a5c60993904c0b72

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Thu Oct  8 10:33:57 2009 +0800

mesa: Enable remap table in core.

This enables the remap table in core.  driInitExtensions is adapted to
use the remap table.  All uses of extension_helper.h are replaced by
remap_helper.h.  The chicken-egg problem of the DRI drivers is also
solved.

It is now also possible to pass NULL extensions to driInitExtensions.
It will cause driInitExtensions to map all known functions.  This
functionality is used by software drivers and EGL_i915.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>

---

 src/gallium/state_trackers/dri/dri_extensions.c |   10 +--
 src/gallium/state_trackers/dri/dri_screen.c     |    5 -
 src/gallium/state_trackers/egl/egl_context.c    |   67 ----------------
 src/gallium/state_trackers/egl/egl_tracker.c    |    4 +-
 src/mesa/drivers/dri/common/utils.c             |   94 +++++------------------
 src/mesa/drivers/dri/common/utils.h             |   32 +-------
 src/mesa/drivers/dri/i810/i810context.c         |    2 +-
 src/mesa/drivers/dri/i810/i810screen.c          |    4 -
 src/mesa/drivers/dri/intel/intel_extensions.c   |    3 +-
 src/mesa/drivers/dri/intel/intel_screen.c       |   24 ------
 src/mesa/drivers/dri/mach64/mach64_context.c    |    2 +-
 src/mesa/drivers/dri/mach64/mach64_screen.c     |   14 ----
 src/mesa/drivers/dri/mga/mga_xmesa.c            |   18 +----
 src/mesa/drivers/dri/r128/r128_context.c        |    4 +-
 src/mesa/drivers/dri/r128/r128_screen.c         |   14 ----
 src/mesa/drivers/dri/r200/r200_context.c        |   16 ++--
 src/mesa/drivers/dri/r300/r300_context.c        |    8 +-
 src/mesa/drivers/dri/r600/r600_context.c        |    8 +-
 src/mesa/drivers/dri/radeon/radeon_context.c    |    6 +-
 src/mesa/drivers/dri/radeon/radeon_screen.c     |   54 -------------
 src/mesa/drivers/dri/savage/savage_xmesa.c      |   14 +---
 src/mesa/drivers/dri/sis/sis_context.c          |    6 +-
 src/mesa/drivers/dri/sis/sis_screen.c           |   12 ---
 src/mesa/drivers/dri/swrast/swrast.c            |   74 +------------------
 src/mesa/drivers/dri/tdfx/tdfx_context.c        |    6 +-
 src/mesa/drivers/dri/tdfx/tdfx_screen.c         |   16 ----
 src/mesa/drivers/dri/unichrome/via_context.c    |    4 +-
 src/mesa/drivers/dri/unichrome/via_screen.c     |   14 ----
 src/mesa/drivers/x11/xm_api.c                   |   73 ------------------
 src/mesa/main/context.c                         |    3 +
 src/mesa/sources.mak                            |    1 +
 31 files changed, 66 insertions(+), 546 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c
index 800d462..78c4cd8 100644
--- a/src/gallium/state_trackers/dri/dri_extensions.c
+++ b/src/gallium/state_trackers/dri/dri_extensions.c
@@ -59,12 +59,13 @@
 #define need_GL_NV_vertex_program
 #define need_GL_VERSION_2_0
 #define need_GL_VERSION_2_1
-#include "extension_helper.h"
+#include "main/remap_helper.h"
+#include "utils.h"
 
 /**
  * Extension strings exported by the driver.
  */
-const struct dri_extension card_extensions[] = {
+static const struct dri_extension card_extensions[] = {
    {"GL_ARB_fragment_shader", NULL},
    {"GL_ARB_map_buffer_range", GL_ARB_map_buffer_range_functions},
    {"GL_ARB_multisample", GL_ARB_multisample_functions},
@@ -127,10 +128,7 @@ dri_init_extensions(struct dri_context *ctx)
     * capabilities of the pipe_screen. This is actually something
     * that can/should be done inside st_create_context().
     */
-   if (ctx)
-      driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE);
-   else
-      driInitExtensions(NULL, card_extensions, GL_FALSE);
+   driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE);
 }
 
 /* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 884b6d5..cb864d4 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -226,8 +226,6 @@ dri_init_screen(__DRIscreenPrivate * sPriv)
    const __DRIconfig **configs;
    struct dri1_create_screen_arg arg;
 
-   dri_init_extensions(NULL);
-
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
       return NULL;
@@ -292,9 +290,6 @@ dri_init_screen2(__DRIscreenPrivate * sPriv)
    struct dri_screen *screen;
    struct drm_create_screen_arg arg;
 
-   /* Set up dispatch table to cope with all known extensions */
-   dri_init_extensions(NULL);
-
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
       goto fail;
diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c
index e21a4a1..fee186c 100644
--- a/src/gallium/state_trackers/egl/egl_context.c
+++ b/src/gallium/state_trackers/egl/egl_context.c
@@ -16,73 +16,6 @@
 
 #include "GL/internal/glcore.h"
 
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_window_pos
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_NV_vertex_program
-#include "extension_helper.h"
-
-/**
- * TODO HACK! FUGLY!
- * Copied for intel extentions.
- */
-const struct dri_extension card_extensions[] = {
-	{"GL_ARB_multisample", GL_ARB_multisample_functions},
-	{"GL_ARB_multitexture", NULL},
-	{"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
-	{"GL_ARB_texture_border_clamp", NULL},
-	{"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
-	{"GL_ARB_texture_cube_map", NULL},
-	{"GL_ARB_texture_env_add", NULL},
-	{"GL_ARB_texture_env_combine", NULL},
-	{"GL_ARB_texture_env_dot3", NULL},
-	{"GL_ARB_texture_mirrored_repeat", NULL},
-	{"GL_ARB_texture_rectangle", NULL},
-	{"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
-	{"GL_ARB_pixel_buffer_object", NULL},
-	{"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
-	{"GL_ARB_window_pos", GL_ARB_window_pos_functions},
-	{"GL_EXT_blend_color", GL_EXT_blend_color_functions},
-	{"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
-	{"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
-	{"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
-	{"GL_EXT_blend_subtract", NULL},
-	{"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
-	{"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
-	{"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
-	{"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
-	{"GL_EXT_packed_depth_stencil", NULL},
-	{"GL_EXT_pixel_buffer_object", NULL},
-	{"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
-	{"GL_EXT_stencil_wrap", NULL},
-	{"GL_EXT_texture_edge_clamp", NULL},
-	{"GL_EXT_texture_env_combine", NULL},
-	{"GL_EXT_texture_env_dot3", NULL},
-	{"GL_EXT_texture_filter_anisotropic", NULL},
-	{"GL_EXT_texture_lod_bias", NULL},
-	{"GL_3DFX_texture_compression_FXT1", NULL},
-	{"GL_APPLE_client_storage", NULL},
-	{"GL_MESA_pack_invert", NULL},
-	{"GL_MESA_ycbcr_texture", NULL},
-	{"GL_NV_blend_square", NULL},
-	{"GL_NV_vertex_program", GL_NV_vertex_program_functions},
-	{"GL_NV_vertex_program1_1", NULL},
-	{"GL_SGIS_generate_mipmap", NULL },
-	{NULL, NULL}
-};
-
 _EGLContext *
 drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list)
 {
diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c
index 5140755..8d29bf4 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.c
+++ b/src/gallium/state_trackers/egl/egl_tracker.c
@@ -16,7 +16,6 @@
 
 /** HACK */
 void* driDriverAPI;
-extern const struct dri_extension card_extensions[];
 
 
 /*
@@ -168,8 +167,7 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
 		goto err_screen;
 	dev->winsys = dev->screen->winsys;
 
-	/* TODO HACK */
-	driInitExtensions(NULL, card_extensions, GL_FALSE);
+	driInitExtensions(NULL, NULL, GL_FALSE);
 
 	drm_update_res(dev);
 	res = dev->res;
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c
index 66f277c..b272eb7 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -38,9 +38,6 @@
 #include "utils.h"
 
 
-int driDispatchRemapTable[ driDispatchRemapTable_size ];
-
-
 unsigned
 driParseDebugString( const char * debug, 
 		     const struct dri_debug_control * control  )
@@ -142,7 +139,7 @@ driGetRendererString( char * buffer, const char * hardware_name,
 #define need_GL_EXT_blend_func_separate
 #define need_GL_NV_vertex_program
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 static const struct dri_extension all_mesa_extensions[] = {
    { "GL_ARB_draw_buffers",          GL_ARB_draw_buffers_functions },
@@ -165,8 +162,12 @@ static const struct dri_extension all_mesa_extensions[] = {
 
 
 /**
- * Enable extensions supported by the driver.
+ * Enable and map extensions supported by the driver.
  * 
+ * When ctx is NULL, extensions are not enabled, but their functions
+ * are still mapped.  When extensions_to_enable is NULL, all static
+ * functions known to mesa core are mapped.
+ *
  * \bug
  * ARB_imaging isn't handled properly.  In Mesa, enabling ARB_imaging also
  * enables all the sub-extensions that are folded into it.  This means that
@@ -181,18 +182,23 @@ void driInitExtensions( GLcontext * ctx,
    unsigned   i;
 
    if ( first_time ) {
-      for ( i = 0 ; i < driDispatchRemapTable_size ; i++ ) {
-	 driDispatchRemapTable[i] = -1;
-      }
-
       first_time = 0;
-      driInitExtensions( ctx, all_mesa_extensions, GL_FALSE );
+      driInitExtensions( NULL, all_mesa_extensions, GL_FALSE );
    }
 
    if ( (ctx != NULL) && enable_imaging ) {
       _mesa_enable_imaging_extensions( ctx );
    }
 
+   /* The caller is too lazy to list any extension */
+   if ( extensions_to_enable == NULL ) {
+      /* Map the static functions.  Together with those mapped by remap
+       * table, this should cover everything mesa core knows.
+       */
+      _mesa_map_static_functions();
+      return;
+   }
+
    for ( i = 0 ; extensions_to_enable[i].name != NULL ; i++ ) {
        driInitSingleExtension( ctx, & extensions_to_enable[i] );
    }
@@ -202,80 +208,18 @@ void driInitExtensions( GLcontext * ctx,
 
 
 /**
- * Enable and add dispatch functions for a single extension
+ * Enable and map functions for a single extension
  * 
  * \param ctx  Context where extension is to be enabled.
  * \param ext  Extension that is to be enabled.
  * 
- * \sa driInitExtensions, _mesa_enable_extension, _glapi_add_entrypoint
- *
- * \todo
- * Determine if it would be better to use \c strlen instead of the hardcoded
- * for-loops.
+ * \sa driInitExtensions, _mesa_enable_extension, _mesa_map_function_array
  */
 void driInitSingleExtension( GLcontext * ctx,
 			     const struct dri_extension * ext )
 {
-    unsigned i;
-
-
     if ( ext->functions != NULL ) {
-	for ( i = 0 ; ext->functions[i].strings != NULL ; i++ ) {
-	    const char * functions[16];
-	    const char * parameter_signature;
-	    const char * str = ext->functions[i].strings;
-	    unsigned j;
-	    unsigned offset;
-
-
-	    /* Separate the parameter signature from the rest of the string.
-	     * If the parameter signature is empty (i.e., the string starts
-	     * with a NUL character), then the function has a void parameter
-	     * list.
-	     */
-	    parameter_signature = str;
-	    while ( str[0] != '\0' ) {
-		str++;
-	    }
-	    str++;
-
-
-	    /* Divide the string into the substrings that name each
-	     * entry-point for the function.
-	     */
-	    for ( j = 0 ; j < 16 ; j++ ) {
-		if ( str[0] == '\0' ) {
-		    functions[j] = NULL;
-		    break;
-		}
-
-		functions[j] = str;
-
-		while ( str[0] != '\0' ) {
-		    str++;
-		}
-		str++;
-	    }
-
-
-	    /* Add each entry-point to the dispatch table.
-	     */
-	    offset = _glapi_add_dispatch( functions, parameter_signature );
-	    if (offset == -1) {
-#if 0 /* this causes noise with egl */
-		fprintf(stderr, "DISPATCH ERROR! _glapi_add_dispatch failed "
-			"to add %s!\n", functions[0]);
-#endif
-	    }
-	    else if (ext->functions[i].remap_index != -1) {
-		driDispatchRemapTable[ ext->functions[i].remap_index ] = 
-		  offset;
-	    }
-	    else if (ext->functions[i].offset != offset) {
-		fprintf(stderr, "DISPATCH ERROR! %s -> %u != %u\n",
-			functions[0], offset, ext->functions[i].offset);
-	    }
-	}
+       _mesa_map_function_array(ext->functions);
     }
 
     if ( ctx != NULL ) {
diff --git a/src/mesa/drivers/dri/common/utils.h b/src/mesa/drivers/dri/common/utils.h
index 9e9e5bc..2aa6de6 100644
--- a/src/mesa/drivers/dri/common/utils.h
+++ b/src/mesa/drivers/dri/common/utils.h
@@ -31,6 +31,7 @@
 #include <GL/gl.h>
 #include <GL/internal/dri_interface.h>
 #include "main/context.h"
+#include "main/remap.h"
 
 typedef struct __DRIutilversionRec2    __DRIutilversion2;
 
@@ -40,35 +41,6 @@ struct dri_debug_control {
 };
 
 /**
- * Description of the entry-points and parameters for an OpenGL function.
- */
-struct dri_extension_function {
-    /**
-     * \brief
-     * Packed string describing the parameter signature and the entry-point
-     * names.
-     * 
-     * The parameter signature and the names of the entry-points for this
-     * function are packed into a single string.  The substrings are
-     * separated by NUL characters.  The whole string is terminated by
-     * two consecutive NUL characters.
-     */
-    const char * strings;
-
-
-    /**
-     * Location in the remap table where the dispatch offset should be
-     * stored.
-     */
-    int remap_index;
-
-    /**
-     * Offset of the function in the dispatch table.
-     */
-    int offset;
-};
-
-/**
  * Description of the API for an extension to OpenGL.
  */
 struct dri_extension {
@@ -83,7 +55,7 @@ struct dri_extension {
      * is terminated by a structure with a \c NULL
      * \c dri_extension_function::strings pointer.
      */
-    const struct dri_extension_function * functions;
+    const struct gl_function_remap * functions;
 };
 
 /**
diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c
index 6785655..7311b2e 100644
--- a/src/mesa/drivers/dri/i810/i810context.c
+++ b/src/mesa/drivers/dri/i810/i810context.c
@@ -116,7 +116,7 @@ static void i810BufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
 
 /* Extension strings exported by the i810 driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_env_add",            NULL },
diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c
index 6e49f34..a9ee611 100644
--- a/src/mesa/drivers/dri/i810/i810screen.c
+++ b/src/mesa/drivers/dri/i810/i810screen.c
@@ -53,8 +53,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "GL/internal/dri_interface.h"
 
-extern const struct dri_extension card_extensions[];
-
 static const __DRIconfig **
 i810FillInModes( __DRIscreenPrivate *psp,
 		 unsigned pixel_bits, unsigned depth_bits,
@@ -166,8 +164,6 @@ i810InitScreen(__DRIscreen *sPriv)
       return NULL;
    }
 
-   driInitExtensions( NULL, card_extensions, GL_TRUE );
-
    if (sPriv->devPrivSize != sizeof(I810DRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(I810DRIRec) does not match passed size from device driver\n");
       return GL_FALSE;
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index 2eb08a8..b6754c9 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -28,6 +28,7 @@
 #include "intel_chipset.h"
 #include "intel_context.h"
 #include "intel_extensions.h"
+#include "utils.h"
 
 
 #define need_GL_ARB_copy_buffer
@@ -63,7 +64,7 @@
 #define need_GL_VERSION_2_0
 #define need_GL_VERSION_2_1
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 
 /**
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 24f7fbc..41342dd 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -696,18 +696,6 @@ static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
       return NULL;
    }
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   intelInitExtensions(NULL, GL_TRUE);
-	   
    if (!intelInitDriver(psp))
        return NULL;
 
@@ -760,18 +748,6 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
    int color;
    __DRIconfig **configs = NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   intelInitExtensions(NULL, GL_TRUE);
-
    /* Allocate the private area */
    intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate));
    if (!intelScreen) {
diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c
index 9c7f513..2bca293 100644
--- a/src/mesa/drivers/dri/mach64/mach64_context.c
+++ b/src/mesa/drivers/dri/mach64/mach64_context.c
@@ -76,7 +76,7 @@ static const struct dri_debug_control debug_control[] =
     { NULL,    0 }
 };
 
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_EXT_texture_edge_clamp",         NULL },
diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c
index 6440027..43aac89 100644
--- a/src/mesa/drivers/dri/mach64/mach64_screen.c
+++ b/src/mesa/drivers/dri/mach64/mach64_screen.c
@@ -67,8 +67,6 @@ static const GLuint __driNConfigOptions = 3;
 static const GLuint __driNConfigOptions = 2;
 #endif
 
-extern const struct dri_extension card_extensions[];
-
 static const __DRIconfig **
 mach64FillInModes( __DRIscreenPrivate *psp,
 		   unsigned pixel_bits, unsigned depth_bits,
@@ -436,18 +434,6 @@ mach64InitScreen(__DRIscreenPrivate *psp)
       return NULL;
    }
    
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!mach64InitDriver(psp))
       return NULL;
 
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 0dc76fe..03fd9b6 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -78,7 +78,7 @@
 #endif
 #define need_GL_APPLE_vertex_array_object
 #define need_GL_NV_vertex_program
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 /* MGA configuration
  */
@@ -945,22 +945,6 @@ static const __DRIconfig **mgaInitScreen(__DRIscreen *psp)
       return NULL;
 
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-   driInitExtensions( NULL, g400_extensions, GL_FALSE );
-   driInitExtensions(NULL, ARB_vp_extensions, GL_FALSE);
-   driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
-
    if (!mgaInitDriver(psp))
        return NULL;
 
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c
index f511a67..0b25087 100644
--- a/src/mesa/drivers/dri/r128/r128_context.c
+++ b/src/mesa/drivers/dri/r128/r128_context.c
@@ -68,9 +68,9 @@ int R128_DEBUG = 0;
 #define need_GL_EXT_blend_minmax
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_env_add",            NULL },
diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c
index f5bcc2f..a68b019 100644
--- a/src/mesa/drivers/dri/r128/r128_screen.c
+++ b/src/mesa/drivers/dri/r128/r128_screen.c
@@ -74,8 +74,6 @@ static const GLuint __driNConfigOptions = 4;
 static const GLuint __driNConfigOptions = 3;
 #endif
 
-extern const struct dri_extension card_extensions[];
-
 #if 1
 /* Including xf86PciInfo.h introduces a bunch of errors...
  */
@@ -493,18 +491,6 @@ r128InitScreen(__DRIscreenPrivate *psp)
 				      &psp->drm_version, & drm_expected ) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!r128InitDriver(psp))
        return NULL;
 
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index 3ddb5bf..e3ae839 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -75,7 +75,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_NV_vertex_program
 #define need_GL_ARB_point_parameters
 #define need_GL_EXT_framebuffer_object
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #define DRIVER_DATE	"20060602"
 
@@ -115,7 +115,7 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
 
 /* Extension strings exported by the R200 driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_occlusion_query",		   GL_ARB_occlusion_query_functions},
@@ -146,31 +146,31 @@ const struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
-const struct dri_extension blend_extensions[] = {
+static const struct dri_extension blend_extensions[] = {
     { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },
     { "GL_EXT_blend_func_separate",        GL_EXT_blend_func_separate_functions },
     { NULL,                                NULL }
 };
 
-const struct dri_extension ARB_vp_extension[] = {
+static const struct dri_extension ARB_vp_extension[] = {
     { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions }
 };
 
-const struct dri_extension NV_vp_extension[] = {
+static const struct dri_extension NV_vp_extension[] = {
     { "GL_NV_vertex_program",              GL_NV_vertex_program_functions }
 };
 
-const struct dri_extension ATI_fs_extension[] = {
+static const struct dri_extension ATI_fs_extension[] = {
     { "GL_ATI_fragment_shader",            GL_ATI_fragment_shader_functions }
 };
 
-const struct dri_extension point_extensions[] = {
+static const struct dri_extension point_extensions[] = {
     { "GL_ARB_point_sprite",               NULL },
     { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
     { NULL,                                NULL }
 };
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
 };
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 2c2b16a..6f66e97 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -90,10 +90,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_ATI_separate_stencil
 #define need_GL_NV_vertex_program
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 
-const struct dri_extension card_extensions[] = {
+static const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
   {"GL_ARB_depth_texture",		NULL},
   {"GL_ARB_fragment_program",		NULL},
@@ -145,7 +145,7 @@ const struct dri_extension card_extensions[] = {
 };
 
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_blit",	GL_EXT_framebuffer_blit_functions },
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
@@ -155,7 +155,7 @@ const struct dri_extension mm_extensions[] = {
  * The GL 2.0 functions are needed to make display lists work with
  * functions added by GL_ATI_separate_stencil.
  */
-const struct dri_extension gl_20_extension[] = {
+static const struct dri_extension gl_20_extension[] = {
   {"GL_VERSION_2_0",			GL_VERSION_2_0_functions },
 };
 
diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c
index e6791b4..c1bf76d 100644
--- a/src/mesa/drivers/dri/r600/r600_context.c
+++ b/src/mesa/drivers/dri/r600/r600_context.c
@@ -92,9 +92,9 @@ int hw_tcl_on = 1;
 #define need_GL_ATI_separate_stencil
 #define need_GL_NV_vertex_program
 
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
-const struct dri_extension card_extensions[] = {
+static const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
   {"GL_ARB_depth_texture",		NULL},
   {"GL_ARB_fragment_program",		NULL},
@@ -145,7 +145,7 @@ const struct dri_extension card_extensions[] = {
 };
 
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
 };
@@ -154,7 +154,7 @@ const struct dri_extension mm_extensions[] = {
  * The GL 2.0 functions are needed to make display lists work with
  * functions added by GL_ATI_separate_stencil.
  */
-const struct dri_extension gl_20_extension[] = {
+static const struct dri_extension gl_20_extension[] = {
   {"GL_VERSION_2_0",			GL_VERSION_2_0_functions },
 };
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 8f4485a..5e700be 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -69,7 +69,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
 #define need_GL_EXT_framebuffer_object
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #define DRIVER_DATE	"20061018"
 
@@ -79,7 +79,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* Extension strings exported by the R100 driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_occlusion_query",		   GL_ARB_occlusion_query_functions},
@@ -109,7 +109,7 @@ const struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
-const struct dri_extension mm_extensions[] = {
+static const struct dri_extension mm_extensions[] = {
   { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
   { NULL, NULL }
 };
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 573eb6c..2fb2d37 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -141,12 +141,6 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 17;
 
-extern const struct dri_extension blend_extensions[];
-extern const struct dri_extension ARB_vp_extension[];
-extern const struct dri_extension NV_vp_extension[];
-extern const struct dri_extension ATI_fs_extension[];
-extern const struct dri_extension point_extensions[];
-
 #elif defined(RADEON_R300) || defined(RADEON_R600)
 
 #define DRI_CONF_FP_OPTIMIZATION_SPEED   0
@@ -218,13 +212,8 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 17;
 
-extern const struct dri_extension gl_20_extension[];
-
 #endif
 
-extern const struct dri_extension card_extensions[];
-extern const struct dri_extension mm_extensions[];
-
 static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
 
 static int
@@ -1619,27 +1608,6 @@ radeonInitScreen(__DRIscreenPrivate *psp)
       return NULL;
    }
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create
-    * is called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-#if defined(RADEON_R200)
-   driInitExtensions( NULL, blend_extensions, GL_FALSE );
-   driInitSingleExtension( NULL, ARB_vp_extension );
-   driInitSingleExtension( NULL, NV_vp_extension );
-   driInitSingleExtension( NULL, ATI_fs_extension );
-   driInitExtensions( NULL, point_extensions, GL_FALSE );
-#elif (defined(RADEON_R300) || defined(RADEON_R600))
-   driInitSingleExtension( NULL, gl_20_extension );
-#endif
-
    if (!radeonInitDriver(psp))
        return NULL;
 
@@ -1672,28 +1640,6 @@ __DRIconfig **radeonInitScreen2(__DRIscreenPrivate *psp)
    int color;
    __DRIconfig **configs = NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create
-    * is called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-   driInitExtensions( NULL, mm_extensions, GL_FALSE );
-#if defined(RADEON_R200)
-   driInitExtensions( NULL, blend_extensions, GL_FALSE );
-   driInitSingleExtension( NULL, ARB_vp_extension );
-   driInitSingleExtension( NULL, NV_vp_extension );
-   driInitSingleExtension( NULL, ATI_fs_extension );
-   driInitExtensions( NULL, point_extensions, GL_FALSE );
-#elif (defined(RADEON_R300) || defined(RADEON_R600))
-   driInitSingleExtension( NULL, gl_20_extension );
-#endif
-
    if (!radeonInitDriver(psp)) {
        return NULL;
     }
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 931ceff..0fccf50 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -59,7 +59,7 @@
 #include "texmem.h"
 
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #include "xmlpool.h"
 
@@ -980,18 +980,6 @@ savageInitScreen(__DRIscreenPrivate *psp)
 				      &psp->drm_version, & drm_expected ) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!savageInitDriver(psp))
        return NULL;
 
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index a070fe3..f501e7a 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -59,7 +59,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #ifndef SIS_DEBUG
 int SIS_DEBUG = 0;
@@ -69,7 +69,7 @@ int GlobalCurrentHwcx = -1;
 int GlobalHwcxCountBase = 1;
 int GlobalCmdQueueLen = 0;
 
-struct dri_extension card_extensions[] =
+static struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_border_clamp",       NULL },
@@ -83,7 +83,7 @@ struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
-struct dri_extension card_extensions_6326[] =
+static struct dri_extension card_extensions_6326[] =
 {
     /*{ "GL_ARB_texture_border_clamp",       NULL },*/
     /*{ "GL_ARB_texture_mirrored_repeat",    NULL },*/
diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c
index b5f04ae..fec9158 100644
--- a/src/mesa/drivers/dri/sis/sis_screen.c
+++ b/src/mesa/drivers/dri/sis/sis_screen.c
@@ -298,18 +298,6 @@ sisInitScreen(__DRIscreenPrivate *psp)
 				   &psp->drm_version, &drm_expected))
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    psp->private = sisCreateScreen(psp);
 
    if (!psp->private) {
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index f4947da..df5221b 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -49,78 +49,6 @@
 #include "swrast_priv.h"
 
 
-#define need_GL_VERSION_1_3
-#define need_GL_VERSION_1_4
-#define need_GL_VERSION_1_5
-#define need_GL_VERSION_2_0
-#define need_GL_VERSION_2_1
-
-/* sw extensions for imaging */
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_convolution
-#define need_GL_EXT_histogram
-#define need_GL_SGI_color_table
-
-/* sw extensions not associated with some GL version */
-#define need_GL_ARB_draw_elements_base_vertex
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_vertex_array_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_sync
-#define need_GL_APPLE_vertex_array_object
-#define need_GL_ATI_fragment_shader
-#define need_GL_ATI_separate_stencil
-#define need_GL_EXT_depth_bounds_test
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_framebuffer_blit
-#define need_GL_EXT_gpu_program_parameters
-#define need_GL_EXT_paletted_texture
-#define need_GL_EXT_stencil_two_side
-#define need_GL_MESA_resize_buffers
-#define need_GL_NV_vertex_program
-#define need_GL_NV_fragment_program
-
-#include "extension_helper.h"
-
-const struct dri_extension card_extensions[] =
-{
-    { "GL_VERSION_1_3",			GL_VERSION_1_3_functions },
-    { "GL_VERSION_1_4",			GL_VERSION_1_4_functions },
-    { "GL_VERSION_1_5",			GL_VERSION_1_5_functions },
-    { "GL_VERSION_2_0",			GL_VERSION_2_0_functions },
-    { "GL_VERSION_2_1",			GL_VERSION_2_1_functions },
-
-    { "GL_EXT_blend_color",		GL_EXT_blend_color_functions },
-    { "GL_EXT_blend_minmax",		GL_EXT_blend_minmax_functions },
-    { "GL_EXT_convolution",		GL_EXT_convolution_functions },
-    { "GL_EXT_histogram",		GL_EXT_histogram_functions },
-    { "GL_SGI_color_table",		GL_SGI_color_table_functions },
-
-    { "GL_ARB_depth_clamp",		NULL },
-    { "GL_ARB_draw_elements_base_vertex", GL_ARB_draw_elements_base_vertex_functions },
-    { "GL_ARB_shader_objects",		GL_ARB_shader_objects_functions },
-    { "GL_ARB_vertex_array_object",	GL_ARB_vertex_array_object_functions },
-    { "GL_ARB_vertex_program",		GL_ARB_vertex_program_functions },
-    { "GL_ARB_sync",			GL_ARB_sync_functions },
-    { "GL_APPLE_vertex_array_object",	GL_APPLE_vertex_array_object_functions },
-    { "GL_ATI_fragment_shader",		GL_ATI_fragment_shader_functions },
-    { "GL_ATI_separate_stencil",	GL_ATI_separate_stencil_functions },
-    { "GL_EXT_depth_bounds_test",	GL_EXT_depth_bounds_test_functions },
-    { "GL_EXT_framebuffer_object",	GL_EXT_framebuffer_object_functions },
-    { "GL_EXT_framebuffer_blit",	GL_EXT_framebuffer_blit_functions },
-    { "GL_EXT_gpu_program_parameters",	GL_EXT_gpu_program_parameters_functions },
-    { "GL_EXT_paletted_texture",	GL_EXT_paletted_texture_functions },
-    { "GL_EXT_stencil_two_side",	GL_EXT_stencil_two_side_functions },
-    { "GL_MESA_resize_buffers",		GL_MESA_resize_buffers_functions },
-    { "GL_NV_depth_clamp",		NULL },
-    { "GL_NV_vertex_program",		GL_NV_vertex_program_functions },
-    { "GL_NV_fragment_program",		GL_NV_fragment_program_functions },
-    { "GL_NV_fragment_program_option",	NULL },
-    { NULL,				NULL }
-};
-
-
 /**
  * Screen and config-related functions
  */
@@ -244,7 +172,7 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions,
     *driver_configs = (const __DRIconfig **)
        driConcatConfigs(configs24, configs32);
 
-    driInitExtensions( NULL, card_extensions, GL_FALSE );
+    driInitExtensions( NULL, NULL, GL_FALSE );
 
     return psp;
 }
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c
index 68b5027..e742d41 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_context.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c
@@ -68,13 +68,13 @@
 #define need_GL_EXT_paletted_texture
 /* #define need_GL_EXT_secondary_color */
 /* #define need_GL_NV_vertex_program */
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 
 /**
  * Common extension strings exported by all cards
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },
     { "GL_ARB_texture_mirrored_repeat",    NULL },
@@ -107,7 +107,7 @@ const struct dri_extension card_extensions[] =
 /**
  * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards.
  */
-const struct dri_extension napalm_extensions[] =
+static const struct dri_extension napalm_extensions[] =
 {
     { "GL_ARB_texture_env_combine",        NULL },
     { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
index 58bd48b..d8a4b40 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
@@ -69,9 +69,6 @@ static const __DRIextension *tdfxExtensions[] = {
 
 static const GLuint __driNConfigOptions = 1;
 
-extern const struct dri_extension card_extensions[];
-extern const struct dri_extension napalm_extensions[];
-
 static GLboolean
 tdfxCreateScreen( __DRIscreenPrivate *sPriv )
 {
@@ -418,19 +415,6 @@ tdfxInitScreen(__DRIscreen *psp)
 				      &psp->drm_version, & drm_expected ) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-   driInitExtensions( NULL, napalm_extensions, GL_FALSE );
-
    if (!tdfxInitDriver(psp))
       return NULL;
       
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index 6eb19ac..5be1cf3 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -65,7 +65,7 @@
 #define need_GL_ARB_point_parameters
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
-#include "extension_helper.h"
+#include "main/remap_helper.h"
 
 #define DRIVER_DATE	"20060710"
 
@@ -362,7 +362,7 @@ void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
 
 /* Extension strings exported by the Unichrome driver.
  */
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c
index 3dbb570..7cfc60a 100644
--- a/src/mesa/drivers/dri/unichrome/via_screen.c
+++ b/src/mesa/drivers/dri/unichrome/via_screen.c
@@ -62,8 +62,6 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 3;
 
-extern const struct dri_extension card_extensions[];
-
 static drmBufMapPtr via_create_empty_buffers(void)
 {
     drmBufMapPtr retval;
@@ -393,18 +391,6 @@ viaInitScreen(__DRIscreenPrivate *psp)
 				      &psp->drm_version, & drm_expected) )
       return NULL;
 
-   /* Calling driInitExtensions here, with a NULL context pointer,
-    * does not actually enable the extensions.  It just makes sure
-    * that all the dispatch offsets for all the extensions that
-    * *might* be enables are known.  This is needed because the
-    * dispatch offsets need to be known when _mesa_context_create is
-    * called, but we can't enable the extensions until we have a
-    * context pointer.
-    *
-    * Hello chicken.  Hello egg.  How are you two today?
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-
    if (!viaInitDriver(psp))
        return NULL;
 
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 79b0586..bf767bc 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -1303,71 +1303,6 @@ xmesa_convert_from_x_visual_type( int visualType )
 /**********************************************************************/
 
 
-#ifdef IN_DRI_DRIVER
-#define need_GL_VERSION_1_3
-#define need_GL_VERSION_1_4
-#define need_GL_VERSION_1_5
-#define need_GL_VERSION_2_0
-
-/* sw extensions for imaging */
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_convolution
-#define need_GL_EXT_histogram
-#define need_GL_SGI_color_table
-
-/* sw extensions not associated with some GL version */
-#define need_GL_ARB_draw_elements_base_vertex
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_sync
-#define need_GL_ARB_vertex_program
-#define need_GL_APPLE_vertex_array_object
-#define need_GL_ATI_fragment_shader
-#define need_GL_EXT_depth_bounds_test
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_framebuffer_blit
-#define need_GL_EXT_gpu_program_parameters
-#define need_GL_EXT_paletted_texture
-#define need_GL_MESA_resize_buffers
-#define need_GL_NV_vertex_program
-#define need_GL_NV_fragment_program
-
-#include "extension_helper.h"
-#include "utils.h"
-
-const struct dri_extension card_extensions[] =
-{
-   { "GL_VERSION_1_3",			GL_VERSION_1_3_functions },
-   { "GL_VERSION_1_4",			GL_VERSION_1_4_functions },
-   { "GL_VERSION_1_5",			GL_VERSION_1_5_functions },
-   { "GL_VERSION_2_0",			GL_VERSION_2_0_functions },
-
-   { "GL_EXT_blend_color",		GL_EXT_blend_color_functions },
-   { "GL_EXT_blend_minmax",		GL_EXT_blend_minmax_functions },
-   { "GL_EXT_convolution",		GL_EXT_convolution_functions },
-   { "GL_EXT_histogram",		GL_EXT_histogram_functions },
-   { "GL_SGI_color_table",		GL_SGI_color_table_functions },
-
-   { "GL_ARB_depth_clamp",		NULL },
-   { "GL_ARB_draw_elements_base_vertex", GL_ARB_draw_elements_base_vertex_functions },
-   { "GL_ARB_shader_objects",		GL_ARB_shader_objects_functions },
-   { "GL_ARB_sync",			GL_ARB_sync_functions },
-   { "GL_ARB_vertex_program",		GL_ARB_vertex_program_functions },
-   { "GL_APPLE_vertex_array_object",	GL_APPLE_vertex_array_object_functions },
-   { "GL_ATI_fragment_shader",		GL_ATI_fragment_shader_functions },
-   { "GL_EXT_depth_bounds_test",	GL_EXT_depth_bounds_test_functions },
-   { "GL_EXT_framebuffer_object",	GL_EXT_framebuffer_object_functions },
-   { "GL_EXT_framebuffer_blit",		GL_EXT_framebuffer_blit_functions },
-   { "GL_EXT_gpu_program_parameters",	GL_EXT_gpu_program_parameters_functions },
-   { "GL_EXT_paletted_texture",		GL_EXT_paletted_texture_functions },
-   { "GL_MESA_resize_buffers",		GL_MESA_resize_buffers_functions },
-   { "GL_NV_depth_clamp",		NULL },
-   { "GL_NV_vertex_program",		GL_NV_vertex_program_functions },
-   { "GL_NV_fragment_program",		GL_NV_fragment_program_functions },
-   { NULL,				NULL }
-};
-#endif
-
 /*
  * Create a new X/Mesa visual.
  * Input:  display - X11 display
@@ -1413,14 +1348,6 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
    XMesaVisual v;
    GLint red_bits, green_bits, blue_bits, alpha_bits;
 
-#ifdef IN_DRI_DRIVER
-   /* driInitExtensions() should be called once per screen to setup extension
-    * indices.  There is no need to call it when the context is created since
-    * XMesa enables mesa sw extensions on its own.
-    */
-   driInitExtensions( NULL, card_extensions, GL_FALSE );
-#endif
-
 #ifndef XFree86Server
    /* For debugging only */
    if (_mesa_getenv("MESA_XSYNC")) {
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 490b8f0..ea820d7 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -117,6 +117,7 @@
 #include "syncobj.h"
 #endif
 #include "rastpos.h"
+#include "remap.h"
 #include "scissor.h"
 #include "shared.h"
 #include "simple_list.h"
@@ -407,6 +408,8 @@ one_time_init( GLcontext *ctx )
 
       _mesa_get_cpu_features();
 
+      _mesa_init_remap_table();
+
       _mesa_init_sqrt_table();
 
       for (i = 0; i < 256; i++) {
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 7107538..0838014 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -55,6 +55,7 @@ MAIN_SOURCES = \
 	main/rastpos.c \
 	main/rbadaptors.c \
 	main/readpix.c \
+	main/remap.c \
 	main/renderbuffer.c \
 	main/scissor.c \
 	main/shaders.c \




More information about the mesa-commit mailing list