aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glx
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/glx')
-rw-r--r--xorg-server/glx/glxdri.c44
-rw-r--r--xorg-server/glx/glxdri2.c39
-rw-r--r--xorg-server/glx/glxdricommon.c57
-rw-r--r--xorg-server/glx/glxdricommon.h87
-rw-r--r--xorg-server/glx/glxdriswrast.c50
5 files changed, 126 insertions, 151 deletions
diff --git a/xorg-server/glx/glxdri.c b/xorg-server/glx/glxdri.c
index e0713b8a1..b394cdedc 100644
--- a/xorg-server/glx/glxdri.c
+++ b/xorg-server/glx/glxdri.c
@@ -858,8 +858,6 @@ static const __DRIextension *loader_extensions[] = {
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
static Bool
glxDRIEnterVT (int index, int flags)
{
@@ -971,13 +969,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
drm_handle_t hFB;
int junk;
__GLXDRIscreen *screen;
- char filename[128];
Bool isCapable;
size_t buffer_size;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
const __DRIconfig **driConfigs;
- const __DRIextension **extensions;
- int i;
if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
!DRIQueryDirectRenderingCapable(pScreen, &isCapable) ||
@@ -1052,42 +1047,15 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
goto handle_error;
}
- snprintf(filename, sizeof filename, "%s/%s_dri.so",
- dri_driver_path, driverName);
-
- screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ screen->driver = glxProbeDriver(driverName,
+ (void **)&screen->core,
+ __DRI_CORE, __DRI_CORE_VERSION,
+ (void **)&screen->legacy,
+ __DRI_LEGACY, __DRI_LEGACY_VERSION);
if (screen->driver == NULL) {
- LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
- filename, dlerror());
goto handle_error;
}
-
- extensions = dlsym(screen->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- LogMessage(X_ERROR, "AIGLX error: %s exports no extensions (%s)\n",
- driverName, dlerror());
- goto handle_error;
- }
- for (i = 0; extensions[i]; i++) {
- if (strcmp(extensions[i]->name, __DRI_CORE) == 0 &&
- extensions[i]->version >= __DRI_CORE_VERSION) {
- screen->core = (__DRIcoreExtension *) extensions[i];
- }
-
- if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0 &&
- extensions[i]->version >= __DRI_LEGACY_VERSION) {
- screen->legacy = (__DRIlegacyExtension *) extensions[i];
- }
- }
-
- if (screen->core == NULL || screen->legacy == NULL) {
- LogMessage(X_ERROR,
- "AIGLX error: %s does not export required DRI extension\n",
- driverName);
- goto handle_error;
- }
-
/*
* Get device-specific info. pDevPriv will point to a struct
* (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
@@ -1172,7 +1140,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
pScrn->LeaveVT = glxDRILeaveVT;
LogMessage(X_INFO,
- "AIGLX: Loaded and initialized %s\n", filename);
+ "AIGLX: Loaded and initialized %s\n", driverName);
return &screen->base;
diff --git a/xorg-server/glx/glxdri2.c b/xorg-server/glx/glxdri2.c
index c9c316be5..9d4aeab23 100644
--- a/xorg-server/glx/glxdri2.c
+++ b/xorg-server/glx/glxdri2.c
@@ -599,8 +599,6 @@ static const __DRIextension *loader_extensions[] = {
NULL
};
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
static Bool
glxDRIEnterVT (int index, int flags)
{
@@ -702,12 +700,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
{
const char *driverName, *deviceName;
__GLXDRIscreen *screen;
- char filename[128];
size_t buffer_size;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- const __DRIextension **extensions;
const __DRIconfig **driConfigs;
- int i;
screen = calloc(1, sizeof *screen);
if (screen == NULL)
@@ -729,40 +724,12 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
__glXInitExtensionEnableBits(screen->glx_enable_bits);
- snprintf(filename, sizeof filename,
- "%s/%s_dri.so", dri_driver_path, driverName);
-
- screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ screen->driver = glxProbeDriver(driverName, (void **)&screen->core, __DRI_CORE, 1,
+ (void **)&screen->dri2, __DRI_DRI2, 1);
if (screen->driver == NULL) {
- LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
- filename, dlerror());
goto handle_error;
}
-
- extensions = dlsym(screen->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- LogMessage(X_ERROR, "AIGLX error: %s exports no extensions (%s)\n",
- driverName, dlerror());
- goto handle_error;
- }
- for (i = 0; extensions[i]; i++) {
- if (strcmp(extensions[i]->name, __DRI_CORE) == 0 &&
- extensions[i]->version >= 1) {
- screen->core = (const __DRIcoreExtension *) extensions[i];
- }
- if (strcmp(extensions[i]->name, __DRI_DRI2) == 0 &&
- extensions[i]->version >= 1) {
- screen->dri2 = (const __DRIdri2Extension *) extensions[i];
- }
- }
-
- if (screen->core == NULL || screen->dri2 == NULL) {
- LogMessage(X_ERROR, "AIGLX error: %s exports no DRI extension\n",
- driverName);
- goto handle_error;
- }
-
screen->driScreen =
(*screen->dri2->createNewScreen)(pScreen->myNum,
screen->fd,
@@ -816,7 +783,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
pScrn->LeaveVT = glxDRILeaveVT;
LogMessage(X_INFO,
- "AIGLX: Loaded and initialized %s\n", filename);
+ "AIGLX: Loaded and initialized %s\n", driverName);
return &screen->base;
diff --git a/xorg-server/glx/glxdricommon.c b/xorg-server/glx/glxdricommon.c
index 44078fb41..2fcda8fb8 100644
--- a/xorg-server/glx/glxdricommon.c
+++ b/xorg-server/glx/glxdricommon.c
@@ -29,6 +29,7 @@
#include <stdint.h>
#include <errno.h>
+#include <dlfcn.h>
#include <sys/time.h>
#include <GL/gl.h>
#include <GL/glxtokens.h>
@@ -204,3 +205,59 @@ glxConvertConfigs(const __DRIcoreExtension *core,
return head.next;
}
+
+static const char dri_driver_path[] = DRI_DRIVER_PATH;
+
+void *
+glxProbeDriver(const char *driverName,
+ void **coreExt, const char *coreName, int coreVersion,
+ void **renderExt, const char *renderName, int renderVersion)
+{
+ int i;
+ void *driver;
+ char filename[PATH_MAX];
+ const __DRIextension **extensions;
+
+ snprintf(filename, sizeof filename, "%s/%s_dri.so",
+ dri_driver_path, driverName);
+
+ driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ if (driver == NULL) {
+ LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
+ filename, dlerror());
+ goto cleanup_failure;
+ }
+
+ extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
+ if (extensions == NULL) {
+ LogMessage(X_ERROR, "AIGLX error: %s exports no extensions (%s)\n",
+ driverName, dlerror());
+ goto cleanup_failure;
+ }
+
+ for (i = 0; extensions[i]; i++) {
+ if (strcmp(extensions[i]->name, coreName) == 0 &&
+ extensions[i]->version >= coreVersion) {
+ *coreExt = (void *)extensions[i];
+ }
+
+ if (strcmp(extensions[i]->name, renderName) == 0 &&
+ extensions[i]->version >= renderVersion) {
+ *renderExt = (void *)extensions[i];
+ }
+ }
+
+ if (*coreExt == NULL || *renderExt == NULL) {
+ LogMessage(X_ERROR,
+ "AIGLX error: %s does not export required DRI extension\n",
+ driverName);
+ goto cleanup_failure;
+ }
+ return driver;
+
+cleanup_failure:
+ if (driver)
+ dlclose(driver);
+ *coreExt = *renderExt = NULL;
+ return NULL;
+}
diff --git a/xorg-server/glx/glxdricommon.h b/xorg-server/glx/glxdricommon.h
index 41e2d2770..ef7b531f6 100644
--- a/xorg-server/glx/glxdricommon.h
+++ b/xorg-server/glx/glxdricommon.h
@@ -1,41 +1,46 @@
-/*
- * Copyright © 2008 Red Hat, Inc
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of the
- * copyright holders not be used in advertising or publicity
- * pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#ifndef _GLX_dri_common_h
-#define _GLX_dri_common_h
-
-typedef struct __GLXDRIconfig __GLXDRIconfig;
-struct __GLXDRIconfig {
- __GLXconfig config;
- const __DRIconfig *driConfig;
-};
-
-__GLXconfig *
-glxConvertConfigs(const __DRIcoreExtension *core,
- const __DRIconfig **configs, unsigned int drawableType);
-
-extern const __DRIsystemTimeExtension systemTimeExtension;
-
-#endif
+/*
+ * Copyright © 2008 Red Hat, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef _GLX_dri_common_h
+#define _GLX_dri_common_h
+
+typedef struct __GLXDRIconfig __GLXDRIconfig;
+struct __GLXDRIconfig {
+ __GLXconfig config;
+ const __DRIconfig *driConfig;
+};
+
+__GLXconfig *
+glxConvertConfigs(const __DRIcoreExtension *core,
+ const __DRIconfig **configs, unsigned int drawableType);
+
+extern const __DRIsystemTimeExtension systemTimeExtension;
+
+void *
+glxProbeDriver(const char *name,
+ void **coreExt, const char *coreName, int coreVersion,
+ void **renderExt, const char *renderName, int renderVersion);
+
+#endif
diff --git a/xorg-server/glx/glxdriswrast.c b/xorg-server/glx/glxdriswrast.c
index 30ce19ed1..fb2316a62 100644
--- a/xorg-server/glx/glxdriswrast.c
+++ b/xorg-server/glx/glxdriswrast.c
@@ -201,6 +201,14 @@ __glXDRIbindTexImage(__GLXcontext *baseContext,
if (texBuffer == NULL)
return Success;
+#if __DRI_TEX_BUFFER_VERSION >= 2
+ if (texBuffer->base.version >= 2 && texBuffer->setTexBuffer2 != NULL) {
+ (*texBuffer->setTexBuffer2)(context->driContext,
+ glxPixmap->target,
+ glxPixmap->format,
+ drawable->driDrawable);
+ } else
+#endif
texBuffer->setTexBuffer(context->driContext,
glxPixmap->target,
drawable->driDrawable);
@@ -427,17 +435,12 @@ initializeExtensions(__GLXDRIscreen *screen)
}
}
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
static __GLXscreen *
__glXDRIscreenProbe(ScreenPtr pScreen)
{
const char *driverName = "swrast";
__GLXDRIscreen *screen;
- char filename[128];
- const __DRIextension **extensions;
const __DRIconfig **driConfigs;
- int i;
screen = calloc(1, sizeof *screen);
if (screen == NULL)
@@ -449,40 +452,15 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
screen->base.swapInterval = NULL;
screen->base.pScreen = pScreen;
- snprintf(filename, sizeof filename,
- "%s/%s_dri.so", dri_driver_path, driverName);
-
- screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ screen->driver = glxProbeDriver(driverName,
+ (void **)&screen->core,
+ __DRI_CORE, __DRI_CORE_VERSION,
+ (void **)&screen->swrast,
+ __DRI_SWRAST, __DRI_SWRAST_VERSION);
if (screen->driver == NULL) {
- LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
- filename, dlerror());
goto handle_error;
}
- extensions = dlsym(screen->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- LogMessage(X_ERROR, "AIGLX error: %s exports no extensions (%s)\n",
- driverName, dlerror());
- goto handle_error;
- }
-
- for (i = 0; extensions[i]; i++) {
- if (strcmp(extensions[i]->name, __DRI_CORE) == 0 &&
- extensions[i]->version >= __DRI_CORE_VERSION) {
- screen->core = (const __DRIcoreExtension *) extensions[i];
- }
- if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0 &&
- extensions[i]->version >= __DRI_SWRAST_VERSION) {
- screen->swrast = (const __DRIswrastExtension *) extensions[i];
- }
- }
-
- if (screen->core == NULL || screen->swrast == NULL) {
- LogMessage(X_ERROR, "AIGLX error: %s exports no DRI extension\n",
- driverName);
- goto handle_error;
- }
-
screen->driScreen =
(*screen->swrast->createNewScreen)(pScreen->myNum,
loader_extensions,
@@ -508,7 +486,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
screen->base.GLXminor = 4;
LogMessage(X_INFO,
- "AIGLX: Loaded and initialized %s\n", filename);
+ "AIGLX: Loaded and initialized %s\n", driverName);
return &screen->base;