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 a6d4c8ab941d9af4aa2af35a70d526d82277e2af..887f720f0d9344fd573ef724c1fc4617678f7736 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 710e328e015821eb653e143f809d3e828e77f6be..b636349b1f4cfe6e85141ae64c8a0b9a81ab1c84 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 75a6c32b5749055e68ca22ccec5265a753ea8281..7f199ea5c418fd73fa2d8540c9140130e893ca33 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 a26c9dd340170e8a6ebc2a02f69cbadcb716d544..73547aa67f7e20c61155d56a78a1fc22d40c052e 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 8eee8bbe06899bf584edb6543d8fe5dcbceee24e..ac8f185a457dd494b6a28d8e31d62fb00a8f824a 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 5ab6b781cb00c200b4bb3cd3eb924addb6922537..08bea796ccc3e290c87846aa4d8311e263113399 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 fe246686a0154c9d7520c8904ccde127bb743d51..a79ac71d42b3666cc152fcafde666488db8f8cb2 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 f2af26c6b6ef8e6efa1d7a3bc6bb43010a66133c..3a9721540bec449ccaee36441ef9c25fa408b252 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 3bb709019f0467b41744389c8edc4b1c23b9541d..edd7c0f34e4d7cfad1b7d5c1315f06bfecb3edf3 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 6aa61944086835f46017dafbc76c4aac1c338c43..7daa947a464263a2c6e48eb4335afa7437718c38 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 f1a51039d295107250e2cf31be7d33f0142a7055..1d78801442d3b8fa0145e74c4e46bb58f710dacf 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;
 }