summaryrefslogtreecommitdiff
path: root/src/glx
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@tungstengraphics.com>2008-11-28 16:19:10 +0000
committerAlan Hourihane <alanh@tungstengraphics.com>2008-11-28 16:19:10 +0000
commitc4c86bbd16688ee4a0afb32efa27ba52abceb1ca (patch)
tree6b16fae74e49122a86ecf18b4a427b80d5a8e812 /src/glx
parent5b714723895d321db753f896576de5e2c27778c3 (diff)
parentc303e7299b5f95d4728c3710c56f50b1fefca09d (diff)
Merge commit 'origin/master' into gallium-0.2
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/x11/glx_query.c90
-rw-r--r--src/glx/x11/glxclient.h6
-rw-r--r--src/glx/x11/glxcmds.c55
-rw-r--r--src/glx/x11/glxext.c31
-rw-r--r--src/glx/x11/single2.c4
5 files changed, 163 insertions, 23 deletions
diff --git a/src/glx/x11/glx_query.c b/src/glx/x11/glx_query.c
index 56f3495186..2789b841b1 100644
--- a/src/glx/x11/glx_query.c
+++ b/src/glx/x11/glx_query.c
@@ -31,6 +31,70 @@
#include "glxclient.h"
+#if defined(USE_XCB)
+# include <X11/Xlib-xcb.h>
+# include <xcb/xcb.h>
+# include <xcb/glx.h>
+#endif
+
+#ifdef USE_XCB
+
+/**
+ * Exchange a protocol request for glXQueryServerString.
+ */
+char *
+__glXQueryServerString(Display* dpy,
+ int opcode,
+ CARD32 screen,
+ CARD32 name)
+{
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_glx_query_server_string_reply_t* reply =
+ xcb_glx_query_server_string_reply(c,
+ xcb_glx_query_server_string(c,
+ screen,
+ name),
+ NULL);
+
+ /* The spec doesn't mention this, but the Xorg server replies with
+ * a string already terminated with '\0'. */
+ uint32_t len = xcb_glx_query_server_string_string_length(reply);
+ char* buf = Xmalloc(len);
+ memcpy(buf, xcb_glx_query_server_string_string(reply), len);
+ free(reply);
+
+ return buf;
+}
+
+/**
+ * Exchange a protocol request for glGetString.
+ */
+char *
+__glXGetString(Display* dpy,
+ int opcode,
+ CARD32 contextTag,
+ CARD32 name)
+{
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_glx_get_string_reply_t* reply =
+ xcb_glx_get_string_reply(c,
+ xcb_glx_get_string(c,
+ contextTag,
+ name),
+ NULL);
+
+ /* The spec doesn't mention this, but the Xorg server replies with
+ * a string already terminated with '\0'. */
+ uint32_t len = xcb_glx_get_string_string_length(reply);
+ char* buf = Xmalloc(len);
+ memcpy(buf, xcb_glx_get_string_string(reply), len);
+ free(reply);
+
+ return buf;
+}
+
+#else
+
/**
* GLX protocol structure for the ficticious "GXLGenericGetString" request.
*
@@ -57,7 +121,7 @@ typedef struct GLXGenericGetString
* Query the Server GLX string.
* This routine will allocate the necessay space for the string.
*/
-char *
+static char *
__glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
CARD32 for_whom, CARD32 name)
{
@@ -101,3 +165,27 @@ __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
return buf;
}
+
+char *
+__glXQueryServerString(Display* dpy,
+ int opcode,
+ CARD32 screen,
+ CARD32 name)
+{
+ return __glXGetStringFromServer(dpy, opcode,
+ X_GLXQueryServerString,
+ screen, name);
+}
+
+char *
+__glXGetString(Display* dpy,
+ int opcode,
+ CARD32 contextTag,
+ CARD32 name)
+{
+ return __glXGetStringFromServer(dpy, opcode, X_GLsop_GetString,
+ contextTag, name);
+}
+
+#endif /* USE_XCB */
+
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index 3b9076bdd7..467b0ebb7f 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -741,8 +741,10 @@ extern void _XSend(Display*, const void*, long);
extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
-extern char * __glXGetStringFromServer( Display * dpy, int opcode,
- CARD32 glxCode, CARD32 for_whom, CARD32 name );
+extern char * __glXQueryServerString(Display* dpy, int opcode,
+ CARD32 screen, CARD32 name);
+extern char * __glXGetString(Display* dpy, int opcode,
+ CARD32 screen, CARD32 name);
extern char *__glXstrdup(const char *str);
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index 391e0be05e..1d373ed29d 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -44,6 +44,12 @@
#include "xf86dri.h"
#endif
+#if defined(USE_XCB)
+#include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
+#include <xcb/glx.h>
+#endif
+
static const char __glXGLXClientVendorName[] = "SGI";
static const char __glXGLXClientVersion[] = "1.4";
@@ -749,8 +755,10 @@ PUBLIC void glXCopyContext(Display *dpy, GLXContext source,
*/
static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
{
+#if !defined(USE_XCB)
xGLXIsDirectReq *req;
xGLXIsDirectReply reply;
+#endif
CARD8 opcode;
opcode = __glXSetupForCommand(dpy);
@@ -758,6 +766,18 @@ static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
return GL_FALSE;
}
+#ifdef USE_XCB
+ xcb_connection_t* c = XGetXCBConnection(dpy);
+ xcb_glx_is_direct_reply_t* reply =
+ xcb_glx_is_direct_reply(c,
+ xcb_glx_is_direct(c, contextID),
+ NULL);
+
+ const Bool is_direct = reply->is_direct ? True : False;
+ free(reply);
+
+ return is_direct;
+#else
/* Send the glXIsDirect request */
LockDisplay(dpy);
GetReq(GLXIsDirect,req);
@@ -769,6 +789,7 @@ static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
SyncHandle();
return reply.isDirect;
+#endif /* USE_XCB */
}
/**
@@ -840,7 +861,6 @@ PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap)
PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
{
- xGLXSwapBuffersReq *req;
GLXContext gc;
GLXContextTag tag;
CARD8 opcode;
@@ -871,6 +891,13 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
tag = 0;
}
+#ifdef USE_XCB
+ xcb_connection_t* c = XGetXCBConnection(dpy);
+ xcb_glx_swap_buffers(c, tag, drawable);
+ xcb_flush(c);
+#else
+ xGLXSwapBuffersReq *req;
+
/* Send the glXSwapBuffers request */
LockDisplay(dpy);
GetReq(GLXSwapBuffers,req);
@@ -881,6 +908,7 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
UnlockDisplay(dpy);
SyncHandle();
XFlush(dpy);
+#endif /* USE_XCB */
}
@@ -1314,9 +1342,8 @@ PUBLIC const char *glXQueryExtensionsString( Display *dpy, int screen )
if (!psc->effectiveGLXexts) {
if (!psc->serverGLXexts) {
- psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- screen, GLX_EXTENSIONS);
+ psc->serverGLXexts =
+ __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
}
__glXCalculateUsableExtensions(psc,
@@ -1371,8 +1398,7 @@ PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name )
}
if ( *str == NULL ) {
- *str = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString, screen, name);
+ *str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name);
}
return *str;
@@ -1380,9 +1406,18 @@ PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name )
void __glXClientInfo ( Display *dpy, int opcode )
{
- xGLXClientInfoReq *req;
- int size;
char * ext_str = __glXGetClientGLExtensionString();
+ int size = strlen( ext_str ) + 1;
+
+#ifdef USE_XCB
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_glx_client_info(c,
+ GLX_MAJOR_VERSION,
+ GLX_MINOR_VERSION,
+ size,
+ (const uint8_t *)ext_str);
+#else
+ xGLXClientInfoReq *req;
/* Send the glXClientInfo request */
LockDisplay(dpy);
@@ -1392,14 +1427,14 @@ void __glXClientInfo ( Display *dpy, int opcode )
req->major = GLX_MAJOR_VERSION;
req->minor = GLX_MINOR_VERSION;
- size = strlen( ext_str ) + 1;
req->length += (size + 3) >> 2;
req->numbytes = size;
Data(dpy, ext_str, size);
UnlockDisplay(dpy);
SyncHandle();
-
+#endif /* USE_XCB */
+
Xfree( ext_str );
}
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index b6bdbd52bb..be6edf9b19 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -139,7 +139,8 @@ XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
** Free the per screen configs data as well as the array of
** __glXScreenConfigs.
*/
- static void FreeScreenConfigs(__GLXdisplayPrivate * priv)
+static void
+FreeScreenConfigs(__GLXdisplayPrivate * priv)
{
__GLXscreenConfigs *psc;
GLint i, screens;
@@ -221,6 +222,25 @@ __glXFreeDisplayPrivate(XExtData * extension)
static Bool
QueryVersion(Display * dpy, int opcode, int *major, int *minor)
{
+#ifdef USE_XCB
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_glx_query_version_reply_t* reply =
+ xcb_glx_query_version_reply(c,
+ xcb_glx_query_version(c,
+ GLX_MAJOR_VERSION,
+ GLX_MINOR_VERSION),
+ NULL);
+
+ if(reply->major_version != GLX_MAJOR_VERSION)
+ {
+ free(reply);
+ return GL_FALSE;
+ }
+ *major = reply->major_version;
+ *minor = min(reply->minor_version, GLX_MINOR_VERSION);
+ free(reply);
+ return GL_TRUE;
+#else
xGLXQueryVersionReq *req;
xGLXQueryVersionReply reply;
@@ -245,6 +265,7 @@ QueryVersion(Display * dpy, int opcode, int *major, int *minor)
*major = reply.majorVersion;
*minor = min(reply.minorVersion, GLX_MINOR_VERSION);
return GL_TRUE;
+#endif /* USE_XCB */
}
@@ -529,9 +550,7 @@ getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
__GLXscreenConfigs *psc;
psc = priv->screenConfigs + screen;
- psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- screen, GLX_EXTENSIONS);
+ psc->serverGLXexts = __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
LockDisplay(dpy);
@@ -589,9 +608,7 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
priv->screenConfigs = psc;
- priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- 0, GLX_VERSION);
+ priv->serverGLXversion = __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
if (priv->serverGLXversion == NULL) {
FreeScreenConfigs(priv);
return GL_FALSE;
diff --git a/src/glx/x11/single2.c b/src/glx/x11/single2.c
index 83a2505222..0b2d5113cc 100644
--- a/src/glx/x11/single2.c
+++ b/src/glx/x11/single2.c
@@ -679,9 +679,7 @@ __indirect_glGetString(GLenum name)
*/
(void) __glXFlushRenderBuffer(gc, gc->pc);
- s = (GLubyte *) __glXGetStringFromServer(dpy, gc->majorOpcode,
- X_GLsop_GetString,
- gc->currentContextTag, name);
+ s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag, name);
if (!s) {
/* Throw data on the floor */
__glXSetError(gc, GL_OUT_OF_MEMORY);