xf86-video-intel: 4 commits - src/intel_dri.c src/intel.h src/intel_uxa.c uxa/uxa.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Oct 6 04:17:35 PDT 2010


 src/intel.h     |    1 
 src/intel_dri.c |   67 ++++++++++++++++++++++++++++---------------------------
 src/intel_uxa.c |   68 +++++++++++++++++++++-----------------------------------
 uxa/uxa.c       |    3 +-
 4 files changed, 64 insertions(+), 75 deletions(-)

New commits:
commit f286891d1415fc607f0c1b574e6bce4b3759493e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 6 11:38:48 2010 +0100

    dri: Reattach the fake pixmap for the shadow scanout to the drawable.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_dri.c b/src/intel_dri.c
index fe46a11..bc4dc50 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -70,11 +70,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 typedef struct {
 	int refcnt;
 	PixmapPtr pixmap;
-	DrawablePtr drawable;
 	unsigned int attachment;
 } I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr;
 
-static PixmapPtr get_front_buffer(DrawablePtr drawable, DrawablePtr *ret)
+static PixmapPtr get_front_buffer(DrawablePtr drawable)
 {
 	ScreenPtr screen = drawable->pScreen;
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
@@ -82,7 +81,9 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable, DrawablePtr *ret)
 	PixmapPtr pixmap;
 
 	pixmap = get_drawable_pixmap(drawable);
-	if (pixmap_is_scanout(pixmap)) {
+	if (!intel->use_shadow) {
+		pixmap->refcnt++;
+	} else if (pixmap_is_scanout(pixmap)) {
 		pixmap = fbCreatePixmap(screen, 0, 0, drawable->depth, 0);
 		if (pixmap) {
 			screen->ModifyPixmapHeader(pixmap,
@@ -91,12 +92,15 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable, DrawablePtr *ret)
 						   0, 0,
 						   intel->front_pitch,
 						   intel->front_buffer->virtual);
+
 			intel_set_pixmap_bo(pixmap, intel->front_buffer);
 			intel_get_pixmap_private(pixmap)->offscreen = 0;
+			if (WindowDrawable(drawable->type))
+				screen->SetWindowPixmap((WindowPtr)drawable,
+							pixmap);
 		}
 	} else if (intel_get_pixmap_bo(pixmap)) {
 		pixmap->refcnt++;
-		*ret = drawable;
 	} else
 		pixmap = NULL;
 	return pixmap;
@@ -179,7 +183,6 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 	int i;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap, pDepthPixmap;
-	DrawablePtr target;
 
 	buffers = calloc(count, sizeof *buffers);
 	if (buffers == NULL)
@@ -192,10 +195,9 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 
 	pDepthPixmap = NULL;
 	for (i = 0; i < count; i++) {
-		target = NULL;
 		pixmap = NULL;
 		if (attachments[i] == DRI2BufferFrontLeft) {
-			pixmap = get_front_buffer(drawable, &target);
+			pixmap = get_front_buffer(drawable);
 		} else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
 			pixmap = pDepthPixmap;
 			pixmap->refcnt++;
@@ -249,8 +251,6 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 		privates[i].pixmap = pixmap;
 		privates[i].attachment = attachments[i];
 
-		privates[i].drawable = target ? target : &pixmap->drawable;
-
 		bo = intel_get_pixmap_bo(pixmap);
 		if (bo == NULL || dri_bo_flink(bo, &buffers[i].name) != 0) {
 			/* failed to name buffer */
@@ -300,7 +300,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	dri_bo *bo;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap;
-	DrawablePtr target = NULL;
 
 	buffer = calloc(1, sizeof *buffer);
 	if (buffer == NULL)
@@ -313,7 +312,7 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 
 	pixmap = NULL;
 	if (attachment == DRI2BufferFrontLeft)
-		pixmap = get_front_buffer(drawable, &target);
+		pixmap = get_front_buffer(drawable);
 	if (pixmap == NULL) {
 		unsigned int hint = INTEL_CREATE_PIXMAP_DRI2;
 
@@ -358,7 +357,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	privates->refcnt = 1;
 	privates->pixmap = pixmap;
 	privates->attachment = attachment;
-	privates->drawable = target ? target : &pixmap->drawable;
 
 	bo = intel_get_pixmap_bo(pixmap);
 	if (bo == NULL || dri_bo_flink(bo, &buffer->name) != 0) {
@@ -406,8 +404,10 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
 	ScreenPtr screen = drawable->pScreen;
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	DrawablePtr src = srcPrivate->drawable;
-	DrawablePtr dst = dstPrivate->drawable;
+	DrawablePtr src = (srcPrivate->attachment == DRI2BufferFrontLeft)
+		? drawable : &srcPrivate->pixmap->drawable;
+	DrawablePtr dst = (dstPrivate->attachment == DRI2BufferFrontLeft)
+		? drawable : &dstPrivate->pixmap->drawable;
 	RegionPtr pCopyClip;
 	struct intel_pixmap *src_pixmap, *dst_pixmap;
 	GCPtr gc;
commit 23ee926bcd8ddd7a2785786efdf119e4fae75bfd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 6 10:20:49 2010 +0100

    uxa: Skip a pixmap lookup if there is no driver finish access function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/uxa/uxa.c b/uxa/uxa.c
index 3c81a85..856a0ce 100644
--- a/uxa/uxa.c
+++ b/uxa/uxa.c
@@ -164,11 +164,12 @@ void uxa_finish_access(DrawablePtr pDrawable)
 {
 	ScreenPtr pScreen = pDrawable->pScreen;
 	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
-	PixmapPtr pPixmap = uxa_get_drawable_pixmap(pDrawable);
+	PixmapPtr pPixmap;
 
 	if (uxa_screen->info->finish_access == NULL)
 		return;
 
+	pPixmap = uxa_get_drawable_pixmap(pDrawable);
 	if (!uxa_pixmap_is_offscreen(pPixmap))
 		return;
 
commit 707901bf98073fb56179a0b61c806f85ef8f413c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 6 08:47:20 2010 +0100

    uxa: Re-enable acceleration.
    
    A side-effect of discriminating offscreen based on the devPrivate.ptr
    was that it broke uxa_finish_access and so after any fallback to s/w on
    a Pixmap, it remained in software for the reminder of its life.
    
    Introduce an explicit boolean to mark whether or not hardware
    acceleration is enabled for a pixmap (with a GEM buffer).
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel.h b/src/intel.h
index 83d541e..b74a061 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -169,6 +169,7 @@ struct intel_pixmap {
 	uint8_t tiling;
 	int8_t busy :2;
 	int8_t batch_write :1;
+	int8_t offscreen :1;
 };
 
 #if HAS_DEVPRIVATEKEYREC
diff --git a/src/intel_dri.c b/src/intel_dri.c
index 1527dba..fe46a11 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -90,8 +90,9 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable, DrawablePtr *ret)
 						   drawable->height,
 						   0, 0,
 						   intel->front_pitch,
-						   NULL);
+						   intel->front_buffer->virtual);
 			intel_set_pixmap_bo(pixmap, intel->front_buffer);
+			intel_get_pixmap_private(pixmap)->offscreen = 0;
 		}
 	} else if (intel_get_pixmap_bo(pixmap)) {
 		pixmap->refcnt++;
@@ -124,20 +125,21 @@ static PixmapPtr fixup_shadow(DrawablePtr drawable, PixmapPtr pixmap)
 	 * accelerated.
 	 */
 
-	drm_intel_gem_bo_map_gtt(priv->bo);
+	if (drm_intel_gem_bo_map_gtt(priv->bo))
+		return pixmap;
+
+	screen->ModifyPixmapHeader(pixmap,
+				   drawable->width,
+				   drawable->height,
+				   0, 0,
+				   priv->stride,
+				   priv->bo->virtual);
+	priv->offscreen = 0;
 
 	/* Copy the current contents of the pixmap to the bo. */
 	gc = GetScratchGC(drawable->depth, screen);
 	if (gc) {
 		ValidateGC(&pixmap->drawable, gc);
-
-		screen->ModifyPixmapHeader(pixmap,
-					   drawable->width,
-					   drawable->height,
-					   0, 0,
-					   priv->stride,
-					   priv->bo->virtual);
-
 		gc->ops->CopyArea(drawable, &pixmap->drawable,
 				  gc,
 				  0, 0,
@@ -407,7 +409,7 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
 	DrawablePtr src = srcPrivate->drawable;
 	DrawablePtr dst = dstPrivate->drawable;
 	RegionPtr pCopyClip;
-	PixmapPtr src_pixmap, dst_pixmap;
+	struct intel_pixmap *src_pixmap, *dst_pixmap;
 	GCPtr gc;
 
 	gc = GetScratchGC(dst->depth, screen);
@@ -505,11 +507,13 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
 	 * again. */
 
 	/* Re-enable 2D acceleration... */
-	src_pixmap = get_drawable_pixmap(src);
-	src_pixmap->devPrivate.ptr = NULL;
+	src_pixmap = intel_get_pixmap_private(get_drawable_pixmap(src));
+	src_pixmap->offscreen = 1;
+	src_pixmap->busy = 1;
 
-	dst_pixmap = get_drawable_pixmap(dst);
-	dst_pixmap->devPrivate.ptr = NULL;
+	dst_pixmap = intel_get_pixmap_private(get_drawable_pixmap(dst));
+	dst_pixmap->offscreen = 1;
+	dst_pixmap->busy = 1;
 
 	gc->ops->CopyArea(src, dst, gc,
 			  0, 0,
@@ -518,8 +522,8 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
 	FreeScratchGC(gc);
 
 	/* and restore 2D/3D coherency */
-	src_pixmap->devPrivate.ptr = intel_get_pixmap_bo(src_pixmap)->virtual;
-	dst_pixmap->devPrivate.ptr = intel_get_pixmap_bo(dst_pixmap)->virtual;
+	src_pixmap->offscreen = 0;
+	dst_pixmap->offscreen = 0;
 }
 
 #if DRI2INFOREC_VERSION >= 4
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index d964a95..fd7ca23 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -666,6 +666,7 @@ void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo)
 
 		priv->tiling = tiling;
 		priv->busy = -1;
+		priv->offscreen = 1;
 	} else {
 		if (priv != NULL) {
 			free(priv);
@@ -677,6 +678,12 @@ void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo)
 	intel_set_pixmap_private(pixmap, priv);
 }
 
+static Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
+{
+	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	return priv && priv->offscreen;
+}
+
 static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 {
 	ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
@@ -707,22 +714,6 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 	return TRUE;
 }
 
-static void intel_uxa_finish_access(PixmapPtr pixmap)
-{
-	ScreenPtr screen = pixmap->drawable.pScreen;
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
-	dri_bo *bo = priv->bo;
-
-	if (priv->tiling || bo->size <= intel->max_gtt_map_size)
-		drm_intel_gem_bo_unmap_gtt(bo);
-	else
-		dri_bo_unmap(bo);
-
-	pixmap->devPrivate.ptr = NULL;
-}
-
 static Bool intel_uxa_pixmap_put_image(PixmapPtr pixmap,
 				       char *src, int src_pitch,
 				       int x, int y, int w, int h)
@@ -813,6 +804,11 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
 			if (!scratch)
 				return FALSE;
 
+			if (!intel_uxa_pixmap_is_offscreen(scratch)) {
+				screen->DestroyPixmap(scratch);
+				return FALSE;
+			}
+
 			ret = intel_uxa_pixmap_put_image(scratch, src, src_pitch, 0, 0, w, h);
 			if (ret) {
 				GCPtr gc = GetScratchGC(pixmap->drawable.depth, screen);
@@ -893,7 +889,7 @@ static Bool intel_uxa_get_image(PixmapPtr pixmap,
 		if (!scratch)
 			return FALSE;
 
-		if (!intel_get_pixmap_bo(scratch)) {
+		if (!intel_uxa_pixmap_is_offscreen(scratch)) {
 			screen->DestroyPixmap(scratch);
 			return FALSE;
 		}
@@ -941,14 +937,6 @@ void intel_uxa_block_handler(intel_screen_private *intel)
 	}
 }
 
-static Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
-{
-	if (pixmap->devPrivate.ptr)
-		return FALSE;
-
-	return intel_get_pixmap_bo(pixmap) != NULL;
-}
-
 static PixmapPtr
 intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 			unsigned usage)
@@ -1070,6 +1058,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 			drm_intel_bo_set_tiling(priv->bo, &tiling, stride);
 		priv->stride = stride;
 		priv->tiling = tiling;
+		priv->offscreen = 1;
 
 		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
 
@@ -1093,22 +1082,22 @@ void intel_uxa_create_screen_resources(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
+	dri_bo *bo = intel->front_buffer;
+
+	drm_intel_gem_bo_map_gtt(bo);
 
 	if (intel->use_shadow) {
 		intel_shadow_create(intel);
 	} else {
-		dri_bo *bo = intel->front_buffer;
-		if (bo != NULL) {
-			PixmapPtr pixmap = screen->GetScreenPixmap(screen);
-			intel_set_pixmap_bo(pixmap, bo);
-			intel_get_pixmap_private(pixmap)->busy = 1;
-			screen->ModifyPixmapHeader(pixmap,
-						   scrn->virtualX,
-						   scrn->virtualY,
-						   -1, -1,
-						   intel->front_pitch,
-						   NULL);
-		}
+		PixmapPtr pixmap = screen->GetScreenPixmap(screen);
+		intel_set_pixmap_bo(pixmap, bo);
+		intel_get_pixmap_private(pixmap)->busy = 1;
+		screen->ModifyPixmapHeader(pixmap,
+					   scrn->virtualX,
+					   scrn->virtualY,
+					   -1, -1,
+					   intel->front_pitch,
+					   NULL);
 		scrn->displayWidth = intel->front_pitch / intel->cpp;
 	}
 }
@@ -1244,7 +1233,6 @@ Bool intel_uxa_init(ScreenPtr screen)
 	intel->uxa_driver->get_image = intel_uxa_get_image;
 
 	intel->uxa_driver->prepare_access = intel_uxa_prepare_access;
-	intel->uxa_driver->finish_access = intel_uxa_finish_access;
 	intel->uxa_driver->pixmap_is_offscreen = intel_uxa_pixmap_is_offscreen;
 
 	screen->CreatePixmap = intel_uxa_create_pixmap;
commit 54f545e0631a287f421ef6a6f20831624b212cf2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 6 08:50:13 2010 +0100

    Revert "Clear pixmap->devPrivate.ptr [regression in 7c7294e]"
    
    This reverts commit 48b4e224297fa807be0e2bc7a67bf7e94579e8de.
    
    The better fix is to manually mark the pixmap when acceleration is and
    is not permitted. Whilst the devPrivate.ptr are invalid upon creation,
    it is not worth carring code that serves no purpose.

diff --git a/src/intel_dri.c b/src/intel_dri.c
index 7d109e9..1527dba 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -91,7 +91,6 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable, DrawablePtr *ret)
 						   0, 0,
 						   intel->front_pitch,
 						   NULL);
-			pixmap->devPrivate.ptr = NULL;
 			intel_set_pixmap_bo(pixmap, intel->front_buffer);
 		}
 	} else if (intel_get_pixmap_bo(pixmap)) {
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index 34649b8..d964a95 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -796,7 +796,6 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
 						   w, h,
 						   0, 0,
 						   stride, NULL);
-			pixmap->devPrivate.ptr = NULL;
 			intel_set_pixmap_bo(pixmap, bo);
 			dri_bo_unreference(bo);
 
@@ -1040,7 +1039,6 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 
 				list_del(&priv->in_flight);
 				screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
-				pixmap->devPrivate.ptr = NULL;
 				intel_set_pixmap_private(pixmap, priv);
 				return pixmap;
 			}
@@ -1074,7 +1072,6 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		priv->tiling = tiling;
 
 		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
-		pixmap->devPrivate.ptr = NULL;
 
 		list_init(&priv->batch);
 		list_init(&priv->flush);
@@ -1111,7 +1108,6 @@ void intel_uxa_create_screen_resources(ScreenPtr screen)
 						   -1, -1,
 						   intel->front_pitch,
 						   NULL);
-			pixmap->devPrivate.ptr = NULL;
 		}
 		scrn->displayWidth = intel->front_pitch / intel->cpp;
 	}


More information about the xorg-commit mailing list