In __glXCreateARGBConfig(), insert the new GL mode at the _end_ of the linked list.

Previously, the new mode was added at the head of the list.  This caused the
positional correspondence between modes and the XMesaVisuals array to be off
by one.  The net result was GLX clients failing when they tried to use the
last GLX mode/visual.

We still have the problem of DRI drivers not being able to use the extra
mode/visual introduced by __glXCreateARGBConfig().  glXCreateContext fails
with BadAlloc if it's attempted.  This is also the source of the often-
seen warning "libGL warning: 3D driver claims to not support visual xxx"
Look into fixing that someday...
This commit is contained in:
Brian 2007-05-02 15:55:40 -06:00
parent bd0abb2844
commit c1e1d6b98a

View File

@ -1019,6 +1019,7 @@ __glXCreateARGBConfig(__GLXscreen *screen)
VisualPtr visual;
int i;
/* search for a 32-bit visual */
visual = NULL;
for (i = 0; i < screen->pScreen->numVisuals; i++)
if (screen->pScreen->visuals[i].nplanes == 32) {
@ -1037,8 +1038,22 @@ __glXCreateARGBConfig(__GLXscreen *screen)
if (modes == NULL)
return;
modes->next = screen->modes;
screen->modes = modes;
/* Insert this new mode at the TAIL of the linked list.
* Previously, the mode was incorrectly inserted at the head of the
* list, causing find_mesa_visual() to be off by one. This would
* GLX clients to blow up if they attempted to use the last mode
* in the list!
*/
{
__GLcontextModes *prev = NULL, *m;
for (m = screen->modes; m; m = m->next)
prev = m;
if (prev)
prev->next = modes;
else
screen->modes = modes;
}
screen->numUsableVisuals++;
screen->numVisuals++;
@ -1104,6 +1119,9 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
}
pGlxScreen = __glXActiveScreens[screen];
/* Create the "extra" 32bpp ARGB visual, if not already added.
* XXX This is questionable place to do so! Re-examine this someday.
*/
__glXCreateARGBConfig(pGlxScreen);
reply.numFBConfigs = pGlxScreen->numUsableVisuals;