applied Felix's patch for configuration system
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 12 Dec 2003 16:38:57 +0000 (16:38 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 12 Dec 2003 16:38:57 +0000 (16:38 +0000)
src/mesa/drivers/dri/common/xmlconfig.c
src/mesa/drivers/dri/common/xmlconfig.h
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r200/r200_screen.c
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/sis/sis_context.c
src/mesa/drivers/dri/sis/sis_screen.c

index a6d4c8a..887f720 100644 (file)
@@ -504,16 +504,17 @@ static void optInfoEndElem (void *userData, const XML_Char *name) {
     }
 }
 
-void driParseOptionInfo (driOptionCache *info) {
+void driParseOptionInfo (driOptionCache *info,
+                        const char *configOptions, GLuint nConfigOptions) {
     XML_Parser p;
     int status;
     struct OptInfoData userData;
     struct OptInfoData *data = &userData;
-    GLuint nOptions;
+    GLuint realNoptions;
 
   /* determine hash table size and allocate memory */
     GLuint size, log2size;
-    for (size = 1, log2size = 0; size < __driNConfigOptions*3/2;
+    for (size = 1, log2size = 0; size < nConfigOptions*3/2;
         size <<= 1, ++log2size);
     info->tableSize = log2size;
     info->info = CALLOC (size * sizeof (driOptionInfo));
@@ -537,21 +538,21 @@ void driParseOptionInfo (driOptionCache *info) {
     userData.inEnum = GL_FALSE;
     userData.curOption = -1;
 
-    status = XML_Parse (p, __driConfigOptions, strlen (__driConfigOptions), 1);
+    status = XML_Parse (p, configOptions, strlen (configOptions), 1);
     if (!status)
        XML_FATAL ("%s.", XML_ErrorString(XML_GetErrorCode(p)));
 
     XML_ParserFree (p);
 
-  /* Check if the actual number of options matches __driNConfigOptions.
+  /* Check if the actual number of options matches nConfigOptions.
    * A mismatch is not fatal (a hash table overflow would be) but we
    * want the driver developer's attention anyway. */
-    nOptions = countOptions (info);
-    if (nOptions != __driNConfigOptions) {
+    realNoptions = countOptions (info);
+    if (realNoptions != nConfigOptions) {
        fprintf (stderr,
-                "Error: __driNConfigOptions (%u) does not match the actual number of options in\n"
+                "Error: nConfigOptions (%u) does not match the actual number of options in\n"
                 "       __driConfigOptions (%u).\n",
-                __driNConfigOptions, nOptions);
+                nConfigOptions, realNoptions);
     }
 }
 
index 710e328..b636349 100644 (file)
@@ -81,21 +81,20 @@ typedef struct driOptionCache {
    * The value is the same in the screen and all contexts. */
 } driOptionCache;
 
-/** \brief XML document describing available options
+/** \brief Parse XML option info from configOptions
  *
- * This must be defined in a driver-specific soure file. xmlpool.h
- * defines helper macros and common options. */
-extern const char __driConfigOptions[];
-/** \brief The number of options supported by a driver
+ * To be called in <driver>CreateScreen 
  *
- * This is used to choose an appropriate hash table size. So any value
- * larger than the actual number of options will work. */
-extern const GLuint __driNConfigOptions;
-
-/** \brief Parse XML option info from __driConfigOptions
+ * \param info    pointer to a driOptionCache that will store the option info
+ * \param configOptions   XML document describing available configuration opts
+ * \param nConfigOptions  number of options, used to choose a hash table size
  *
- * To be called in <driver>CreateScreen */
-void driParseOptionInfo (driOptionCache *info);
+ * For the option information to be available to external configuration tools
+ * it must be a public symbol __driConfigOptions. It is also passed as a
+ * parameter to driParseOptionInfo in order to avoid driver-independent code
+ * depending on symbols in driver-specific code. */
+void driParseOptionInfo (driOptionCache *info,
+                        const char *configOptions, GLuint nConfigOptions);
 /** \brief Initialize option cache from info and parse configuration files
  *
  * To be called in <driver>CreateContext. screenNum and driverName select
index 75a6c32..7f199ea 100644 (file)
@@ -73,7 +73,7 @@ DRI_CONF_BEGIN
         DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-const GLuint __driNConfigOptions = 3;
+static const GLuint __driNConfigOptions = 3;
 
 #ifndef MGA_DEBUG
 int MGA_DEBUG = 0;
@@ -241,7 +241,8 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
    mgaScreen->sarea_priv_offset = serverInfo->sarea_priv_offset;
 
    /* parse information in __driConfigOptions */
-   driParseOptionInfo (&mgaScreen->optionCache);
+   driParseOptionInfo (&mgaScreen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
 
    return GL_TRUE;
 }
index a26c9dd..73547aa 100644 (file)
@@ -59,30 +59,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "vblank.h"
 #include "utils.h"
 #include "texmem.h"
-
-/* R128 configuration
- */
-#include "xmlpool.h"
-
-const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-    DRI_CONF_SECTION_PERFORMANCE
-        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
-    DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_QUALITY
-        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
-    DRI_CONF_SECTION_END
-#if ENABLE_PERF_BOXES
-    DRI_CONF_SECTION_DEBUG
-        DRI_CONF_PERFORMANCE_BOXES(false)
-    DRI_CONF_SECTION_END
-#endif
-DRI_CONF_END;
-#if ENABLE_PERF_BOXES
-const GLuint __driNConfigOptions = 3;
-#else
-const GLuint __driNConfigOptions = 2;
-#endif
+#include "xmlpool.h" /* for symbolic values of enum-type options */
 
 #ifndef R128_DEBUG
 int R128_DEBUG = 0;
index 8eee8bb..ac8f185 100644 (file)
@@ -50,6 +50,30 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "glxextensions.h"
 #endif
 
+/* R128 configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+    DRI_CONF_SECTION_PERFORMANCE
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_QUALITY
+        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+    DRI_CONF_SECTION_END
+#if ENABLE_PERF_BOXES
+    DRI_CONF_SECTION_DEBUG
+        DRI_CONF_PERFORMANCE_BOXES(false)
+    DRI_CONF_SECTION_END
+#endif
+DRI_CONF_END;
+#if ENABLE_PERF_BOXES
+static const GLuint __driNConfigOptions = 3;
+#else
+static const GLuint __driNConfigOptions = 2;
+#endif
+
 #if 1
 /* Including xf86PciInfo.h introduces a bunch of errors...
  */
@@ -80,7 +104,8 @@ r128CreateScreen( __DRIscreenPrivate *sPriv )
    if ( !r128Screen ) return NULL;
 
    /* parse information in __driConfigOptions */
-   driParseOptionInfo (&r128Screen->optionCache);
+   driParseOptionInfo (&r128Screen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
 
    /* This is first since which regions we map depends on whether or
     * not we are using a PCI card.
index 5ab6b78..08bea79 100644 (file)
@@ -64,35 +64,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "vblank.h"
 #include "utils.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
 #ifndef R200_DEBUG
 int R200_DEBUG = (0);
 #endif
 
 
-/* R200 configuration
- */
-#include "xmlpool.h"
-
-const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-    DRI_CONF_SECTION_PERFORMANCE
-        DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
-        DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
-        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
-    DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_QUALITY
-        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
-        DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
-        DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
-        DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
-    DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_DEBUG
-        DRI_CONF_NO_RAST(false)
-    DRI_CONF_SECTION_END
-DRI_CONF_END;
-const GLuint __driNConfigOptions = 8;
-
-
 /* Return the width and height of the given buffer.
  */
 static void r200GetBufferSize( GLframebuffer *buffer,
index fe24668..a79ac71 100644 (file)
@@ -50,6 +50,30 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef _SOLO
 #include "glxextensions.h"
 #endif
+
+/* R200 configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+    DRI_CONF_SECTION_PERFORMANCE
+        DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+        DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_QUALITY
+        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+        DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+        DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+        DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_DEBUG
+        DRI_CONF_NO_RAST(false)
+    DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 8;
+
 #if 1
 /* Including xf86PciInfo.h introduces a bunch of errors...
  */
@@ -109,7 +133,8 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
    }
 
    /* parse information in __driConfigOptions */
-   driParseOptionInfo (&screen->optionCache);
+   driParseOptionInfo (&screen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
 
    /* This is first since which regions we map depends on whether or
     * not we are using a PCI card.
index f2af26c..3a97215 100644 (file)
@@ -64,34 +64,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "vblank.h"
 #include "utils.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
 #ifndef RADEON_DEBUG
 int RADEON_DEBUG = (0);
 #endif
 
 
-/* Radeon configuration
- */
-#include "xmlpool.h"
-
-const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-    DRI_CONF_SECTION_PERFORMANCE
-        DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
-        DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
-        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
-    DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_QUALITY
-        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
-        DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
-        DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
-        DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
-    DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_DEBUG
-        DRI_CONF_NO_RAST(false)
-    DRI_CONF_SECTION_END
-DRI_CONF_END;
-const GLuint __driNConfigOptions = 8;
-
 /* Return the width and height of the given buffer.
  */
 static void radeonGetBufferSize( GLframebuffer *buffer,
index 3bb7090..edd7c0f 100644 (file)
@@ -50,6 +50,29 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "glxextensions.h"
 #endif
 
+/* Radeon configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+    DRI_CONF_SECTION_PERFORMANCE
+        DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+        DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_QUALITY
+        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+        DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+        DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+        DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_DEBUG
+        DRI_CONF_NO_RAST(false)
+    DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 8;
+
 #if 1
 /* Including xf86PciInfo.h introduces a bunch of errors...
  */
@@ -91,7 +114,8 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
    }
 
    /* parse information in __driConfigOptions */
-   driParseOptionInfo (&screen->optionCache);
+   driParseOptionInfo (&screen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
 
    /* This is first since which regions we map depends on whether or
     * not we are using a PCI card.
index 6aa6194..7daa947 100644 (file)
@@ -59,21 +59,6 @@ int GlobalCurrentHwcx = -1;
 int GlobalHwcxCountBase = 1;
 int GlobalCmdQueueLen = 0;
 
-#include "xmlpool.h"
-
-const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-       DRI_CONF_SECTION_DEBUG
-               DRI_CONF_OPT_BEGIN(agp_disable,bool,false)
-               DRI_CONF_DESC(en,"Disable AGP vertex dispatch")
-               DRI_CONF_OPT_END
-               DRI_CONF_OPT_BEGIN(fallback_force,bool,false)
-               DRI_CONF_DESC(en,"Force software fallback")
-               DRI_CONF_OPT_END
-       DRI_CONF_SECTION_END
-DRI_CONF_END;
-const GLuint __driNConfigOptions = 2;
-
 static const char * const card_extensions[] =
 {
    "GL_ARB_multitexture",
index f1a5103..1d78801 100644 (file)
@@ -39,6 +39,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "sis_dri.h"
 #include "sis_lock.h"
 
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+       DRI_CONF_SECTION_DEBUG
+               DRI_CONF_OPT_BEGIN(agp_disable,bool,false)
+               DRI_CONF_DESC(en,"Disable AGP vertex dispatch")
+               DRI_CONF_OPT_END
+               DRI_CONF_OPT_BEGIN(fallback_force,bool,false)
+               DRI_CONF_DESC(en,"Force software fallback")
+               DRI_CONF_OPT_END
+       DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 2;
+
 /* Create the device specific screen private data struct.
  */
 static sisScreenPtr
@@ -86,7 +101,8 @@ sisCreateScreen( __DRIscreenPrivate *sPriv )
    sisScreen->driScreen = sPriv;
 
    /* parse information in __driConfigOptions */
-   driParseOptionInfo(&sisScreen->optionCache);
+   driParseOptionInfo(&sisScreen->optionCache,
+                     __driConfigOptions, __driNConfigOptions);
 
    return sisScreen;
 }