summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c')
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index e0fb249b6..4b6ac054f 100644
--- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -27,13 +27,14 @@
#include "pipe_loader_priv.h"
+#include "util/u_cpu_detect.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_string.h"
#include "util/u_dl.h"
#include "util/u_file.h"
#include "util/xmlconfig.h"
-#include "util/xmlpool.h"
+#include "util/driconf.h"
#include <string.h>
@@ -51,11 +52,9 @@ static int (*backends[])(struct pipe_loader_device **, int) = {
&pipe_loader_sw_probe
};
-const char gallium_driinfo_xml[] =
- DRI_CONF_BEGIN
+const driOptionDescription gallium_driconf[] = {
#include "driinfo_gallium.h"
- DRI_CONF_END
-;
+};
int
pipe_loader_probe(struct pipe_loader_device **devs, int ndev)
@@ -87,32 +86,63 @@ pipe_loader_base_release(struct pipe_loader_device **dev)
*dev = NULL;
}
+static driOptionDescription *
+merge_driconf(const driOptionDescription *driver_driconf, unsigned driver_count,
+ unsigned *merged_count)
+{
+ unsigned gallium_count = ARRAY_SIZE(gallium_driconf);
+ driOptionDescription *merged = malloc((driver_count + gallium_count) *
+ sizeof(*merged));
+ if (!merged) {
+ *merged_count = 0;
+ return NULL;
+ }
+
+ memcpy(merged, gallium_driconf, sizeof(*merged) * gallium_count);
+ memcpy(&merged[gallium_count], driver_driconf, sizeof(*merged) * driver_count);
+
+ *merged_count = driver_count + gallium_count;
+ return merged;
+}
+
void
pipe_loader_load_options(struct pipe_loader_device *dev)
{
if (dev->option_info.info)
return;
- const char *xml_options = dev->ops->get_driconf_xml(dev);
- if (!xml_options)
- xml_options = gallium_driinfo_xml;
+ unsigned driver_count, merged_count;
+ const driOptionDescription *driver_driconf =
+ dev->ops->get_driconf(dev, &driver_count);
+
+ const driOptionDescription *merged_driconf =
+ merge_driconf(driver_driconf, driver_count, &merged_count);
- driParseOptionInfo(&dev->option_info, xml_options);
+ driParseOptionInfo(&dev->option_info, merged_driconf, merged_count);
driParseConfigFiles(&dev->option_cache, &dev->option_info, 0,
- dev->driver_name, NULL, NULL, 0);
+ dev->driver_name, NULL, NULL, 0, NULL, 0);
+ free((void *)merged_driconf);
}
char *
pipe_loader_get_driinfo_xml(const char *driver_name)
{
+ unsigned driver_count = 0;
+ const driOptionDescription *driver_driconf = NULL;
+
#ifdef HAVE_LIBDRM
- char *xml = pipe_loader_drm_get_driinfo_xml(driver_name);
-#else
- char *xml = NULL;
+ driver_driconf = pipe_loader_drm_get_driconf_by_name(driver_name,
+ &driver_count);
#endif
- if (!xml)
- xml = strdup(gallium_driinfo_xml);
+ unsigned merged_count;
+ const driOptionDescription *merged_driconf =
+ merge_driconf(driver_driconf, driver_count, &merged_count);
+ free((void *)driver_driconf);
+
+ char *xml = driGetOptionsXml(merged_driconf, merged_count);
+
+ free((void *)merged_driconf);
return xml;
}
@@ -122,6 +152,7 @@ pipe_loader_create_screen(struct pipe_loader_device *dev)
{
struct pipe_screen_config config;
+ util_cpu_detect();
pipe_loader_load_options(dev);
config.options = &dev->option_cache;