summaryrefslogtreecommitdiff
path: root/xserver/glx/glxdricommon.c
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/glx/glxdricommon.c')
-rw-r--r--xserver/glx/glxdricommon.c124
1 files changed, 68 insertions, 56 deletions
diff --git a/xserver/glx/glxdricommon.c b/xserver/glx/glxdricommon.c
index dbf199c93..1baf082cf 100644
--- a/xserver/glx/glxdricommon.c
+++ b/xserver/glx/glxdricommon.c
@@ -35,35 +35,13 @@
#include <GL/glxtokens.h>
#include <GL/internal/dri_interface.h>
#include <os.h>
+#include "extinit.h"
#include "glxserver.h"
#include "glxext.h"
#include "glxcontext.h"
#include "glxscreens.h"
#include "glxdricommon.h"
-static int
-getUST(int64_t * ust)
-{
- struct timeval tv;
-
- if (ust == NULL)
- return -EFAULT;
-
- if (gettimeofday(&tv, NULL) == 0) {
- ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
- return 0;
- }
- else {
- return -errno;
- }
-}
-
-const __DRIsystemTimeExtension systemTimeExtension = {
- {__DRI_SYSTEM_TIME, 1},
- getUST,
- NULL,
-};
-
#define __ATTRIB(attrib, field) \
{ attrib, offsetof(__GLXconfig, field) }
@@ -206,28 +184,30 @@ createModeFromConfig(const __DRIcoreExtension * core,
config->config.yInverted = GL_TRUE;
#ifdef COMPOSITE
- /*
- * Here we decide what fbconfigs will be duplicated for compositing.
- * fgbconfigs marked with duplicatedForConf will be reserved for
- * compositing visuals.
- * It might look strange to do this decision this late when translation
- * from a __DRIConfig is already done, but using the __DRIConfig
- * accessor function becomes worse both with respect to code complexity
- * and CPU usage.
- */
- if (duplicateForComp &&
- (render_type_is_pbuffer_only(renderType) ||
- config->config.rgbBits != 32 ||
- config->config.redBits != 8 ||
- config->config.greenBits != 8 ||
- config->config.blueBits != 8 ||
- config->config.visualRating != GLX_NONE ||
- config->config.sampleBuffers != 0)) {
- free(config);
- return NULL;
- }
+ if (!noCompositeExtension) {
+ /*
+ * Here we decide what fbconfigs will be duplicated for compositing.
+ * fgbconfigs marked with duplicatedForConf will be reserved for
+ * compositing visuals.
+ * It might look strange to do this decision this late when translation
+ * from a __DRIConfig is already done, but using the __DRIConfig
+ * accessor function becomes worse both with respect to code complexity
+ * and CPU usage.
+ */
+ if (duplicateForComp &&
+ (render_type_is_pbuffer_only(renderType) ||
+ config->config.rgbBits != 32 ||
+ config->config.redBits != 8 ||
+ config->config.greenBits != 8 ||
+ config->config.blueBits != 8 ||
+ config->config.visualRating != GLX_NONE ||
+ config->config.sampleBuffers != 0)) {
+ free(config);
+ return NULL;
+ }
- config->config.duplicatedForComp = duplicateForComp;
+ config->config.duplicatedForComp = duplicateForComp;
+ }
#endif
return &config->config;
@@ -261,14 +241,16 @@ glxConvertConfigs(const __DRIcoreExtension * core,
}
#ifdef COMPOSITE
- /* Duplicate fbconfigs for use with compositing visuals */
- for (i = 0; configs[i]; i++) {
- tail->next = createModeFromConfig(core, configs[i], GLX_TRUE_COLOR,
- GL_TRUE);
- if (tail->next == NULL)
- continue;
-
- tail = tail->next;
+ if (!noCompositeExtension) {
+ /* Duplicate fbconfigs for use with compositing visuals */
+ for (i = 0; configs[i]; i++) {
+ tail->next = createModeFromConfig(core, configs[i], GLX_TRUE_COLOR,
+ GL_TRUE);
+ if (tail->next == NULL)
+ continue;
+
+ tail = tail->next;
+ }
}
#endif
@@ -295,14 +277,44 @@ glxProbeDriver(const char *driverName,
char filename[PATH_MAX];
char *get_extensions_name;
const __DRIextension **extensions = NULL;
+ const char *path = NULL;
+
+ /* Search in LIBGL_DRIVERS_PATH if we're not setuid. */
+ 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",
- dri_driver_path, driverName);
+ snprintf(filename, sizeof filename, "%.*s/%s_dri.so", path_len, path,
+ driverName);
+
+ driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ if (driver != NULL)
+ break;
- driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
- if (driver == NULL) {
LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
filename, dlerror());
+
+ path = next;
+ } while (path);
+
+ if (driver == NULL) {
+ LogMessage(X_ERROR, "AIGLX error: unable to load driver %s\n",
+ driverName);
goto cleanup_failure;
}