Mesa (master): st/xorg: Set shared usage of pixmaps for use via DRI2.

Michel Dänzer daenzer at kemper.freedesktop.org
Thu Aug 27 18:30:56 UTC 2009


Module: Mesa
Branch: master
Commit: 416ee3c53eeb1664784f224a42e293e5fed783bc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=416ee3c53eeb1664784f224a42e293e5fed783bc

Author: Michel Dänzer <daenzer at vmware.com>
Date:   Thu Aug 27 20:29:32 2009 +0200

st/xorg: Set shared usage of pixmaps for use via DRI2.

Also allow pixmaps to have both the shared and displayed usage flags, as is
the case for the screen pixmap now.

---

 src/gallium/state_trackers/xorg/xorg_dri2.c   |   10 +++++++---
 src/gallium/state_trackers/xorg/xorg_driver.c |    1 +
 src/gallium/state_trackers/xorg/xorg_exa.c    |   12 ++----------
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index 1110246..1a4677b 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -92,7 +92,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
 	    else
 		pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
 	    pPixmap->refcnt++;
-	    tex = xorg_exa_get_texture(pPixmap);
 	} else if (attachments[i] == DRI2BufferStencil) {
 	    pipe_texture_reference(&tex, depth);
 	} else if (attachments[i] == DRI2BufferDepth) {
@@ -110,19 +109,24 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
 	    template.height[0] = pDraw->height;
 	    template.depth[0] = 1;
 	    template.last_level = 0;
-	    template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+	    template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
+		PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
 	    tex = ms->screen->texture_create(ms->screen, &template);
 	    depth = tex;
 	} else if (attachments[i] == DRI2BufferFakeFrontLeft &&
 		   pDraw->type == DRAWABLE_PIXMAP) {
 	    pPixmap = (PixmapPtr) pDraw;
 	    pPixmap->refcnt++;
-	    tex = xorg_exa_get_texture(pPixmap);
 	} else {
 	    pPixmap = (*pScreen->CreatePixmap)(pScreen, pDraw->width,
 					       pDraw->height,
 					       pDraw->depth,
 					       0);
+	}
+
+	if (pPixmap) {
+	    xorg_exa_set_shared_usage(pPixmap);
+	    pScreen->ModifyPixmapHeader(pPixmap, 0, 0, 0, 0, 0, NULL);
 	    tex = xorg_exa_get_texture(pPixmap);
 	}
 
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 923662b..d225345 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -481,6 +481,7 @@ CreateScreenResources(ScreenPtr pScreen)
     rootPixmap = pScreen->GetScreenPixmap(pScreen);
 
     xorg_exa_set_displayed_usage(rootPixmap);
+    xorg_exa_set_shared_usage(rootPixmap);
     if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
 	FatalError("Couldn't adjust screen pixmap\n");
 
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index 0184608..4fc8d32 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -373,11 +373,7 @@ xorg_exa_set_displayed_usage(PixmapPtr pPixmap)
 	return 0;
     }
 
-    if (priv->flags & ~PIPE_TEXTURE_USAGE_PRIMARY) {
-	FatalError("BAD FLAGS\n");
-	return 0;
-    }
-    priv->flags = PIPE_TEXTURE_USAGE_PRIMARY;
+    priv->flags |= PIPE_TEXTURE_USAGE_PRIMARY;
 
     return 0;
 }
@@ -393,11 +389,7 @@ xorg_exa_set_shared_usage(PixmapPtr pPixmap)
 	return 0;
     }
 
-    if (priv->flags & ~PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
-	FatalError("BAD FLAGS\n");
-	return 0;
-    }
-    priv->flags = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+    priv->flags |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
 
     return 0;
 }




More information about the mesa-commit mailing list