xf86-video-intel: 3 commits - src/i830_dri.c src/i830.h src/i830_video.c

Eric Anholt anholt at kemper.freedesktop.org
Wed Jun 3 03:20:47 PDT 2009


 src/i830.h       |   19 +++++++++++++
 src/i830_dri.c   |   76 ++++++++++++++++++++++++++-----------------------------
 src/i830_video.c |   10 +------
 3 files changed, 57 insertions(+), 48 deletions(-)

New commits:
commit b8e360bf2b77d28559d15a7c0f9c766848eb6ced
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jun 3 10:12:25 2009 +0000

    Fix segfault in DRI2 vblank syncing if the region isn't onscreen.
    
    Also, fix some weirdness in the checking for whether the target was the
    screen.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 667f687..9da1d40 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -289,7 +289,6 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
 	? pDraw : &srcPrivate->pPixmap->drawable;
     DrawablePtr dst = (dstPrivate->attachment == DRI2BufferFrontLeft)
 	? pDraw : &dstPrivate->pPixmap->drawable;
-    PixmapPtr dst_pixmap = get_drawable_pixmap(dst);
     RegionPtr pCopyClip;
     GCPtr pGC;
 
@@ -300,7 +299,7 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
     ValidateGC(dst, pGC);
 
     /* Wait for the scanline to be outside the region to be copied */
-    if (dstPrivate->attachment == DRI2BufferFrontLeft) {
+    if (pixmap_is_scanout(get_drawable_pixmap(dst))) {
 	BoxPtr box;
 	BoxRec crtcbox;
 	int y1, y2;
@@ -310,33 +309,35 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
 	box = REGION_EXTENTS(unused, pGC->pCompositeClip);
 	crtc = i830_covering_crtc(pScrn, box, NULL, &crtcbox);
 
-	if (pI830->use_drm_mode)
-	    pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
-	else {
-	    I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
-	    pipe = intel_crtc->pipe;
-	}
+	if (crtc != NULL) {
+	    if (pI830->use_drm_mode)
+		pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
+	    else {
+		I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+		pipe = intel_crtc->pipe;
+	    }
 
-	if (pipe == 0) {
-	    event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
-	    load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
-	} else {
-	    event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
-	    load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
-	}
+	    if (pipe == 0) {
+		event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
+		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
+	    } else {
+		event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
+		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
+	    }
 
-	y1 = box->y1 - crtc->y;
-	y2 = box->y2 - crtc->y;
-
-	BEGIN_BATCH(5);
-	/* The documentation says that the LOAD_SCAN_LINES command
-	 * always comes in pairs. Don't ask me why. */
-	OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
-	OUT_BATCH((y1 << 16) | y2);
-	OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
-	OUT_BATCH((y1 << 16) | y2);
-	OUT_BATCH(MI_WAIT_FOR_EVENT | event);
-	ADVANCE_BATCH();
+	    y1 = box->y1 - crtc->y;
+	    y2 = box->y2 - crtc->y;
+
+	    BEGIN_BATCH(5);
+	    /* The documentation says that the LOAD_SCAN_LINES command
+	     * always comes in pairs. Don't ask me why. */
+	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
+	    OUT_BATCH((y1 << 16) | y2);
+	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
+	    OUT_BATCH((y1 << 16) | y2);
+	    OUT_BATCH(MI_WAIT_FOR_EVENT | event);
+	    ADVANCE_BATCH();
+	}
     }
 
     (*pGC->ops->CopyArea)(src, dst,
commit 5901a67fc85ac80fabfa98b78202a388445275c3
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jun 3 10:00:50 2009 +0000

    Fix some drawable abuse in i830_dri.c
    
    We were casting pixmaps to drawables even if they weren't pixmaps.  They did
    happen to work out since we only used the drawable record out of them.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 8b2629f..667f687 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -285,10 +285,11 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
     ScreenPtr pScreen = pDraw->pScreen;
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
-    PixmapPtr pSrcPixmap = (srcPrivate->attachment == DRI2BufferFrontLeft)
-	? (PixmapPtr) pDraw : srcPrivate->pPixmap;
-    PixmapPtr pDstPixmap = (dstPrivate->attachment == DRI2BufferFrontLeft)
-	? (PixmapPtr) pDraw : dstPrivate->pPixmap;
+    DrawablePtr src = (srcPrivate->attachment == DRI2BufferFrontLeft)
+	? pDraw : &srcPrivate->pPixmap->drawable;
+    DrawablePtr dst = (dstPrivate->attachment == DRI2BufferFrontLeft)
+	? pDraw : &dstPrivate->pPixmap->drawable;
+    PixmapPtr dst_pixmap = get_drawable_pixmap(dst);
     RegionPtr pCopyClip;
     GCPtr pGC;
 
@@ -296,7 +297,7 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
     pCopyClip = REGION_CREATE(pScreen, NULL, 0);
     REGION_COPY(pScreen, pCopyClip, pRegion);
     (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pCopyClip, 0);
-    ValidateGC(&pDstPixmap->drawable, pGC);
+    ValidateGC(dst, pGC);
 
     /* Wait for the scanline to be outside the region to be copied */
     if (dstPrivate->attachment == DRI2BufferFrontLeft) {
@@ -338,7 +339,7 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
 	ADVANCE_BATCH();
     }
 
-    (*pGC->ops->CopyArea)(&pSrcPixmap->drawable, &pDstPixmap->drawable,
+    (*pGC->ops->CopyArea)(src, dst,
 			  pGC, 0, 0, pDraw->width, pDraw->height, 0, 0);
     FreeScratchGC(pGC);
 
commit 5e48146777921b693c828af9566a77422cc4f85f
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jun 3 09:57:10 2009 +0000

    Replace some pixmap-related idioms with inline functions to do so.

diff --git a/src/i830.h b/src/i830.h
index 2d9e905..c0e7dcd 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -946,4 +946,23 @@ i830_debug_sync(ScrnInfoPtr scrn)
 }
 #endif
 
+static inline PixmapPtr
+get_drawable_pixmap(DrawablePtr drawable)
+{
+    ScreenPtr screen = drawable->pScreen;
+
+    if (drawable->type == DRAWABLE_PIXMAP)
+	return (PixmapPtr)drawable;
+    else
+	return screen->GetWindowPixmap((WindowPtr)drawable);
+}
+
+static inline Bool
+pixmap_is_scanout(PixmapPtr pixmap)
+{
+    ScreenPtr screen = pixmap->drawable.pScreen;
+
+    return pixmap == screen->GetScreenPixmap(screen);
+}
+
 #endif /* _I830_H_ */
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 632280e..8b2629f 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -103,10 +103,7 @@ I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
     pDepthPixmap = NULL;
     for (i = 0; i < count; i++) {
 	if (attachments[i] == DRI2BufferFrontLeft) {
-	    if (pDraw->type == DRAWABLE_PIXMAP)
-		pPixmap = (PixmapPtr) pDraw;
-	    else
-		pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+	    pPixmap = get_drawable_pixmap(pDraw);
 	    pPixmap->refcnt++;
 	} else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
 	    pPixmap = pDepthPixmap;
@@ -186,10 +183,7 @@ I830DRI2CreateBuffer(DrawablePtr pDraw, unsigned int attachment,
     }
 
     if (attachment == DRI2BufferFrontLeft) {
-	if (pDraw->type == DRAWABLE_PIXMAP)
-	    pPixmap = (PixmapPtr) pDraw;
-	else
-	    pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+	pPixmap = get_drawable_pixmap(pDraw);
 	pPixmap->refcnt++;
     } else {
 	unsigned int hint = 0;
diff --git a/src/i830_video.c b/src/i830_video.c
index 085e79a..1ff80a0 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2216,7 +2216,7 @@ I830PutImage(ScrnInfoPtr pScrn,
     I830PortPrivPtr pPriv = (I830PortPrivPtr) data;
     ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
     I830OverlayRegPtr overlay;
-    PixmapPtr pPixmap;
+    PixmapPtr pPixmap = get_drawable_pixmap(pDraw);;
     INT32 x1, x2, y1, y2;
     int srcPitch = 0, srcPitch2 = 0, dstPitch, destId;
     int dstPitch2 = 0;
@@ -2467,12 +2467,6 @@ I830PutImage(ScrnInfoPtr pScrn,
 	break;
     }
 
-    if (pDraw->type == DRAWABLE_WINDOW) {
-	pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
-    } else {
-	pPixmap = (PixmapPtr)pDraw;
-    }
-
     if (!pPriv->textured) {
 	i830_display_video(pScrn, crtc, destId, width, height, dstPitch,
 			   x1, y1, x2, y2, &dstBox, src_w, src_h,
@@ -2497,7 +2491,7 @@ I830PutImage(ScrnInfoPtr pScrn,
 	    int y1, y2;
 	    int pipe = -1, event, load_scan_lines_pipe;
 
-	    if (pPixmap == pScreen->GetScreenPixmap(pScreen)) {
+	    if (pixmap_is_scanout(pPixmap)) {
 		if (pI830->use_drm_mode)
 		    pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
 		else {


More information about the xorg-commit mailing list