xserver: Branch 'xorg-server-1.5-apple' - 6 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Sun Jul 26 13:17:21 PDT 2009


 glx/glxcmds.c                  |    5 
 glx/glxdrawable.h              |    1 
 glx/glxdri.c                   |   10 +
 glx/glxdri2.c                  |   16 ++
 glx/glxscreens.c               |  235 ++++++++++++++---------------------------
 glx/glxserver.h                |    2 
 hw/xfree86/dixmods/glxmodule.c |   15 --
 7 files changed, 110 insertions(+), 174 deletions(-)

New commits:
commit c83e842d621806af883a48af93c8fced52f3590d
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jun 29 23:18:55 2009 -0700

    Build against DRI_TEX_BUFFER_VERSION 1
    
    setTexBuffer2 isn't present in this version of the structure, so don't try
    to call it.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit a7a93c12f91e0de72868f17a555215f1795d9e2f)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 7b81483..a522800 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -221,12 +221,15 @@ __glXDRIbindTexImage(__GLXcontext *baseContext,
     if (texBuffer == NULL)
         return Success;
 
+#if __DRI_TEX_BUFFER_VERSION >= 2
     if (texBuffer->base.version >= 2 && texBuffer->setTexBuffer2 != NULL) {
 	(*texBuffer->setTexBuffer2)(context->driContext,
 				    glxPixmap->target,
 				    glxPixmap->format,
 				    drawable->driDrawable);
-    } else {
+    } else
+#endif
+    {
 	texBuffer->setTexBuffer(context->driContext,
 				glxPixmap->target,
 				drawable->driDrawable);
commit e34a12b18f1d5f02268c492d95ed9c9fba57832e
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Wed Apr 1 17:42:33 2009 -0400

    Support setTexBuffer2 in AIGLX.
    
    Fixes broken GLX_tfp, specifically, lets compositors ignore un-defined
    alpha channel for pixmaps.
    (cherry picked from commit 91b697efdefba125348dbcaf584ee51a7f8c9bf6)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index d765b49..a0114c1 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -1133,6 +1133,7 @@ static void
 determineTextureTarget(XID glxDrawableID, CARD32 *attribs, CARD32 numAttribs)
 {
     GLenum target = 0;
+    GLenum format = 0;
     int i;
     __GLXdrawable *pGlxDraw;
 
@@ -1149,6 +1150,9 @@ determineTextureTarget(XID glxDrawableID, CARD32 *attribs, CARD32 numAttribs)
 		break;
 	    }
 	}
+
+	if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT)
+		format = attribs[2 * i + 1];
     }
  
     if (!target) {
@@ -1161,6 +1165,7 @@ determineTextureTarget(XID glxDrawableID, CARD32 *attribs, CARD32 numAttribs)
     }
 
     pGlxDraw->target = target;
+    pGlxDraw->format = format;
 }
 
 int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
diff --git a/glx/glxdrawable.h b/glx/glxdrawable.h
index 98e301b..5856b91 100644
--- a/glx/glxdrawable.h
+++ b/glx/glxdrawable.h
@@ -91,6 +91,7 @@ struct __GLXdrawable {
     int refCount;
 
     GLenum target;
+    GLenum format;
 
     /*
     ** Event mask
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 9a3bc1f..7b81483 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -221,9 +221,16 @@ __glXDRIbindTexImage(__GLXcontext *baseContext,
     if (texBuffer == NULL)
         return Success;
 
-    texBuffer->setTexBuffer(context->driContext,
-			    glxPixmap->target,
-			    drawable->driDrawable);
+    if (texBuffer->base.version >= 2 && texBuffer->setTexBuffer2 != NULL) {
+	(*texBuffer->setTexBuffer2)(context->driContext,
+				    glxPixmap->target,
+				    glxPixmap->format,
+				    drawable->driDrawable);
+    } else {
+	texBuffer->setTexBuffer(context->driContext,
+				glxPixmap->target,
+				drawable->driDrawable);
+    }
 
     return Success;
 }
commit ee6ce7e4cc23db26c7a5eb5ead41c1d057ca92e7
Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Feb 17 08:27:32 2009 -0800

    glx: Inialize best_score before calculating visual scores
    
    This bug was pointed out by Peter Ã…strand.
    
    Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
    (cherry picked from commit 4039603413f9f46d7f725463a70b4a51838e0049)

diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 8917269..e7258dd 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -403,7 +403,7 @@ static __GLXconfig *
 pickFBConfig(__GLXscreen *pGlxScreen, VisualPtr visual)
 {
     __GLXconfig *best = NULL, *config;
-    int best_score;
+    int best_score = 0;
 
     for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
 	int score = 0;
commit 5cae7f5a605c3b3f0dca83fa22926da6bd5e32e6
Author: Alan Hourihane <alanh at vmware.com>
Date:   Fri Feb 13 13:45:08 2009 +0000

    glx: fix retval checks when failures occur for drawable creation.
    (cherry picked from commit a26c77ff432d2e85a2665fc36fca25143460c476)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 52a97d4..61e0bf4 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -642,7 +642,7 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
 	if (visual->vid == glxConfig->visualID)
 	    break;
     if (i == pScreen->numVisuals)
-	return GL_FALSE;
+	return NULL;
 
     context->hwContextID = FakeClientID(0);
 
@@ -651,6 +651,9 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
 			      context->hwContextID, &hwContext);
     __glXleaveServer(GL_FALSE);
 
+    if (!retval)
+    	return NULL;
+
     context->driContext =
 	screen->legacy->createNewContext(screen->driScreen,
 					 config->driConfig,
@@ -705,6 +708,11 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
 			       pDraw, &hwDrawable);
     __glXleaveServer(GL_FALSE);
 
+    if (!retval) {
+    	xfree(private);
+    	return NULL;
+    }
+
     /* The last argument is 'attrs', which is used with pbuffers which
      * we currently don't support. */
 
commit 0fd4d26240aa996cf8e815139c9b044171ce7776
Author: Eric Anholt <eric at anholt.net>
Date:   Sun Feb 8 13:00:15 2009 +0100

    glx: Replace broken GLX visual setup with a fixed "all" mode.
    
    With trying to match depths so that you didn't end up with a depth 24
    fbconfig for the 32-bit composite visual, I broke the alpha bits on the depth
    24 X visual, which angered other applications.  But in fixing that, the
    pickFBconfigs code for "minimal" also could end up breaking GLX visuals if
    the same FBconfig was chosen for more than one X visual.
    We have no reason to not expose as many visuals as possible, but the old
    "all" mode didn't match any existing X visuals to GLX visuals, so normal
    GL apps didn't work at all.
    
    Instead, replace it with a simple combination of the two modes: Create GLX
    visuals by picking unique FBconfigs with as many features as possible for
    each X visual in order.  Then, for all remaining FBconfigs that are
    appropriate for display, add a corresponding X and GLX visual.
    
    This gets all applications (even ones that aren't smart enough to do FBconfigs)
    get all the options to get the visual configuration they want.  The only
    potential downside is that the composite ARGB visual is unique and gets a
    nearly full-featured GLX visual (except that the root visual might have taken
    the tastiest FBconfig), which means that a dumb compositing manager could
    waste resources. Write compositing managers using FBconfigs instead, please.
    (cherry picked from commit c40bad88475debf7a1774e22dce835577ad32154)
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 516f8e2cad1311a09764e2633644188d1e3c31bb)

diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 6e7098a..8917269 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -292,44 +292,6 @@ GLint glxConvertToXVisualType(int visualType)
 	? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1;
 }
 
-
-static void
-filterOutNativeConfigs(__GLXscreen *pGlxScreen)
-{
-    __GLXconfig *m, *next, **last;
-    ScreenPtr pScreen = pGlxScreen->pScreen;
-    int i, depth;
-
-    last = &pGlxScreen->fbconfigs;
-    for (m = pGlxScreen->fbconfigs; m != NULL; m = next) {
-	next = m->next;
-	depth = m->redBits + m->blueBits + m->greenBits;
-
-	for (i = 0; i < pScreen->numVisuals; i++) {
-	    if (pScreen->visuals[i].nplanes == depth) {
-		*last = m;
-		last = &m->next;
-		break;
-	    }
-	}
-    }
-
-    *last = NULL;
-}
-
-static XID
-findVisualForConfig(ScreenPtr pScreen, __GLXconfig *m)
-{
-    int i;
-
-    for (i = 0; i < pScreen->numVisuals; i++) {
-	if (glxConvertToXVisualType(m->visualType) == pScreen->visuals[i].class)
-	    return pScreen->visuals[i].vid;
-    }
-
-    return 0;
-}
-
 /* This code inspired by composite/compinit.c.  We could move this to
  * mi/ and share it with composite.*/
 
@@ -437,125 +399,52 @@ initGlxVisual(VisualPtr visual, __GLXconfig *config)
     visual->offsetBlue = findFirstSet(config->blueMask);
 }
 
-typedef struct {
-    GLboolean doubleBuffer;
-    GLboolean depthBuffer;
-    GLboolean stencilBuffer;
-} FBConfigTemplateRec, *FBConfigTemplatePtr;
-
 static __GLXconfig *
-pickFBConfig(__GLXscreen *pGlxScreen, FBConfigTemplatePtr template,
-	     VisualPtr visual)
+pickFBConfig(__GLXscreen *pGlxScreen, VisualPtr visual)
 {
-    __GLXconfig *config;
+    __GLXconfig *best = NULL, *config;
+    int best_score;
 
     for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
+	int score = 0;
+
 	if (config->redMask != visual->redMask ||
 	    config->greenMask != visual->greenMask ||
-	    config->blueMask != visual->blueMask ||
-	    config->rgbBits != visual->nplanes)
+	    config->blueMask != visual->blueMask)
 	    continue;
 	if (config->visualRating != GLX_NONE)
 	    continue;
 	if (glxConvertToXVisualType(config->visualType) != visual->class)
 	    continue;
-	if ((config->doubleBufferMode > 0) != template->doubleBuffer)
-	    continue;
-	if ((config->depthBits > 0) != template->depthBuffer)
+	/* If it's the 32-bit RGBA visual, demand a 32-bit fbconfig. */
+	if (visual->nplanes == 32 && config->rgbBits != 32)
 	    continue;
-	if ((config->stencilBits > 0) != template->stencilBuffer)
-	    continue;
-
-	return config;
-    }
-
-    return NULL;
-}
-
-static void
-addMinimalSet(__GLXscreen *pGlxScreen)
-{
-    __GLXconfig *config;
-    VisualPtr visuals;
-    int i, j;
-    FBConfigTemplateRec best = { GL_TRUE, GL_TRUE, GL_TRUE };
-    FBConfigTemplateRec good = { GL_TRUE, GL_TRUE, GL_FALSE };
-    FBConfigTemplateRec minimal = { GL_FALSE, GL_FALSE, GL_FALSE };
-
-    pGlxScreen->visuals = xcalloc(pGlxScreen->pScreen->numVisuals,
-				  sizeof (__GLXconfig *));
-    if (pGlxScreen->visuals == NULL) {
-	ErrorF("Failed to allocate for minimal set of GLX visuals\n");
-	return;
-    }
-
-    visuals = pGlxScreen->pScreen->visuals;
-    for (i = 0, j = 0; i < pGlxScreen->pScreen->numVisuals; i++) {
-	if (visuals[i].nplanes == 32)
-	    config = pickFBConfig(pGlxScreen, &minimal, &visuals[i]);
-	else {
-	    config = pickFBConfig(pGlxScreen, &best, &visuals[i]);
-	    if (config == NULL)
-		config = pickFBConfig(pGlxScreen, &good, &visuals[i]);
-        }
-	if (config == NULL)
-	    config = pGlxScreen->fbconfigs;
-	if (config == NULL)
+	/* Can't use the same FBconfig for multiple X visuals.  I think. */
+	if (config->visualID != 0)
 	    continue;
 
-	pGlxScreen->visuals[j] = config;
-	config->visualID = visuals[i].vid;
-	j++;
-    }
-
-    pGlxScreen->numVisuals = j;
-}
-
-static void
-addTypicalSet(__GLXscreen *pGlxScreen)
-{
-    addMinimalSet(pGlxScreen);
-}
-
-static void
-addFullSet(__GLXscreen *pGlxScreen)
-{
-    __GLXconfig *config;
-    VisualPtr visuals;
-    int i, depth;
-
-    pGlxScreen->visuals =
-	xcalloc(pGlxScreen->numFBConfigs, sizeof (__GLXconfig *));
-    if (pGlxScreen->visuals == NULL) {
-	ErrorF("Failed to allocate for full set of GLX visuals\n");
-	return;
-    }
-
-    config = pGlxScreen->fbconfigs;
-    depth = config->redBits + config->greenBits + config->blueBits;
-    visuals = AddScreenVisuals(pGlxScreen->pScreen, pGlxScreen->numFBConfigs, depth);
-    if (visuals == NULL) {
-	xfree(pGlxScreen->visuals);
-	return;
-    }
-
-    pGlxScreen->numVisuals = pGlxScreen->numFBConfigs;
-    for (i = 0, config = pGlxScreen->fbconfigs; config; config = config->next, i++) {
-	pGlxScreen->visuals[i] = config;
-	initGlxVisual(&visuals[i], config);
+	if (config->doubleBufferMode > 0)
+	    score += 8;
+	if (config->depthBits > 0)
+	    score += 4;
+	if (config->stencilBits > 0)
+	    score += 2;
+	if (config->alphaBits > 0)
+	    score++;
+
+	if (score > best_score) {
+	    best = config;
+	    best_score = score;
+	}
     }
-}
 
-static int glxVisualConfig = GLX_ALL_VISUALS;
-
-void GlxSetVisualConfig(int config)
-{
-    glxVisualConfig = config;
+    return best;
 }
 
 void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
 {
     __GLXconfig *m;
+    __GLXconfig *config;
     int i;
 
     pGlxScreen->pScreen       = pScreen;
@@ -570,32 +459,66 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
     pGlxScreen->CloseScreen = pScreen->CloseScreen;
     pScreen->CloseScreen = glxCloseScreen;
 
-    filterOutNativeConfigs(pGlxScreen);
-
     i = 0;
     for (m = pGlxScreen->fbconfigs; m != NULL; m = m->next) {
 	m->fbconfigID = FakeClientID(0);
-	m->visualID = findVisualForConfig(pScreen, m);
+	m->visualID = 0;
 	i++;
     }
     pGlxScreen->numFBConfigs = i;
 
-    /* Select a subset of fbconfigs that we send to the client when it
-     * asks for the glx visuals.  All the fbconfigs here have a valid
-     * value for visual ID and each visual ID is only present once.
-     * This runs before composite adds its extra visual so we have to
-     * remember the number of visuals here.*/
-
-    switch (glxVisualConfig) {
-    case GLX_MINIMAL_VISUALS:
-	addMinimalSet(pGlxScreen);
-	break;
-    case GLX_TYPICAL_VISUALS:
-	addTypicalSet(pGlxScreen);
-	break;
-    case GLX_ALL_VISUALS:
-	addFullSet(pGlxScreen);
-	break;
+    pGlxScreen->visuals =
+	xcalloc(pGlxScreen->numFBConfigs, sizeof (__GLXconfig *));
+
+    /* First, try to choose featureful FBconfigs for the existing X visuals.
+     * Note that if multiple X visuals end up with the same FBconfig being
+     * chosen, the later X visuals don't get GLX visuals (because we want to
+     * prioritize the root visual being GLX).
+     */
+    for (i = 0; i < pScreen->numVisuals; i++) {
+	VisualPtr visual = &pScreen->visuals[i];
+
+	config = pickFBConfig(pGlxScreen, visual);
+	if (config) {
+	    pGlxScreen->visuals[pGlxScreen->numVisuals++] = config;
+	    config->visualID = visual->vid;
+	}
+    }
+
+    /* Then, add new visuals corresponding to all FBconfigs that didn't have
+     * an existing, appropriate visual.
+     */
+    for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
+	int depth;
+
+	VisualPtr visual;
+
+	if (config->visualID != 0)
+	    continue;
+
+	/* Only count RGB bits and not alpha, as we're not trying to create
+	 * visuals for compositing (that's what the 32-bit composite visual
+	 * set up above is for.
+	 */
+	depth = config->redBits + config->greenBits + config->blueBits;
+
+	/* Make sure that our FBconfig's depth can actually be displayed
+	 * (corresponds to an existing visual).
+	 */
+	for (i = 0; i < pScreen->numVisuals; i++) {
+	    if (depth == pScreen->visuals[i].nplanes)
+		break;
+	}
+	if (i == pScreen->numVisuals)
+	    continue;
+
+	/* Create a new X visual for our FBconfig. */
+	visual = AddScreenVisuals(pScreen, 1, depth);
+	if (visual == NULL)
+	    continue;
+
+	pGlxScreen->visuals[pGlxScreen->numVisuals++] = config;
+	initGlxVisual(visual, config);
     }
 
     dixSetPrivate(&pScreen->devPrivates, glxScreenPrivateKey, pGlxScreen);
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 6271258..38dfec8 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -139,8 +139,6 @@ enum {
     GLX_ALL_VISUALS
 };
 
-void GlxSetVisualConfig(int config);
-
 void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
 				   void (*leave)(GLboolean));
 void __glXenterServer(GLboolean rendering);
diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c
index f6fda4b..62a047e 100644
--- a/hw/xfree86/dixmods/glxmodule.c
+++ b/hw/xfree86/dixmods/glxmodule.c
@@ -101,21 +101,6 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
 	GlxPushProvider(provider);
     }
 
-    switch (xf86Info.glxVisuals) {
-    case XF86_GlxVisualsMinimal:
-	GlxSetVisualConfig(GLX_MINIMAL_VISUALS);
-	xf86Msg(xf86Info.aiglxFrom, "Exporting only minimal set of GLX visuals\n");
-	break;
-    case XF86_GlxVisualsTypical:
-	GlxSetVisualConfig(GLX_TYPICAL_VISUALS);
-	xf86Msg(xf86Info.aiglxFrom, "Exporting typical set of GLX visuals\n");
-	break;
-    case XF86_GlxVisualsAll:
-	GlxSetVisualConfig(GLX_ALL_VISUALS);
-	xf86Msg(xf86Info.aiglxFrom, "Exporting all GLX visuals\n");
-	break;
-    }
-
     LoadExtension(&GLXExt, FALSE);
 
     return module;
commit 7f9df0c932aab1c1059d434e2ba7ad9099c64315
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Feb 2 10:13:46 2009 -0800

    glx: Don't match fbconfigs to visuals with mismatched channel masks.
    
    This fixes at least one known bug, where the depth 32 visual would end up
    with a depth 24 fbconfig attached, angering compiz.
    (cherry picked from commit 5100d829a4d71ce4a9fbc2b81694a1fb90066ccf)

diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 7b0eb0c..6e7098a 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -444,14 +444,20 @@ typedef struct {
 } FBConfigTemplateRec, *FBConfigTemplatePtr;
 
 static __GLXconfig *
-pickFBConfig(__GLXscreen *pGlxScreen, FBConfigTemplatePtr template, int class)
+pickFBConfig(__GLXscreen *pGlxScreen, FBConfigTemplatePtr template,
+	     VisualPtr visual)
 {
     __GLXconfig *config;
 
     for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
+	if (config->redMask != visual->redMask ||
+	    config->greenMask != visual->greenMask ||
+	    config->blueMask != visual->blueMask ||
+	    config->rgbBits != visual->nplanes)
+	    continue;
 	if (config->visualRating != GLX_NONE)
 	    continue;
-	if (glxConvertToXVisualType(config->visualType) != class)
+	if (glxConvertToXVisualType(config->visualType) != visual->class)
 	    continue;
 	if ((config->doubleBufferMode > 0) != template->doubleBuffer)
 	    continue;
@@ -486,11 +492,11 @@ addMinimalSet(__GLXscreen *pGlxScreen)
     visuals = pGlxScreen->pScreen->visuals;
     for (i = 0, j = 0; i < pGlxScreen->pScreen->numVisuals; i++) {
 	if (visuals[i].nplanes == 32)
-	    config = pickFBConfig(pGlxScreen, &minimal, visuals[i].class);
+	    config = pickFBConfig(pGlxScreen, &minimal, &visuals[i]);
 	else {
-	    config = pickFBConfig(pGlxScreen, &best, visuals[i].class);
+	    config = pickFBConfig(pGlxScreen, &best, &visuals[i]);
 	    if (config == NULL)
-		config = pickFBConfig(pGlxScreen, &good, visuals[i].class);
+		config = pickFBConfig(pGlxScreen, &good, &visuals[i]);
         }
 	if (config == NULL)
 	    config = pGlxScreen->fbconfigs;


More information about the xorg-commit mailing list