summaryrefslogtreecommitdiff
path: root/GL
diff options
context:
space:
mode:
Diffstat (limited to 'GL')
-rw-r--r--GL/glx/glxcmds.c11
-rw-r--r--GL/glx/glxcontext.h16
-rw-r--r--GL/glx/glxdri.c22
-rw-r--r--GL/glx/glxext.c18
-rw-r--r--GL/glx/glxglcore.c4
-rw-r--r--GL/glx/glxscreens.c70
6 files changed, 63 insertions, 78 deletions
diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c
index 992ddbce5..21f3206c3 100644
--- a/GL/glx/glxcmds.c
+++ b/GL/glx/glxcmds.c
@@ -190,7 +190,6 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
__GLXscreen *pGlxScreen, GLboolean isDirect)
{
ClientPtr client = cl->client;
- VisualPtr pVisual;
__GLXcontext *glxc, *shareglxc;
LEGAL_NEW_RESOURCE(gcId, client);
@@ -248,9 +247,7 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
** Initially, setup the part of the context that could be used by
** a GL core that needs windowing information (e.g., Mesa).
*/
- glxc->pScreen = pGlxScreen->pScreen;
glxc->pGlxScreen = pGlxScreen;
- glxc->pVisual = pVisual;
glxc->modes = config;
/*
@@ -499,7 +496,7 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
* a GLX drawable for it. Check that the drawable screen matches
* the context screen and that the context fbconfig is compatible
* with the window visual. */
- if (pDraw->pScreen != glxc->pScreen ||
+ if (pDraw->pScreen != glxc->pGlxScreen->pScreen ||
!validGlxFBConfigForWindow(client, glxc->modes, pDraw, error))
return NULL;
@@ -1255,7 +1252,7 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
__glXenterServer(GL_FALSE);
pPixmap = (*pGlxScreen->pScreen->CreatePixmap) (pGlxScreen->pScreen,
- width, height, config->rgbBits);
+ width, height, config->rgbBits, 0);
__glXleaveServer(GL_FALSE);
return DoCreateGLXDrawable(client, pGlxScreen, config, &pPixmap->drawable,
@@ -1470,9 +1467,9 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId)
*pSendBuf++ = GLX_SHARE_CONTEXT_EXT;
*pSendBuf++ = (int)(ctx->share_id);
*pSendBuf++ = GLX_VISUAL_ID_EXT;
- *pSendBuf++ = (int)(ctx->pVisual->vid);
+ *pSendBuf++ = (int)(ctx->modes->visualID);
*pSendBuf++ = GLX_SCREEN_EXT;
- *pSendBuf++ = (int)(ctx->pScreen->myNum);
+ *pSendBuf++ = (int)(ctx->pGlxScreen->pScreen->myNum);
if (client->swapped) {
__glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h
index 712264729..4c36801c1 100644
--- a/GL/glx/glxcontext.h
+++ b/GL/glx/glxcontext.h
@@ -85,15 +85,9 @@ struct __GLXcontext {
** Pointer to screen info data for this context. This is set
** when the context is created.
*/
- ScreenPtr pScreen;
__GLXscreen *pGlxScreen;
/*
- ** This context is created with respect to this visual.
- */
- VisualRec *pVisual;
-
- /*
** The XID of this context.
*/
XID id;
@@ -104,11 +98,6 @@ struct __GLXcontext {
XID share_id;
/*
- ** Visual id.
- */
- VisualID vid;
-
- /*
** screen number.
*/
GLint screen;
@@ -129,11 +118,6 @@ struct __GLXcontext {
GLboolean isDirect;
/*
- ** Window pending state
- */
- GLuint pendingState;
-
- /*
** This flag keeps track of whether there are unflushed GL commands.
*/
GLboolean hasUnflushedCommands;
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index 3688d50a8..c0da07b68 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -185,10 +185,14 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
(*private->driDrawable.destroyDrawable)(&private->driDrawable);
- __glXenterServer(GL_FALSE);
- DRIDestroyDrawable(drawable->pDraw->pScreen,
- serverClient, drawable->pDraw);
- __glXleaveServer(GL_FALSE);
+ /* If the X window was destroyed, the dri DestroyWindow hook will
+ * aready have taken care of this, so only call if pDraw isn't NULL. */
+ if (drawable->pDraw != NULL) {
+ __glXenterServer(GL_FALSE);
+ DRIDestroyDrawable(drawable->pDraw->pScreen,
+ serverClient, drawable->pDraw);
+ __glXleaveServer(GL_FALSE);
+ }
xfree(private);
}
@@ -249,7 +253,7 @@ __glXDRIcontextDestroy(__GLXcontext *baseContext)
context->driContext.destroyContext(&context->driContext);
__glXenterServer(GL_FALSE);
- retval = DRIDestroyContext(baseContext->pScreen, context->hwContextID);
+ retval = DRIDestroyContext(baseContext->pGlxScreen->pScreen, context->hwContextID);
__glXleaveServer(GL_FALSE);
__glXContextDestroy(&context->base);
@@ -583,7 +587,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
context->base.loseCurrent = __glXDRIcontextLoseCurrent;
context->base.copy = __glXDRIcontextCopy;
context->base.forceCurrent = __glXDRIcontextForceCurrent;
- context->base.pScreen = screen->base.pScreen;
context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
/* Find the requested X visual */
@@ -668,11 +671,16 @@ getDrawableInfo(__DRIdrawable *driDrawable,
{
__GLXDRIdrawable *drawable = containerOf(driDrawable,
__GLXDRIdrawable, driDrawable);
- ScreenPtr pScreen = drawable->base.pDraw->pScreen;
+ ScreenPtr pScreen;
drm_clip_rect_t *pClipRects, *pBackClipRects;
GLboolean retval;
size_t size;
+ /* If the X window has been destroyed, give up here. */
+ if (drawable->base.pDraw == NULL)
+ return GL_FALSE;
+
+ pScreen = drawable->base.pDraw->pScreen;
__glXenterServer(GL_FALSE);
retval = DRIGetDrawableInfo(pScreen, drawable->base.pDraw, index, stamp,
x, y, width, height,
diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index 60dc090ac..85d8debd4 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -107,22 +107,8 @@ static int ContextGone(__GLXcontext* cx, XID id)
*/
static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
{
- __GLXcontext *cx, *cx1;
-
- /*
- ** When a drawable is destroyed, notify all context bound to
- ** it, that there are no longer bound to anything.
- */
- for (cx = glxPriv->drawGlxc; cx; cx = cx1) {
- cx1 = cx->nextDrawPriv;
- cx->pendingState |= __GLX_PENDING_DESTROY;
- }
-
- for (cx = glxPriv->readGlxc; cx; cx = cx1) {
- cx1 = cx->nextReadPriv;
- cx->pendingState |= __GLX_PENDING_DESTROY;
- }
-
+ glxPriv->pDraw = NULL;
+ glxPriv->drawId = 0;
__glXUnrefDrawable(glxPriv);
return True;
diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
index 6aa4e7f5c..0750e1282 100644
--- a/GL/glx/glxglcore.c
+++ b/GL/glx/glxglcore.c
@@ -265,7 +265,7 @@ __glXMesaScreenDestroy(__GLXscreen *screen)
int i;
if (mesaScreen->xm_vis) {
- for (i = 0; i < mesaScreen->num_vis; i++) {
+ for (i = 0; i < mesaScreen->base.numFBConfigs; i++) {
if (mesaScreen->xm_vis[i])
XMesaDestroyVisual(mesaScreen->xm_vis[i]);
}
@@ -363,7 +363,7 @@ createMesaVisuals(__GLXMESAscreen *pMesaScreen)
{
__GLcontextModes *config;
ScreenPtr pScreen;
- VisualPtr visual;
+ VisualPtr visual = NULL;
int i, j;
i = 0;
diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c
index 2dc9d2f10..bf090662a 100644
--- a/GL/glx/glxscreens.c
+++ b/GL/glx/glxscreens.c
@@ -190,7 +190,6 @@ static char GLXServerExtensions[] =
static Bool glxPositionWindow(WindowPtr pWin, int x, int y)
{
ScreenPtr pScreen;
- __GLXcontext *glxc;
__GLXdrawable *glxPriv;
Bool ret;
__GLXscreen *pGlxScreen;
@@ -227,16 +226,6 @@ static Bool glxPositionWindow(WindowPtr pWin, int x, int y)
ret = False;
}
- /* mark contexts as needing resize */
-
- for (glxc = glxPriv->drawGlxc; glxc; glxc = glxc->nextDrawPriv) {
- glxc->pendingState |= __GLX_PENDING_RESIZE;
- }
-
- for (glxc = glxPriv->readGlxc; glxc; glxc = glxc->nextReadPriv) {
- glxc->pendingState |= __GLX_PENDING_RESIZE;
- }
-
return ret;
}
@@ -408,38 +397,61 @@ initGlxVisual(VisualPtr visual, __GLcontextModes *config)
visual->offsetBlue = findFirstSet(config->blueMask);
}
-static void
-addMinimalSet(__GLXscreen *pGlxScreen)
+typedef struct {
+ GLboolean doubleBuffer;
+ GLboolean depthBuffer;
+} FBConfigTemplateRec, *FBConfigTemplatePtr;
+
+static __GLcontextModes *
+pickFBConfig(__GLXscreen *pGlxScreen, FBConfigTemplatePtr template, int class)
{
__GLcontextModes *config;
- VisualPtr visuals;
- int depth;
for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
if (config->visualRating != GLX_NONE)
continue;
- if (config->doubleBufferMode && config->depthBits > 0)
- break;
+ if (_gl_convert_to_x_visual_type(config->visualType) != class)
+ continue;
+ if ((config->doubleBufferMode > 0) != template->doubleBuffer)
+ continue;
+ if ((config->depthBits > 0) != template->depthBuffer)
+ continue;
+
+ return config;
}
- if (config == NULL)
- config = pGlxScreen->fbconfigs;
- pGlxScreen->visuals = xcalloc(1, sizeof (__GLcontextModes *));
+ return NULL;
+}
+
+static void
+addMinimalSet(__GLXscreen *pGlxScreen)
+{
+ __GLcontextModes *config;
+ VisualPtr visuals;
+ int i;
+ FBConfigTemplateRec best = { GL_TRUE, GL_TRUE };
+ FBConfigTemplateRec minimal = { GL_FALSE, GL_FALSE };
+
+ pGlxScreen->visuals = xcalloc(pGlxScreen->pScreen->numVisuals,
+ sizeof (__GLcontextModes *));
if (pGlxScreen->visuals == NULL) {
ErrorF("Failed to allocate for minimal set of GLX visuals\n");
return;
}
- depth = config->redBits + config->greenBits + config->blueBits;
- visuals = AddScreenVisuals(pGlxScreen->pScreen, 1, depth);
- if (visuals == NULL) {
- xfree(pGlxScreen->visuals);
- return;
+ pGlxScreen->numVisuals = pGlxScreen->pScreen->numVisuals;
+ visuals = pGlxScreen->pScreen->visuals;
+ for (i = 0; i < pGlxScreen->numVisuals; i++) {
+ if (visuals[i].nplanes == 32)
+ config = pickFBConfig(pGlxScreen, &minimal, visuals[i].class);
+ else
+ config = pickFBConfig(pGlxScreen, &best, visuals[i].class);
+ if (config == NULL)
+ config = pGlxScreen->fbconfigs;
+ pGlxScreen->visuals[i] = config;
+ config->visualID = visuals[i].vid;
}
- pGlxScreen->numVisuals = 1;
- pGlxScreen->visuals[0] = config;
- initGlxVisual(&visuals[0], config);
}
static void
@@ -505,8 +517,6 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
for (m = pGlxScreen->fbconfigs; m != NULL; m = m->next) {
m->fbconfigID = FakeClientID(0);
m->visualID = findVisualForConfig(pScreen, m);
- ErrorF("mapping fbconfig id 0x%02lx to visual id 0x%02lx\n",
- m->fbconfigID, m->visualID);
i++;
}
pGlxScreen->numFBConfigs = i;