util/xmlconfig: add MESA_DRICONF_EXECUTABLE_OVERRIDE

Allow the loading process to affect driconf option matching without
changing the behavior throughout mesa common code or leaking the name of
the loading process to logs, artifact storage, or in sub-thread naming,
as can be the case with the broader MESA_PROCESS_NAME override.

This new MESA_DRICONF_EXECUTABLE_OVERRIDE takes higher precedence over
MESA_PROCESS_NAME in the case where both are set.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20779>
This commit is contained in:
Ryan Neph
2023-01-19 10:48:59 -08:00
committed by Marge Bot
parent 887ca5e1b2
commit 65adf0c0af
3 changed files with 23 additions and 1 deletions

View File

@@ -173,6 +173,12 @@ Core Mesa environment variables
features of the given language version if it's higher than what's
normally reported. (for developers only)
.. envvar:: MESA_DRICONF_EXECUTABLE_OVERRIDE
if set, overrides the "executable" string used specifically for driconf
option matching. This takes higher precedence over more general process
name override (e.g. MESA_PROCESS_NAME).
.. envvar:: MESA_SHADER_CACHE_DISABLE
if set to ``true``, disables the on-disk shader cache. If set to

View File

@@ -288,4 +288,15 @@ TEST_F(xmlconfig_test, drirc_exec_regexp)
EXPECT_EQ(driQueryOptioni(&cache, "mesa_drirc_option"), 7);
driDestroyOptionCache(&cache);
}
TEST_F(xmlconfig_test, drirc_exec_override)
{
putenv("MESA_DRICONF_EXECUTABLE_OVERRIDE=app1");
driOptionCache cache = drirc_init("driver", "drm",
NULL,
NULL, 0,
NULL, 0);
EXPECT_EQ(driQueryOptioni(&cache, "mesa_drirc_option"), 1);
driDestroyOptionCache(&cache);
}
#endif

View File

@@ -1199,6 +1199,11 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
initOptionCache(cache, info);
struct OptConfData userData = {0};
if (!execname)
execname = os_get_option("MESA_DRICONF_EXECUTABLE_OVERRIDE");
if (!execname)
execname = util_get_process_name();
userData.cache = cache;
userData.screenNum = screenNum;
userData.driverName = driverName;
@@ -1208,7 +1213,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
userData.applicationVersion = applicationVersion;
userData.engineName = engineName ? engineName : "";
userData.engineVersion = engineVersion;
userData.execName = execname ? execname : util_get_process_name();
userData.execName = execname;
#if WITH_XMLCONFIG
char *home;