driParseOptionInfo(&instance->available_dri_options, radv_dri_options_xml);
driParseConfigFiles(&instance->dri_options,
&instance->available_dri_options,
- 0, "radv", NULL);
+ 0, "radv", NULL,
+ instance->engineName,
+ instance->engineVersion);
}
VkResult radv_CreateInstance(
driParseOptionInfo(&dev->option_info, xml_options);
driParseConfigFiles(&dev->option_cache, &dev->option_info, 0,
- dev->driver_name, NULL);
+ dev->driver_name, NULL, NULL, 0);
}
char *
ctx->base.throttling = ctx->base.throttling_value > 0;
driParseOptionInfo(&defaultInitOptions, __driConfigOptionsNine);
- driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "nine", NULL);
+ driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0,
+ "nine", NULL, NULL, 0);
if (driCheckOption(&userInitOptions, "throttle_value", DRI_INT)) {
throttling_value_user = driQueryOptioni(&userInitOptions, "throttle_value");
if (throttling_value_user == -1)
driParseOptionInfo(&instance->available_dri_options, anv_dri_options_xml);
driParseConfigFiles(&instance->dri_options, &instance->available_dri_options,
- 0, "anv", NULL);
+ 0, "anv", NULL,
+ instance->app_info.engine_name,
+ instance->app_info.engine_version);
*pInstance = anv_instance_to_handle(instance);
driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader);
driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0,
- "loader", kernel_driver);
+ "loader", kernel_driver, NULL, 0);
if (driCheckOption(&userInitOptions, "dri_driver", DRI_STRING)) {
char *opt = driQueryOptionstr(&userInitOptions, "dri_driver");
/* not an empty string */
char *prime = NULL;
driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader);
- driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "loader", NULL);
+ driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0,
+ "loader", NULL, NULL, 0);
if (driCheckOption(&userInitOptions, "device_id", DRI_STRING))
prime = strdup(driQueryOptionstr(&userInitOptions, "device_id"));
driDestroyOptionCache(&userInitOptions);
/* Option parsing before ->InitScreen(), as some options apply there. */
driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions);
- driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2", NULL);
+ driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum,
+ "dri2", NULL, NULL, 0);
*driver_configs = psp->driver->InitScreen(psp);
if (*driver_configs == NULL) {
0, sizeof(ctx->TextureFormatSupported));
driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
- sPriv->myNum, "i915", NULL);
+ sPriv->myNum, "i915", NULL, NULL, 0);
intel->maxBatchSize = 4096;
/* Estimate the size of the mappable aperture into the GTT. There's an
driOptionCache *options = &brw->optionCache;
driParseConfigFiles(options, &brw->screen->optionCache,
brw->driContext->driScreenPriv->myNum,
- "i965", NULL);
+ "i965", NULL, NULL, 0);
if (INTEL_DEBUG & DEBUG_NO_HIZ) {
brw->has_hiz = false;
driParseOptionInfo(&options, brw_config_options.xml);
driParseConfigFiles(&screen->optionCache, &options, dri_screen->myNum,
- "i965", NULL);
+ "i965", NULL, NULL, 0);
driDestroyOptionCache(&options);
screen->driScrnPriv = dri_screen;
* the default textures.
*/
driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
- screen->driScreen->myNum, "r200", NULL);
+ screen->driScreen->myNum, "r200", NULL, NULL, 0);
rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
"def_max_anisotropy");
if (driQueryOptionb( &rmesa->radeon.optionCache, "hyperz"))
rmesa->using_hyperz = GL_TRUE;
-
+
/* Init default driver functions then plug in our R200-specific functions
* (the texture functions are especially important)
*/
/* init exp fog table data */
radeonInitStaticFogData();
-
+
/* Parse configuration files.
* Do this here so that initialMaxAnisotropy is set before we create
* the default textures.
*/
driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
- screen->driScreen->myNum, "radeon", NULL);
+ screen->driScreen->myNum, "radeon", NULL, NULL, 0);
rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
"def_max_anisotropy");
<!DOCTYPE driconf [
<!ELEMENT driconf (device+)>
- <!ELEMENT device (application+)>
+ <!ELEMENT device (application | engine)+>
<!ATTLIST device driver CDATA #IMPLIED>
<!ELEMENT application (option+)>
<!ATTLIST application name CDATA #REQUIRED
executable CDATA #REQUIRED>
+ <!ELEMENT engine (option+)>
+
+ <!-- engine_name_match: A regexp matching the engine name -->
+ <!-- engine_version: A list of version in range format
+ (version 1 to 4 and version 7 to 8 : "1:4,7:8") -->
+
+ <!ATTLIST engine engine_name_match CDATA #REQUIRED
+ engine_versions CDATA #REQUIRED>
+
<!ELEMENT option EMPTY>
<!ATTLIST option name CDATA #REQUIRED
value CDATA #REQUIRED>
#include <errno.h>
#include <dirent.h>
#include <fnmatch.h>
+#include <regex.h>
#include "xmlconfig.h"
#include "u_process.h"
int screenNum;
const char *driverName, *execName;
const char *kernelDriverName;
+ const char *engineName;
+ uint32_t engineVersion;
uint32_t ignoringDevice;
uint32_t ignoringApp;
uint32_t inDriConf;
/** \brief Elements in configuration files. */
enum OptConfElem {
- OC_APPLICATION = 0, OC_DEVICE, OC_DRICONF, OC_OPTION, OC_COUNT
+ OC_APPLICATION = 0, OC_DEVICE, OC_DRICONF, OC_ENGINE, OC_OPTION, OC_COUNT
};
static const XML_Char *OptConfElems[] = {
[OC_APPLICATION] = "application",
[OC_DEVICE] = "device",
[OC_DRICONF] = "driconf",
+ [OC_ENGINE] = "engine",
[OC_OPTION] = "option",
};
}
}
+static bool
+valueInRanges(const driOptionInfo *info, uint32_t value)
+{
+ uint32_t i;
+
+ for (i = 0; i < info->nRanges; i++) {
+ if (info->ranges[i].start._int <= value &&
+ info->ranges[i].end._int >= value)
+ return true;
+ }
+
+ return false;
+}
+
/** \brief Parse attributes of an application element. */
static void
parseAppAttr(struct OptConfData *data, const XML_Char **attr)
data->ignoringApp = data->inApp;
}
+/** \brief Parse attributes of an application element. */
+static void
+parseEngineAttr(struct OptConfData *data, const XML_Char **attr)
+{
+ uint32_t i;
+ const XML_Char *engine_name_match = NULL, *engine_versions = NULL;
+ driOptionInfo version_ranges = {
+ .type = DRI_INT,
+ };
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "name")) /* not needed here */;
+ else if (!strcmp (attr[i], "engine_name_match")) engine_name_match = attr[i+1];
+ else if (!strcmp (attr[i], "engine_versions")) engine_versions = attr[i+1];
+ else XML_WARNING("unknown application attribute: %s.", attr[i]);
+ }
+ if (engine_name_match) {
+ regex_t re;
+
+ if (regcomp (&re, engine_name_match, REG_EXTENDED|REG_NOSUB) != 0) {
+ if (regexec (&re, data->engineName, 0, NULL, 0) == REG_NOMATCH)
+ data->ignoringApp = data->inApp;
+ regfree (&re);
+ } else
+ XML_WARNING ("Invalid engine_name_match=\"%s\".", engine_name_match);
+ }
+ if (engine_versions) {
+ if (parseRanges (&version_ranges, engine_versions) &&
+ !valueInRanges (&version_ranges, data->engineVersion))
+ data->ignoringApp = data->inApp;
+ }
+
+ free(version_ranges.ranges);
+}
+
/** \brief Parse attributes of an option element. */
static void
parseOptConfAttr(struct OptConfData *data, const XML_Char **attr)
if (!data->inDevice)
XML_WARNING1 ("<application> should be inside <device>.");
if (data->inApp)
- XML_WARNING1 ("nested <application> elements.");
+ XML_WARNING1 ("nested <application> or <engine> elements.");
data->inApp++;
if (!data->ignoringDevice && !data->ignoringApp)
parseAppAttr (data, attr);
break;
+ case OC_ENGINE:
+ if (!data->inDevice)
+ XML_WARNING1 ("<engine> should be inside <device>.");
+ if (data->inApp)
+ XML_WARNING1 ("nested <application> or <engine> elements.");
+ data->inApp++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseEngineAttr (data, attr);
+ break;
case OC_OPTION:
if (!data->inApp)
XML_WARNING1 ("<option> should be inside <application>.");
data->ignoringDevice = 0;
break;
case OC_APPLICATION:
+ case OC_ENGINE:
if (data->inApp-- == data->ignoringApp)
data->ignoringApp = 0;
break;
void
driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
int screenNum, const char *driverName,
- const char *kernelDriverName)
+ const char *kernelDriverName,
+ const char *engineName, uint32_t engineVersion)
{
char *home;
struct OptConfData userData;
userData.screenNum = screenNum;
userData.driverName = driverName;
userData.kernelDriverName = kernelDriverName;
+ userData.engineName = engineName ? engineName : "";
+ userData.engineVersion = engineVersion;
userData.execName = util_get_process_name();
parseConfigDir(&userData, DATADIR "/drirc.d");
#include "util/mesa-sha1.h"
#include "util/ralloc.h"
+#include <stdint.h>
#include <string.h>
#define STRING_CONF_MAXLEN 25
const char *configOptions);
/** \brief Initialize option cache from info and parse configuration files
*
- * To be called in <driver>CreateContext. screenNum, driverName and
- * kernelDriverName select device sections. */
+ * To be called in <driver>CreateContext. screenNum, driverName,
+ * kernelDriverName and engineName select device sections. */
void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
int screenNum, const char *driverName,
- const char *kernelDriverName);
+ const char *kernelDriverName,
+ const char *engineName, uint32_t engineVersion);
/** \brief Destroy option info
*
* To be called in <driver>DestroyScreen */