From: Marek Olšák <marek.ol...@amd.com>

People are having issues with apps because drirc wasn't installed
into /etc. I've lost patience.
---
 src/mesa/drivers/dri/common/Makefile.am      |   4 +-
 src/mesa/drivers/dri/common/Makefile.sources |   3 +-
 src/mesa/drivers/dri/common/drirc            |  84 --------------------
 src/mesa/drivers/dri/common/drirc_built_in.h | 111 +++++++++++++++++++++++++++
 src/mesa/drivers/dri/common/xmlconfig.c      |  30 +++++++-
 5 files changed, 140 insertions(+), 92 deletions(-)
 delete mode 100644 src/mesa/drivers/dri/common/drirc
 create mode 100644 src/mesa/drivers/dri/common/drirc_built_in.h

diff --git a/src/mesa/drivers/dri/common/Makefile.am 
b/src/mesa/drivers/dri/common/Makefile.am
index b307f10..7106abe 100644
--- a/src/mesa/drivers/dri/common/Makefile.am
+++ b/src/mesa/drivers/dri/common/Makefile.am
@@ -23,7 +23,7 @@ SUBDIRS = xmlpool
 
 include Makefile.sources
 
-EXTRA_DIST = drirc xmlpool.h SConscript
+EXTRA_DIST = xmlpool.h SConscript
 
 AM_CFLAGS = \
        -I$(top_srcdir)/include \
@@ -52,5 +52,3 @@ libdri_test_stubs_la_SOURCES = $(test_stubs_FILES)
 libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN
 
 libmegadriver_stub_la_SOURCES = $(megadriver_stub_FILES)
-
-sysconf_DATA = drirc
diff --git a/src/mesa/drivers/dri/common/Makefile.sources 
b/src/mesa/drivers/dri/common/Makefile.sources
index d5d8da8..71ba01d 100644
--- a/src/mesa/drivers/dri/common/Makefile.sources
+++ b/src/mesa/drivers/dri/common/Makefile.sources
@@ -6,7 +6,8 @@ DRI_COMMON_FILES := \
 
 XMLCONFIG_FILES := \
        xmlconfig.c \
-       xmlconfig.h
+       xmlconfig.h \
+       drirc_built_in.h
 
 # Paths are relative to MESA_TOP.
 mesa_dri_common_INCLUDES := \
diff --git a/src/mesa/drivers/dri/common/drirc 
b/src/mesa/drivers/dri/common/drirc
deleted file mode 100644
index bb840ea..0000000
--- a/src/mesa/drivers/dri/common/drirc
+++ /dev/null
@@ -1,84 +0,0 @@
-<!--
-
-============================================
-Application bugs worked around in this file:
-============================================
-
-* Unigine Heaven 3.0 and older contain too many bugs and can't be supported
-  by drivers that want to be compliant.
-
-* Various Unigine products don't use the #version and #extension GLSL
-  directives, meaning they only get GLSL 1.10 and no extensions for their
-  shaders.
-  Enabling all extensions for Unigine fixes most issues, but the GLSL version
-  is still 1.10.
-
-* If ARB_sample_shading is supported, Unigine Heaven 4.0 and Valley 1.0 uses
-  an #extension directive in the middle of its shaders, which is illegal
-  in GLSL.
-
-TODO: document the other workarounds.
-
--->
-
-<driconf>
-    <!-- Please always enable app-specific workarounds for all drivers and
-         screens. -->
-    <device>
-        <application name="Unigine Sanctuary" executable="Sanctuary">
-            <option name="force_glsl_extensions_warn" value="true" />
-            <option name="disable_blend_func_extended" value="true" />
-       </application>
-
-        <application name="Unigine Tropics" executable="Tropics">
-            <option name="force_glsl_extensions_warn" value="true" />
-            <option name="disable_blend_func_extended" value="true" />
-       </application>
-
-        <application name="Unigine Heaven (32-bit)" executable="heaven_x86">
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-       </application>
-
-        <application name="Unigine Heaven (64-bit)" executable="heaven_x64">
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-       </application>
-
-        <application name="Unigine Valley (32-bit)" executable="valley_x86">
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-       </application>
-
-        <application name="Unigine Valley (64-bit)" executable="valley_x64">
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-       </application>
-
-        <application name="Unigine OilRush (32-bit)" executable="OilRush_x86">
-            <option name="disable_blend_func_extended" value="true" />
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-       </application>
-
-        <application name="Unigine OilRush (64-bit)" executable="OilRush_x64">
-            <option name="disable_blend_func_extended" value="true" />
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-       </application>
-
-        <application name="Savage 2" executable="savage2.bin">
-            <option name="disable_glsl_line_continuations" value="true" />
-        </application>
-
-        <application name="Topogun (32-bit)" executable="topogun32">
-            <option name="always_have_depth_buffer" value="true" />
-        </application>
-
-        <application name="Topogun (64-bit)" executable="topogun64">
-            <option name="always_have_depth_buffer" value="true" />
-        </application>
-
-        <application name="Dead Island" executable="DeadIslandGame">
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-        </application>
-
-        <application name="Second Life" 
executable="do-not-directly-run-secondlife-bin">
-            <option name="allow_glsl_extension_directive_midshader" 
value="true" />
-        </application>
-    </device>
-</driconf>
diff --git a/src/mesa/drivers/dri/common/drirc_built_in.h 
b/src/mesa/drivers/dri/common/drirc_built_in.h
new file mode 100644
index 0000000..592b1d1
--- /dev/null
+++ b/src/mesa/drivers/dri/common/drirc_built_in.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef DRIRC_BUILT_IN_H
+#define DRIRC_BUILT_IN_H
+
+/*
+============================================
+Application bugs worked around here:
+============================================
+
+* Unigine Heaven 3.0 and older contain too many bugs and can't be supported
+  by drivers that want to be compliant.
+
+* Various Unigine products don't use the #version and #extension GLSL
+  directives, meaning they only get GLSL 1.10 and no extensions for their
+  shaders.
+  Enabling all extensions for Unigine fixes most issues, but the GLSL version
+  is still 1.10.
+
+* If ARB_sample_shading is supported, Unigine Heaven 4.0 and Valley 1.0 uses
+  an #extension directive in the middle of its shaders, which is illegal
+  in GLSL.
+
+TODO: document the other workarounds.
+
+*/
+
+static const char *drirc_built_in =
+"<driconf>"
+"    <device>"
+"        <application name='Unigine Sanctuary' executable='Sanctuary'>"
+"            <option name='force_glsl_extensions_warn' value='true' />"
+"            <option name='disable_blend_func_extended' value='true' />"
+"        </application>"
+
+"        <application name='Unigine Tropics' executable='Tropics'>"
+"            <option name='force_glsl_extensions_warn' value='true' />"
+"            <option name='disable_blend_func_extended' value='true' />"
+"        </application>"
+
+"        <application name='Unigine Heaven (32-bit)' executable='heaven_x86'>"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Unigine Heaven (64-bit)' executable='heaven_x64'>"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Unigine Valley (32-bit)' executable='valley_x86'>"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Unigine Valley (64-bit)' executable='valley_x64'>"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Unigine OilRush (32-bit)' 
executable='OilRush_x86'>"
+"            <option name='disable_blend_func_extended' value='true' />"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Unigine OilRush (64-bit)' 
executable='OilRush_x64'>"
+"            <option name='disable_blend_func_extended' value='true' />"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Savage 2' executable='savage2.bin'>"
+"            <option name='disable_glsl_line_continuations' value='true' />"
+"        </application>"
+
+"        <application name='Topogun (32-bit)' executable='topogun32'>"
+"            <option name='always_have_depth_buffer' value='true' />"
+"        </application>"
+
+"        <application name='Topogun (64-bit)' executable='topogun64'>"
+"            <option name='always_have_depth_buffer' value='true' />"
+"        </application>"
+
+"        <application name='Dead Island' executable='DeadIslandGame'>"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+
+"        <application name='Second Life' 
executable='do-not-directly-run-secondlife-bin'>"
+"            <option name='allow_glsl_extension_directive_midshader' 
value='true' />"
+"        </application>"
+"    </device>"
+"</driconf>";
+
+#endif
diff --git a/src/mesa/drivers/dri/common/xmlconfig.c 
b/src/mesa/drivers/dri/common/xmlconfig.c
index f17693e..47a9aef 100644
--- a/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/src/mesa/drivers/dri/common/xmlconfig.c
@@ -39,6 +39,7 @@
 #include "main/imports.h"
 #include "utils.h"
 #include "xmlconfig.h"
+#include "drirc_built_in.h"
 
 #undef GET_PROGRAM_NAME
 
@@ -896,6 +897,23 @@ static void initOptionCache (driOptionCache *cache, const 
driOptionCache *info)
     }
 }
 
+static void parseConfigFromString(XML_Parser p, const char *string)
+{
+   struct OptConfData *data = (struct OptConfData *)XML_GetUserData (p);
+   int size = strlen(string);
+
+   void *buffer = XML_GetBuffer(p, size);
+   if (!buffer) {
+      __driUtilMessage("Can't allocate parser buffer.");
+      return;
+   }
+
+   memcpy(buffer, string, size);
+
+   if (!XML_ParseBuffer(p, size, true))
+      XML_ERROR("%s.", XML_ErrorString(XML_GetErrorCode(p)));
+}
+
 /** \brief Parse the named configuration file */
 static void parseOneConfigFile (XML_Parser p) {
 #define BUF_SIZE 0x1000
@@ -960,16 +978,16 @@ void driParseConfigFiles (driOptionCache *cache, const 
driOptionCache *info,
        }
     }
 
-    for (i = 0; i < 2; ++i) {
+    for (i = 0; i < 3; ++i) {
        XML_Parser p;
-       if (filenames[i] == NULL)
+       if (i && filenames[i-1] == NULL)
            continue;
 
        p = XML_ParserCreate (NULL); /* use encoding specified by file */
        XML_SetElementHandler (p, optConfStartElem, optConfEndElem);
        XML_SetUserData (p, &userData);
        userData.parser = p;
-       userData.name = filenames[i];
+       userData.name = i ? filenames[i-1] : NULL;
        userData.ignoringDevice = 0;
        userData.ignoringApp = 0;
        userData.inDriConf = 0;
@@ -977,7 +995,11 @@ void driParseConfigFiles (driOptionCache *cache, const 
driOptionCache *info,
        userData.inApp = 0;
        userData.inOption = 0;
 
-       parseOneConfigFile (p);
+        if (i == 0)
+           parseConfigFromString(p, drirc_built_in);
+        else
+           parseOneConfigFile(p);
+
        XML_ParserFree (p);
     }
 
-- 
2.1.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to