summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Brenneman <kbrenneman@nvidia.com>2016-03-14 15:21:41 -0600
committerKyle Brenneman <kbrenneman@nvidia.com>2016-03-24 12:46:41 -0600
commit547daaf228c918026825f0b58a56638afaf54d0e (patch)
tree37ee9596eb1d7133b57c6e7ef91b4fee286ccf79
parent4c7a1b18e68655178bf88da9a17395f86bae3006 (diff)
GLX: Use GLX_EXT_libglvnd instead of x11glvnd.
Reworked libGLX.so to use the GLX_EXT_libglvnd extension instead of x11glvnd. In __glXLookupVendorByScreen, use __glXQueryServerString to look up the vendor name string, and then split it up with strtok_r.
-rw-r--r--src/GLX/Makefile.am3
-rw-r--r--src/GLX/libglx.c1
-rw-r--r--src/GLX/libglxmapping.c65
-rw-r--r--src/GLX/libglxmapping.h4
4 files changed, 46 insertions, 27 deletions
diff --git a/src/GLX/Makefile.am b/src/GLX/Makefile.am
index 156b3b5..1e865b2 100644
--- a/src/GLX/Makefile.am
+++ b/src/GLX/Makefile.am
@@ -41,7 +41,6 @@ UTIL_DIR = ../util
TRACE_DIR = ../util/trace
UTHASH_DIR = ../util/uthash/src
GL_DISPATCH_DIR = ../GLdispatch
-X11GLVND_DIR = ../x11glvnd
# Warning settings
# Include paths
@@ -50,7 +49,6 @@ libGLX_la_CFLAGS += -I$(srcdir)/$(UTIL_DIR)
libGLX_la_CFLAGS += -I$(srcdir)/$(TRACE_DIR)
libGLX_la_CFLAGS += -I$(srcdir)/$(GL_DISPATCH_DIR)
libGLX_la_CFLAGS += -I$(top_srcdir)/include
-libGLX_la_CFLAGS += -I$(srcdir)/$(X11GLVND_DIR)
libGLX_la_CFLAGS += $(GLPROTO_CFLAGS)
# Required library flags
@@ -61,7 +59,6 @@ libGLX_la_LIBADD = -ldl
libGLX_la_LIBADD += $(X11_LIBS)
libGLX_la_LIBADD += $(XEXT_LIBS)
libGLX_la_LIBADD += $(GL_DISPATCH_DIR)/libGLdispatch.la
-libGLX_la_LIBADD += $(X11GLVND_DIR)/libx11glvnd_client.la
libGLX_la_LIBADD += $(TRACE_DIR)/libtrace.la
libGLX_la_LDFLAGS = -shared -Wl,-Bsymbolic -version-info 0 $(LINKER_FLAG_NO_UNDEFINED)
diff --git a/src/GLX/libglx.c b/src/GLX/libglx.c
index d87e052..a3d43a2 100644
--- a/src/GLX/libglx.c
+++ b/src/GLX/libglx.c
@@ -43,7 +43,6 @@
#include "utils_misc.h"
#include "trace.h"
#include "GL/glxproto.h"
-#include "x11glvnd.h"
#include "libglxgl.h"
#include "glvnd_list.h"
diff --git a/src/GLX/libglxmapping.c b/src/GLX/libglxmapping.c
index b3242af..6be351d 100644
--- a/src/GLX/libglxmapping.c
+++ b/src/GLX/libglxmapping.c
@@ -42,12 +42,12 @@
#include "libglxnoop.h"
#include "libglxthread.h"
#include "libglxstring.h"
+#include "libglxproto.h"
#include "utils_misc.h"
#include "glvnd_genentry.h"
#include "trace.h"
#include "lkdhash.h"
-#include "x11glvnd.h"
#define _GNU_SOURCE 1
@@ -595,16 +595,26 @@ __GLXvendorInfo *__glXLookupVendorByScreen(Display *dpy, const int screen)
}
if (!vendor) {
- if (dpyInfo->x11glvndSupported) {
- char *queriedVendorName = XGLVQueryScreenVendorMapping(dpy, screen);
- vendor = __glXLookupVendorByName(queriedVendorName);
- Xfree(queriedVendorName);
-
- // Make sure that the vendor library can support this screen.
- // If it can't, then we'll fall back to the indirect rendering
- // library.
- if (vendor != NULL && !vendor->glxvc->checkSupportsScreen(dpy, screen)) {
- vendor = NULL;
+ if (dpyInfo->libglvndExtensionSupported) {
+ char *queriedVendorNames =
+ __glXQueryServerString(dpyInfo, screen, GLX_VENDOR_NAMES_EXT);
+ if (queriedVendorNames != NULL) {
+ char *name, *saveptr;
+ for (name = strtok_r(queriedVendorNames, " ", &saveptr);
+ name != NULL;
+ name = strtok_r(NULL, " ", &saveptr)) {
+ vendor = __glXLookupVendorByName(name);
+
+ // Make sure that the vendor library can support this screen.
+ if (vendor != NULL && !vendor->glxvc->checkSupportsScreen(dpy, screen)) {
+ vendor = NULL;
+ }
+
+ if (vendor != NULL) {
+ break;
+ }
+ }
+ free(queriedVendorNames);
}
}
}
@@ -666,7 +676,7 @@ static __GLXdisplayInfoHash *InitDisplayInfoEntry(Display *dpy)
{
__GLXdisplayInfoHash *pEntry;
size_t size;
- int eventBase, errorBase;
+ int eventBase;
size = sizeof(*pEntry) + ScreenCount(dpy) * sizeof(__GLXvendorInfo *);
pEntry = (__GLXdisplayInfoHash *) malloc(size);
@@ -687,11 +697,26 @@ static __GLXdisplayInfoHash *InitDisplayInfoEntry(Display *dpy)
&pEntry->info.glxMajorOpcode, &eventBase,
&pEntry->info.glxFirstError);
- // Check whether the server supports the x11glvnd extension.
- if (XGLVQueryExtension(dpy, &eventBase, &errorBase)) {
- pEntry->info.x11glvndSupported = True;
- XGLVQueryVersion(dpy, &pEntry->info.x11glvndMajor,
- &pEntry->info.x11glvndMinor);
+ if (pEntry->info.glxSupported) {
+ int screen;
+
+ // Check to see if the server supports the GLX_EXT_libglvnd extension.
+ // Note that it has to be supported on every screen to use it.
+ pEntry->info.libglvndExtensionSupported = True;
+ for (screen = 0;
+ screen < ScreenCount(dpy) && pEntry->info.libglvndExtensionSupported;
+ screen++) {
+ char *extensions = __glXQueryServerString(&pEntry->info, screen, GLX_EXTENSIONS);
+ if (extensions != NULL) {
+ if (!IsExtensionInString(extensions, GLX_EXT_LIBGLVND_NAME,
+ strlen(GLX_EXT_LIBGLVND_NAME))) {
+ pEntry->info.libglvndExtensionSupported = False;
+ }
+ free(extensions);
+ } else {
+ pEntry->info.libglvndExtensionSupported = False;
+ }
+ }
}
return pEntry;
@@ -973,8 +998,8 @@ static void VendorFromXID(Display *dpy, __GLXdisplayInfo *dpyInfo, XID xid,
} else {
LKDHASH_UNLOCK(dpyInfo->xidVendorHash);
- if (dpyInfo->x11glvndSupported) {
- int screen = XGLVQueryXIDScreenMapping(dpy, xid);
+ if (dpyInfo->libglvndExtensionSupported) {
+ int screen = __glXGetDrawableScreen(dpyInfo, xid);
if (screen >= 0 && screen < ScreenCount(dpy)) {
vendor = __glXLookupVendorByScreen(dpy, screen);
if (vendor != NULL) {
@@ -1015,7 +1040,7 @@ int __glXVendorFromDrawable(Display *dpy, GLXDrawable drawable, __GLXvendorInfo
__GLXdisplayInfo *dpyInfo = __glXLookupDisplay(dpy);
__GLXvendorInfo *vendor = NULL;
if (dpyInfo != NULL) {
- if (dpyInfo->x11glvndSupported) {
+ if (dpyInfo->libglvndExtensionSupported) {
VendorFromXID(dpy, dpyInfo, drawable, &vendor);
} else {
// We'll use the same vendor for every screen in this case.
diff --git a/src/GLX/libglxmapping.h b/src/GLX/libglxmapping.h
index 00b5575..ebef813 100644
--- a/src/GLX/libglxmapping.h
+++ b/src/GLX/libglxmapping.h
@@ -80,9 +80,7 @@ typedef struct __GLXdisplayInfoRec {
int glxMajorOpcode;
int glxFirstError;
- Bool x11glvndSupported;
- int x11glvndMajor;
- int x11glvndMinor;
+ Bool libglvndExtensionSupported;
} __GLXdisplayInfo;
/*!