xf86-video-intel: 4 commits - src/sna/kgem.c src/sna/sna_display.c src/sna/sna_dri2.c src/sna/sna.h

Chris Wilson ickle at kemper.freedesktop.org
Sun Aug 3 12:56:41 PDT 2014


 src/sna/kgem.c        |    2 -
 src/sna/sna.h         |    2 +
 src/sna/sna_display.c |   26 ++++++++-----
 src/sna/sna_dri2.c    |   95 +++++++++++++++++++++++++++++++++-----------------
 4 files changed, 82 insertions(+), 43 deletions(-)

New commits:
commit 926631ee4148dbe2c53def01c98d568b80d46d53
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Aug 3 18:23:31 2014 +0100

    sna: Restore single CRTC flips
    
    CRTC flips depend upon having a proxy front buffer, so
    
    commit 33a0dd8f0b1e31e501825dc66f7ec2d85b55a7f4
    Author: Chris Wilson <chris at chris-wilson.co.uk>
    Date:   Tue Jul 29 09:11:01 2014 +0100
    
        sna/dri2: Also check for stale buffers before exchanges
    
    was false and disabling every other CRTC flip. However,
    
    commit 70868c7aa881b15b7478f7ee4543fde0268a4ba6
    Author: Chris Wilson <chris at chris-wilson.co.uk>
    Date:   Wed Jul 23 08:37:46 2014 +0100
    
        sna/dri2: Recreate buffer in reuse rather than force recreate
    
    was not the entire story and to prevent unnecessary confusion when
    multiple clients share the same front buffer, we have to force the
    recreation of the back. Do this inside the xchg routine to avoid the
    confusion first fixed by 70868c7aa881b15b7478f7ee4543fde0268a4ba6.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index 5d1c3da..83c6040 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -1714,14 +1714,13 @@ can_xchg(struct sna * sna,
 	}
 
 	pixmap = get_window_pixmap(win);
-	if (sna_pixmap_get_buffer(pixmap) != front) {
-		DBG(("%s: no, stale buffer, front->handle=%d, pixmap->front->handle=%d\n",
+	if (get_private(front)->pixmap != pixmap) {
+		DBG(("%s: no, DRI2 drawable is no longer attached, old pixmap=%ld, now pixmap=%ld\n",
 		     __FUNCTION__,
-		     get_private(front)->bo->handle,
-		     get_private(sna_pixmap_get_buffer(pixmap))->bo->handle));
+		     get_private(front)->pixmap->drawable.serialNumber,
+		     pixmap->drawable.serialNumber));
 		return false;
 	}
-	assert(get_private(front)->pixmap == pixmap);
 
 	DBG(("%s: window size: %dx%d, clip=(%d, %d), (%d, %d) x %d, pixmap size=%dx%d\n",
 	     __FUNCTION__,
@@ -1835,17 +1834,16 @@ can_xchg_crtc(struct sna *sna,
 	}
 
 	pixmap = get_window_pixmap(win);
-	if (sna_pixmap_get_buffer(pixmap) != front) {
-		DBG(("%s: no, stale buffer, front->handle=%d, pixmap->front->handle=%d\n",
-		     __FUNCTION__,
-		     get_private(front)->bo->handle,
-		     get_private(sna_pixmap_get_buffer(pixmap))->bo->handle));
+	if (pixmap != sna->front) {
+		DBG(("%s: no, not attached to front buffer\n", __FUNCTION__));
 		return false;
 	}
-	assert(get_private(front)->pixmap == pixmap);
 
-	if (pixmap != sna->front) {
-		DBG(("%s: no, not attached to front buffer\n", __FUNCTION__));
+	if (get_private(front)->pixmap != pixmap) {
+		DBG(("%s: no, DRI2 drawable is no longer attached, old pixmap=%ld, now pixmap=%ld\n",
+		     __FUNCTION__,
+		     get_private(front)->pixmap->drawable.serialNumber,
+		     pixmap->drawable.serialNumber));
 		return false;
 	}
 
@@ -1936,31 +1934,62 @@ sna_dri2_xchg(DrawablePtr draw, DRI2BufferPtr front, DRI2BufferPtr back)
 static void sna_dri2_xchg_crtc(struct sna *sna, DrawablePtr draw, xf86CrtcPtr crtc, DRI2BufferPtr front, DRI2BufferPtr back)
 {
 	WindowPtr win = (WindowPtr)draw;
-	PixmapPtr pixmap = get_window_pixmap(win);
+	DRI2Buffer2Ptr tmp;
+	struct kgem_bo *bo;
 
 	DBG(("%s: exchange front=%d/%d and back=%d/%d, win id=%lu, pixmap=%ld %dx%d\n",
-				__FUNCTION__,
-				get_private(front)->bo->handle, front->name,
-				get_private(back)->bo->handle, back->name,
-				win->drawable.id,
-				pixmap->drawable.serialNumber,
-				pixmap->drawable.width,
-				pixmap->drawable.height));
-
+	     __FUNCTION__,
+	     get_private(front)->bo->handle, front->name,
+	     get_private(back)->bo->handle, back->name,
+	     win->drawable.id,
+	     get_window_pixmap(win)->drawable.serialNumber,
+	     get_window_pixmap(win)->drawable.width,
+	     get_window_pixmap(win)->drawable.height));
+
+	DamageRegionAppend(&win->drawable, &win->clipList);
 	sna_shadow_set_crtc(sna, crtc, get_private(back)->bo);
 	DamageRegionProcessPending(&win->drawable);
 
-	front->attachment = DRI2BufferBackLeft;
-	get_private(front)->stale = true;
+	assert(dri2_window(win)->front == NULL);
 
-	back->attachment = DRI2BufferFrontLeft;
-	if (get_private(back)->proxy == NULL) {
-		get_private(back)->proxy = sna_dri2_reference_buffer(sna_pixmap_get_buffer(pixmap));
-		get_private(back)->pixmap = pixmap;
+	tmp = calloc(1, sizeof(*tmp) + sizeof(struct sna_dri2_private));
+	if (tmp == NULL) {
+		back->attachment = -1;
+		if (get_private(back)->proxy == NULL) {
+			get_private(back)->pixmap = get_window_pixmap(win);
+			get_private(back)->proxy = sna_dri2_reference_buffer(sna_pixmap_get_buffer(get_private(back)->pixmap));
+		}
+		dri2_window(win)->front = sna_dri2_reference_buffer(back);
+		return;
 	}
 
-	assert(dri2_window(win)->front == NULL);
-	dri2_window(win)->front = sna_dri2_reference_buffer(back);
+	*tmp = *back;
+	tmp->attachment = DRI2BufferFrontLeft;
+	tmp->driverPrivate = tmp + 1;
+	get_private(tmp)->refcnt = 1;
+	get_private(tmp)->bo = get_private(back)->bo;
+	get_private(tmp)->size = get_private(back)->size;
+	get_private(tmp)->pixmap = get_window_pixmap(win);
+	get_private(tmp)->proxy = sna_dri2_reference_buffer(sna_pixmap_get_buffer(get_private(tmp)->pixmap));
+	dri2_window(win)->front = tmp;
+
+	DBG(("%s: allocating new backbuffer\n", __FUNCTION__));
+	back->name = 0;
+	bo = kgem_create_2d(&sna->kgem,
+			    draw->width, draw->height, draw->bitsPerPixel,
+			    get_private(back)->bo->tiling,
+			    CREATE_SCANOUT);
+	if (bo != NULL) {
+		get_private(back)->bo = bo;
+		back->pitch = bo->pitch;
+		back->name = kgem_bo_flink(&sna->kgem, bo);
+	}
+	if (back->name == 0) {
+		if (bo != NULL)
+			kgem_bo_destroy(&sna->kgem, bo);
+		get_private(back)->bo = NULL;
+		back->attachment = -1;
+	}
 }
 
 static void frame_swap_complete(struct sna *sna,
@@ -2861,13 +2890,17 @@ sna_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 	assert(sna_pixmap_from_drawable(draw)->flush);
 
 	if (draw->type != DRAWABLE_PIXMAP) {
-		struct dri2_window *priv = dri2_window((WindowPtr)draw);
+		WindowPtr win = (WindowPtr)draw;
+		struct dri2_window *priv = dri2_window(win);
 		if (priv->front) {
 			assert(front == priv->front);
 			assert(get_private(priv->front)->refcnt > 1);
 			get_private(priv->front)->refcnt--;
 			priv->front = NULL;
 		}
+		if (win->clipList.extents.x2 <= win->clipList.extents.x1 ||
+		    win->clipList.extents.y2 <= win->clipList.extents.y1)
+			goto skip;
 	}
 
 	/* Drawable not displayed... just complete the swap */
commit 623fa61090fb288062d68257a5c72d8da1fbfc9c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Aug 3 18:08:12 2014 +0100

    sna: Rearrange showing cursors
    
    Just tidying and explaining why cursor show on a particular pipe may be
    skipped.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 9022db7..9906dfb 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -4215,6 +4215,7 @@ static struct sna_cursor *__sna_create_cursor(struct sna *sna, int size)
 
 	c->ref = 0;
 	c->serial = 0;
+	c->rotation = 0;
 	c->last_width = c->last_height = 0; /* all clear */
 
 	sna->cursor.num_stash--;
@@ -4286,8 +4287,10 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 
 	if (cursor == NULL) {
 		cursor = __sna_create_cursor(sna, 4*size*size);
-		if (cursor == NULL)
+		if (cursor == NULL) {
+			DBG(("%s: failed to allocate cursor\n", __FUNCTION__));
 			return NULL;
+		}
 	}
 
 	width = sna->cursor.ref->bits->width;
@@ -4412,7 +4415,7 @@ sna_show_cursors(ScrnInfoPtr scrn)
 	struct sna *sna = to_sna(scrn);
 	int sigio, c;
 
-	DBG(("%s\n", __FUNCTION__));
+	DBG(("%s: cursor?=%d\n", __FUNCTION__, sna->cursor.ref != NULL));
 	if (sna->cursor.ref == NULL)
 		return;
 
@@ -4427,18 +4430,21 @@ sna_show_cursors(ScrnInfoPtr scrn)
 		if (sna_crtc->bo == NULL)
 			continue;
 
-		if (!crtc->cursor_in_range)
-			continue;
-
-		if (sna_crtc->cursor)
+		if (!crtc->cursor_in_range) {
+			DBG(("%s: skipping cursor outside CRTC (pipe=%d)\n",
+			     __FUNCTION__, sna_crtc->pipe));
 			continue;
+		}
 
 		cursor = __sna_get_cursor(sna, crtc);
-		if (cursor == NULL)
+		if (cursor == NULL || sna_crtc->cursor == cursor) {
+			DBG(("%s: skipping cursor already show on CRTC (pipe=%d)\n",
+			     __FUNCTION__, sna_crtc->pipe));
 			continue;
+		}
 
-		DBG(("%s: CRTC:%d, handle->%d\n", __FUNCTION__,
-		     sna_crtc->id, cursor->handle));
+		DBG(("%s: CRTC pipe=%d, handle->%d\n", __FUNCTION__,
+		     sna_crtc->pipe, cursor->handle));
 
 		VG_CLEAR(arg);
 		arg.flags = DRM_MODE_CURSOR_BO;
@@ -6391,7 +6397,7 @@ sna_crtc_redisplay(xf86CrtcPtr crtc, RegionPtr region, struct kgem_bo *bo)
 	struct sna_pixmap *priv = sna_pixmap((PixmapPtr)draw);
 
 	DBG(("%s: crtc %d [pipe=%d], damage (%d, %d), (%d, %d) x %d\n",
-	     __FUNCTION__, sna_crtc->id, sna_crtc->pipe,
+	     __FUNCTION__, to_sna_crtc(crtc)->id, to_sna_crtc(crtc)->pipe,
 	     region->extents.x1, region->extents.y1,
 	     region->extents.x2, region->extents.y2,
 	     region_num_rects(region)));
commit 0b938573353aab70536d913b2d078181a3c9a1a4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Aug 3 18:08:02 2014 +0100

    sna: Add some paranoid asserts around get_window_pixmap()
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 206ecc9..498149d 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -188,6 +188,8 @@ static inline WindowPtr get_root_window(ScreenPtr screen)
 
 static inline PixmapPtr get_window_pixmap(WindowPtr window)
 {
+	assert(window);
+	assert(window->drawable.type != DRAWABLE_PIXMAP);
 	return fbGetWindowPixmap(window);
 }
 
commit 4de3f9bd79d8e42f9767c9fe44d553cfb749ac65
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Aug 3 07:33:35 2014 +0100

    sna: Relax restriction on fenced aperture check
    
    This is done upfront based on the fenced size within the batch, so we do
    not need to assume everything is fenced later on.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 17c6965..865291e 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -5330,8 +5330,6 @@ static bool aperture_check(struct kgem *kgem, unsigned num_pages)
 	DBG(("%s: num_pages=%d, holding %d pages in reserve, total aperture %d\n",
 	     __FUNCTION__, num_pages, reserve, kgem->aperture_total));
 	num_pages += reserve;
-	if (kgem->gen < 040 && num_pages > kgem->aperture_fenceable)
-		return false;
 
 	VG_CLEAR(aperture);
 	aperture.aper_available_size = kgem->aperture_total;


More information about the xorg-commit mailing list