driconf: Support selection by Vulkan applicationName.
This adds applicationName + version through like engineName. Rationale: A game (World War Z) includes the store name in the executable name, so has multiple executable names. CC: <mesa-stable@lists.freedesktop.org> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6120>
This commit is contained in:
@@ -715,7 +715,9 @@ struct OptConfData {
|
||||
const char *driverName, *execName;
|
||||
const char *kernelDriverName;
|
||||
const char *engineName;
|
||||
const char *applicationName;
|
||||
uint32_t engineVersion;
|
||||
uint32_t applicationVersion;
|
||||
uint32_t ignoringDevice;
|
||||
uint32_t ignoringApp;
|
||||
uint32_t inDriConf;
|
||||
@@ -782,10 +784,20 @@ parseAppAttr(struct OptConfData *data, const XML_Char **attr)
|
||||
uint32_t i;
|
||||
const XML_Char *exec = NULL;
|
||||
const XML_Char *sha1 = NULL;
|
||||
const XML_Char *application_name_match = NULL;
|
||||
const XML_Char *application_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], "executable")) exec = attr[i+1];
|
||||
else if (!strcmp (attr[i], "sha1")) sha1 = attr[i+1];
|
||||
else if (!strcmp (attr[i], "application_name_match"))
|
||||
application_name_match = attr[i+1];
|
||||
else if (!strcmp (attr[i], "application_versions"))
|
||||
application_versions = attr[i+1];
|
||||
else XML_WARNING("unknown application attribute: %s.", attr[i]);
|
||||
}
|
||||
if (exec && strcmp (exec, data->execName)) {
|
||||
@@ -814,6 +826,20 @@ parseAppAttr(struct OptConfData *data, const XML_Char **attr)
|
||||
data->ignoringApp = data->inApp;
|
||||
}
|
||||
}
|
||||
} else if (application_name_match) {
|
||||
regex_t re;
|
||||
|
||||
if (regcomp (&re, application_name_match, REG_EXTENDED|REG_NOSUB) == 0) {
|
||||
if (regexec (&re, data->applicationName, 0, NULL, 0) == REG_NOMATCH)
|
||||
data->ignoringApp = data->inApp;
|
||||
regfree (&re);
|
||||
} else
|
||||
XML_WARNING ("Invalid application_name_match=\"%s\".", application_name_match);
|
||||
}
|
||||
if (application_versions) {
|
||||
if (parseRanges (&version_ranges, application_versions) &&
|
||||
!valueInRanges (&version_ranges, data->applicationVersion))
|
||||
data->ignoringApp = data->inApp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1103,6 +1129,7 @@ void
|
||||
driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
int screenNum, const char *driverName,
|
||||
const char *kernelDriverName,
|
||||
const char *applicationName, uint32_t applicationVersion,
|
||||
const char *engineName, uint32_t engineVersion)
|
||||
{
|
||||
char *home;
|
||||
@@ -1114,6 +1141,8 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
userData.screenNum = screenNum;
|
||||
userData.driverName = driverName;
|
||||
userData.kernelDriverName = kernelDriverName;
|
||||
userData.applicationName = applicationName ? applicationName : "";
|
||||
userData.applicationVersion = applicationVersion;
|
||||
userData.engineName = engineName ? engineName : "";
|
||||
userData.engineVersion = engineVersion;
|
||||
userData.execName = util_get_process_name();
|
||||
|
Reference in New Issue
Block a user