glx: honor LIBGL_DRIVERS_PATH when loading DRI drivers
Allow switching to another driver build without a full installation. Glamor already takes LIBGL_DRIVERS_PATH into account, so this change makes sure that the same driver is used in both parts of the server. Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Ben Crocker <bcrocker@redhat.com> Reviewed-by: Antoine Martin <antoine@nagafix.co.uk> Tested-by: Ben Crocker <bcrocker@redhat.com>
This commit is contained in:
parent
75a869a4e7
commit
319af6f471
|
@ -272,14 +272,44 @@ glxProbeDriver(const char *driverName,
|
||||||
char filename[PATH_MAX];
|
char filename[PATH_MAX];
|
||||||
char *get_extensions_name;
|
char *get_extensions_name;
|
||||||
const __DRIextension **extensions = NULL;
|
const __DRIextension **extensions = NULL;
|
||||||
|
const char *path = NULL;
|
||||||
|
|
||||||
snprintf(filename, sizeof filename, "%s/%s_dri.so",
|
/* Search in LIBGL_DRIVERS_PATH if we're not setuid. */
|
||||||
dri_driver_path, driverName);
|
if (!PrivsElevated())
|
||||||
|
path = getenv("LIBGL_DRIVERS_PATH");
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
path = dri_driver_path;
|
||||||
|
|
||||||
|
do {
|
||||||
|
const char *next;
|
||||||
|
int path_len;
|
||||||
|
|
||||||
|
next = strchr(path, ':');
|
||||||
|
if (next) {
|
||||||
|
path_len = next - path;
|
||||||
|
next++;
|
||||||
|
} else {
|
||||||
|
path_len = strlen(path);
|
||||||
|
next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(filename, sizeof filename, "%.*s/%s_dri.so", path_len, path,
|
||||||
|
driverName);
|
||||||
|
|
||||||
driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
|
driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
|
||||||
if (driver == NULL) {
|
if (driver != NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
|
LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
|
||||||
|
path = next;
|
||||||
|
} while (path);
|
||||||
|
|
||||||
|
if (driver == NULL) {
|
||||||
|
LogMessage(X_ERROR, "AIGLX error: unable to load driver %s\n",
|
||||||
|
driverName);
|
||||||
goto cleanup_failure;
|
goto cleanup_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue