xf86-video-intel: 5 commits - src/sna/gen5_render.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_render_inline.h

Chris Wilson ickle at kemper.freedesktop.org
Fri Nov 4 15:44:47 PDT 2011


 src/sna/gen5_render.c       |   15 +++++++++++++--
 src/sna/sna_accel.c         |   16 +++++++++++++++-
 src/sna/sna_blt.c           |   22 +++++++++++++++-------
 src/sna/sna_render_inline.h |    3 +++
 4 files changed, 46 insertions(+), 10 deletions(-)

New commits:
commit 8052c3904a1ac0308846ac13534c4c76bb96d5dd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Nov 4 21:14:23 2011 +0000

    sna: Drain the delayed timer after forcing a flush
    
    The goal is to remove a spurious wakeup when we have no work outstanding
    afterwards and so would end up prematurely disabling the timer.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 4505039..a51af18 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -8035,6 +8035,12 @@ static uint64_t read_timer(int fd)
 	(void)ret;
 }
 
+static void sna_accel_drain_timer(struct sna *sna, int id)
+{
+	if (sna->timer_active & (1<<id))
+		read_timer(sna->timer[id]);
+}
+
 static void _sna_accel_disarm_timer(struct sna *sna, int id)
 {
 	struct itimerspec to;
@@ -8056,8 +8062,10 @@ static Bool sna_accel_do_flush(struct sna *sna)
 	struct itimerspec to;
 	struct sna_pixmap *priv;
 
-	if (sna->kgem.flush_now)
+	if (sna->kgem.flush_now) {
+		sna_accel_drain_timer(sna, FLUSH_TIMER);
 		return TRUE;
+	}
 
 	return_if_timer_active(FLUSH_TIMER);
 
@@ -8136,6 +8144,7 @@ static void sna_accel_create_timers(struct sna *sna)
 }
 static Bool sna_accel_do_flush(struct sna *sna) { return sna_accel_scanout(sna) != NULL; }
 static Bool sna_accel_do_expire(struct sna *sna) { return sna->kgem.need_expire; }
+static void sna_accel_drain_timer(struct sna *sna, int id) { }
 static void _sna_accel_disarm_timer(struct sna *sna, int id) { }
 #endif
 
commit 112c61f6557c2337d5f1b25eb71d0dc9ada6ec89
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Nov 4 21:13:55 2011 +0000

    sna: Convert GXcopy with -1 to GXset
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 9ea3efb..6965cbd 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -142,8 +142,12 @@ static bool sna_blt_fill_init(struct sna *sna,
 
 	if (alu == GXclear)
 		pixel = 0;
-	if (alu == GXcopy && pixel == 0)
-		alu = GXclear;
+	else if (alu == GXcopy) {
+		if (pixel == 0)
+			alu = GXclear;
+		else if (pixel == -1)
+			alu = GXset;
+	}
 
 	blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch;
 	switch (bpp) {
@@ -287,7 +291,7 @@ static Bool sna_blt_copy_init(struct sna *sna,
 	if (blt->pitch[1] > MAXSHORT)
 		return FALSE;
 
-	blt->overwrites = alu == GXcopy || alu == GXclear;
+	blt->overwrites = alu == GXcopy || alu == GXclear || alu == GXset;
 	blt->br13 = (copy_ROP[alu] << 16) | blt->pitch[1];
 	switch (bpp) {
 	default: assert(0);
@@ -1538,7 +1542,7 @@ static Bool sna_blt_fill_box(struct sna *sna, uint8_t alu,
 
 	/* All too frequently one blt completely overwrites the previous */
 	if (kgem->nbatch >= 6 &&
-	    (alu == GXcopy || alu == GXclear) &&
+	    (alu == GXcopy || alu == GXclear || alu == GXset) &&
 	    kgem->batch[kgem->nbatch-6] == cmd &&
 	    kgem->batch[kgem->nbatch-4] == ((uint32_t)box[0].y1 << 16 | (uint16_t)box[0].x1) &&
 	    kgem->batch[kgem->nbatch-3] == ((uint32_t)box[0].y2 << 16 | (uint16_t)box[0].x2) &&
@@ -1609,8 +1613,12 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
 
 	if (alu == GXclear)
 		pixel = 0;
-	if (alu == GXcopy && pixel == 0)
-		alu = GXclear;
+	else if (alu == GXcopy) {
+		if (pixel == 0)
+			alu = GXclear;
+		else if (pixel == -1)
+			alu = GXset;
+	}
 
 	br13 |= 1<<31 | fill_ROP[alu] << 16;
 	switch (bpp) {
@@ -1769,7 +1777,7 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu,
 
 	/* Compare first box against a previous fill */
 	if (kgem->nbatch >= 6 &&
-	    (alu == GXcopy || alu == GXclear) &&
+	    (alu == GXcopy || alu == GXclear || alu == GXset) &&
 	    kgem->reloc[kgem->nreloc-1].target_handle == dst_bo->handle &&
 	    kgem->batch[kgem->nbatch-6] == ((cmd & ~XY_SRC_COPY_BLT_CMD) | XY_COLOR_BLT) &&
 	    kgem->batch[kgem->nbatch-4] == ((uint32_t)(box->y1 + dst_dy) << 16 | (uint16_t)(box->x1 + dst_dx)) &&
commit 573b23c6b618af808d3236395bbf4f4993b406e5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Nov 4 15:57:24 2011 +0000

    sna: Add some asserts to detect buffer overflow.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h
index f05063d..8ad755c 100644
--- a/src/sna/sna_render_inline.h
+++ b/src/sna/sna_render_inline.h
@@ -23,11 +23,13 @@ static inline int vertex_space(struct sna *sna)
 }
 static inline void vertex_emit(struct sna *sna, float v)
 {
+	assert(sna->render.vertex_used < ARRAY_SIZE(sna->render.vertex_data));
 	sna->render.vertex_data[sna->render.vertex_used++] = v;
 }
 static inline void vertex_emit_2s(struct sna *sna, int16_t x, int16_t y)
 {
 	int16_t *v = (int16_t *)&sna->render.vertex_data[sna->render.vertex_used++];
+	assert(sna->render.vertex_used <= ARRAY_SIZE(sna->render.vertex_data));
 	v[0] = x;
 	v[1] = y;
 }
@@ -50,6 +52,7 @@ static inline int batch_space(struct sna *sna)
 
 static inline void batch_emit(struct sna *sna, uint32_t dword)
 {
+	assert(sna->kgem.nbatch < sna->kgem.surface);
 	sna->kgem.batch[sna->kgem.nbatch++] = dword;
 }
 
commit 4ba55c3d110ba51400a72da7d4f4c62efcea1335
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Nov 4 15:55:15 2011 +0000

    sna/gen5: Prefer using the BLT for many solid fills
    
    Even if it means incurring a context switch, the BLT unit is
    significantly faster so long as we do enough fills. And there is the
    catch ;-)
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 3926adc..28c7a07 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -51,6 +51,8 @@
 
 #define NO_COMPOSITE_SPANS 0
 
+#define PREFER_BLT_FILL 1
+
 #define DBG_NO_STATE_CACHE 0
 #define DBG_NO_SURFACE_CACHE 0
 
@@ -2643,6 +2645,15 @@ gen5_fill_bind_surfaces(struct sna *sna,
 	gen5_emit_state(sna, op, offset);
 }
 
+static inline bool prefer_blt_fill(struct sna *sna)
+{
+#if PREFER_BLT_FILL
+	return true;
+#else
+	return sna->kgem.mode != KGEM_RENDER;
+#endif
+}
+
 static Bool
 gen5_render_fill_boxes(struct sna *sna,
 		       CARD8 op,
@@ -2663,7 +2674,7 @@ gen5_render_fill_boxes(struct sna *sna,
 		return FALSE;
 	}
 
-	if (sna->kgem.mode != KGEM_RENDER ||
+	if (prefer_blt_fill(sna) ||
 	    dst->drawable.width > 8192 ||
 	    dst->drawable.height > 8192 ||
 	    !gen5_check_dst_format(format)) {
@@ -2869,7 +2880,7 @@ gen5_render_fill(struct sna *sna, uint8_t alu,
 {
 	DBG(("%s(alu=%d, color=%08x)\n", __FUNCTION__, alu, color));
 
-	if (sna->kgem.mode != KGEM_RENDER &&
+	if (prefer_blt_fill(sna) &&
 	    sna_blt_fill(sna, alu,
 			 dst_bo, dst->drawable.bitsPerPixel,
 			 color,
commit 703cf8abdbcda783e2bb0ceb423909ee8ca98176
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Nov 4 15:24:57 2011 +0000

    sna: Add earlier guards against to wedged to sna_glyph_blt
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 48d3d6a..4505039 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -6829,6 +6829,11 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 	DBG(("%s (%d, %d) x %d, transparent? %d, alu=%d\n",
 	     __FUNCTION__, _x, _y, _n, transparent, rop));
 
+	if (wedged(sna)) {
+		DBG(("%s -- fallback, wedged\n", __FUNCTION__));
+		return false;
+	}
+
 	if (!sna_drawable_use_gpu_bo(drawable, &clip->extents, &damage))
 		return false;
 


More information about the xorg-commit mailing list