summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glx/x11/glxclient.h4
-rw-r--r--src/glx/x11/glxcmds.c7
-rw-r--r--src/glx/x11/glxext.c267
3 files changed, 133 insertions, 145 deletions
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index 0709f3ef26..b464e505fc 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -500,9 +500,9 @@ struct __GLXscreenConfigsRec {
#endif
/**
- * Linked list of configurations for this screen.
+ * Linked list of glx visuals and fbconfigs for this screen.
*/
- __GLcontextModes *configs;
+ __GLcontextModes *visuals, *configs;
/**
* Per-screen dynamic GLX extension tracking. The \c direct_support
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index 3e53dca319..707e398d1d 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -903,12 +903,12 @@ PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute,
{
__GLXdisplayPrivate *priv;
__GLXscreenConfigs *psc;
+ __GLcontextModes *modes;
int status;
status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc );
if ( status == Success ) {
- const __GLcontextModes * const modes = _gl_context_modes_find_visual(
- psc->configs, vis->visualid );
+ modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
/* Lookup attribute after first finding a match on the visual */
if ( modes != NULL ) {
@@ -1286,7 +1286,7 @@ PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)
** Compute a score for those that do
** Remember which visual, if any, got the highest score
*/
- for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) {
+ for ( modes = psc->visuals ; modes != NULL ; modes = modes->next ) {
if ( fbconfigs_compatible( & test_config, modes )
&& ((best_config == NULL)
|| (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) {
@@ -1654,6 +1654,7 @@ PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
__GLcontextModes ** config = NULL;
int i;
+ *nelements = 0;
if ( (priv->screenConfigs != NULL)
&& (screen >= 0) && (screen <= ScreenCount(dpy))
&& (priv->screenConfigs[screen].configs != NULL)
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index 7b25ad717a..2a1fcf2b84 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -362,7 +362,8 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
if (psc->driScreen.private)
(*psc->driScreen.destroyScreen)(&psc->driScreen);
psc->driScreen.private = NULL;
- __glxHashDestroy(psc->drawHash);
+ if (psc->drawHash)
+ __glxHashDestroy(psc->drawHash);
#endif
}
XFree((char*) priv->screenConfigs);
@@ -999,6 +1000,126 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
#endif /* GLX_DIRECT_RENDERING */
+static __GLcontextModes *
+createConfigsFromProperties(Display *dpy, int nvisuals, int nprops,
+ int screen, GLboolean tagged_only)
+{
+ INT32 buf[__GLX_TOTAL_CONFIG], *props;
+ unsigned prop_size;
+ __GLcontextModes *modes, *m;
+ int i;
+
+ if (nprops == 0)
+ return NULL;
+
+ /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
+
+ /* Check number of properties */
+ if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
+ return NULL;
+
+ /* Allocate memory for our config structure */
+ modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
+ if (!modes)
+ return NULL;
+
+ prop_size = nprops * __GLX_SIZE_INT32;
+ if (prop_size <= sizeof(buf))
+ props = buf;
+ else
+ props = Xmalloc(prop_size);
+
+ /* Read each config structure and convert it into our format */
+ m = modes;
+ for (i = 0; i < nvisuals; i++) {
+ _XRead(dpy, (char *)props, prop_size);
+ __glXInitializeVisualConfigFromTags(m, nprops, props,
+ tagged_only, GL_TRUE);
+ m->screen = screen;
+ m = m->next;
+ }
+
+ if (props != buf)
+ Xfree(props);
+
+ return modes;
+}
+
+static GLboolean
+getVisualConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
+{
+ xGLXGetVisualConfigsReq *req;
+ __GLXscreenConfigs *psc;
+ xGLXGetVisualConfigsReply reply;
+
+ LockDisplay(dpy);
+
+ psc = priv->screenConfigs + screen;
+ psc->visuals = NULL;
+ GetReq(GLXGetVisualConfigs, req);
+ req->reqType = priv->majorOpcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = screen;
+
+ if (!_XReply(dpy, (xReply*) &reply, 0, False))
+ goto out;
+
+ psc->visuals = createConfigsFromProperties(dpy,
+ reply.numVisuals,
+ reply.numProps,
+ screen, GL_FALSE);
+
+ out:
+ UnlockDisplay(dpy);
+ return psc->visuals != NULL;
+}
+
+static GLboolean
+getFBConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
+{
+ xGLXGetFBConfigsReq *fb_req;
+ xGLXGetFBConfigsSGIXReq *sgi_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXGetFBConfigsReply reply;
+ __GLXscreenConfigs *psc;
+
+ psc = priv->screenConfigs + screen;
+ psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ screen, GLX_EXTENSIONS);
+
+ LockDisplay(dpy);
+
+ psc->configs = NULL;
+ if (atof(priv->serverGLXversion) >= 1.3) {
+ GetReq(GLXGetFBConfigs, fb_req);
+ fb_req->reqType = priv->majorOpcode;
+ fb_req->glxCode = X_GLXGetFBConfigs;
+ fb_req->screen = screen;
+ } else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXGetFBConfigsSGIXReq +
+ sz_xGLXVendorPrivateWithReplyReq, vpreq);
+ sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+ sgi_req->reqType = priv->majorOpcode;
+ sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+ sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+ sgi_req->screen = screen;
+ } else
+ goto out;
+
+ if (!_XReply(dpy, (xReply*) &reply, 0, False))
+ goto out;
+
+ psc->configs = createConfigsFromProperties(dpy,
+ reply.numFBConfigs,
+ reply.numAttribs * 2,
+ screen, GL_TRUE);
+
+ out:
+ UnlockDisplay(dpy);
+ return psc->configs != NULL;
+}
/*
** Allocate the memory for the per screen configs for each screen.
@@ -1006,17 +1127,8 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
*/
static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
{
- xGLXGetVisualConfigsReq *req;
- xGLXGetFBConfigsReq *fb_req;
- xGLXVendorPrivateWithReplyReq *vpreq;
- xGLXGetFBConfigsSGIXReq *sgi_req;
- xGLXGetVisualConfigsReply reply;
__GLXscreenConfigs *psc;
- __GLcontextModes *config;
- GLint i, j, nprops, screens;
- INT32 buf[__GLX_TOTAL_CONFIG], *props;
- unsigned supported_request = 0;
- unsigned prop_size;
+ GLint i, screens;
/*
** First allocate memory for the array of per screen configs.
@@ -1030,141 +1142,16 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
priv->screenConfigs = psc;
priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- 0, GLX_VERSION);
+ X_GLXQueryServerString,
+ 0, GLX_VERSION);
if ( priv->serverGLXversion == NULL ) {
FreeScreenConfigs(priv);
return GL_FALSE;
}
- if ( atof( priv->serverGLXversion ) >= 1.3 ) {
- supported_request = 1;
- }
-
- /*
- ** Now fetch each screens configs structures. If a screen supports
- ** GL (by returning a numVisuals > 0) then allocate memory for our
- ** config structure and then fill it in.
- */
for (i = 0; i < screens; i++, psc++) {
- if ( supported_request != 1 ) {
- psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- i, GLX_EXTENSIONS);
- if ( strstr( psc->serverGLXexts, "GLX_SGIX_fbconfig" ) != NULL ) {
- supported_request = 2;
- }
- else {
- supported_request = 3;
- }
- }
-
-
- LockDisplay(dpy);
- switch( supported_request ) {
- case 1:
- GetReq(GLXGetFBConfigs,fb_req);
- fb_req->reqType = priv->majorOpcode;
- fb_req->glxCode = X_GLXGetFBConfigs;
- fb_req->screen = i;
- break;
-
- case 2:
- GetReqExtra(GLXVendorPrivateWithReply,
- sz_xGLXGetFBConfigsSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
- sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
- sgi_req->reqType = priv->majorOpcode;
- sgi_req->glxCode = X_GLXVendorPrivateWithReply;
- sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
- sgi_req->screen = i;
- break;
-
- case 3:
- GetReq(GLXGetVisualConfigs,req);
- req->reqType = priv->majorOpcode;
- req->glxCode = X_GLXGetVisualConfigs;
- req->screen = i;
- break;
- }
-
- if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
- /* Something is busted. Punt. */
- UnlockDisplay(dpy);
- SyncHandle();
- FreeScreenConfigs(priv);
- return GL_FALSE;
- }
-
- if (!reply.numVisuals) {
- /* This screen does not support GL rendering */
- UnlockDisplay(dpy);
- continue;
- }
-
- /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for
- * FIXME: FBconfigs?
- */
- /* Check number of properties */
- nprops = reply.numProps;
- if ((nprops < __GLX_MIN_CONFIG_PROPS) ||
- (nprops > __GLX_MAX_CONFIG_PROPS)) {
- /* Huh? Not in protocol defined limits. Punt */
- UnlockDisplay(dpy);
- SyncHandle();
- FreeScreenConfigs(priv);
- return GL_FALSE;
- }
-
- /* Allocate memory for our config structure */
- psc->configs = _gl_context_modes_create(reply.numVisuals,
- sizeof(__GLcontextModes));
- if (!psc->configs) {
- UnlockDisplay(dpy);
- SyncHandle();
- FreeScreenConfigs(priv);
- return GL_FALSE;
- }
-
- /* Allocate memory for the properties, if needed */
- if ( supported_request != 3 ) {
- nprops *= 2;
- }
-
- prop_size = nprops * __GLX_SIZE_INT32;
-
- if (prop_size <= sizeof(buf)) {
- props = buf;
- } else {
- props = (INT32 *) Xmalloc(prop_size);
- }
-
- /* Read each config structure and convert it into our format */
- config = psc->configs;
- for (j = 0; j < reply.numVisuals; j++) {
- assert( config != NULL );
- _XRead(dpy, (char *)props, prop_size);
-
- if ( supported_request != 3 ) {
- config->rgbMode = GL_TRUE;
- config->drawableType = GLX_WINDOW_BIT;
- }
- else {
- config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
- }
-
- __glXInitializeVisualConfigFromTags( config, nprops, props,
- (supported_request != 3),
- GL_TRUE );
- if ( config->fbconfigID == GLX_DONT_CARE ) {
- config->fbconfigID = config->visualID;
- }
- config->screen = i;
- config = config->next;
- }
- if (props != buf) {
- Xfree((char *)props);
- }
- UnlockDisplay(dpy);
+ getVisualConfigs(dpy, priv, i);
+ getFBConfigs(dpy, priv, i);
#ifdef GLX_DIRECT_RENDERING
psc->scr = i;