xf86-video-intel: 10 commits - src/intel.h src/sna/gen2_render.c src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna.h src/sna/sna_render.h

Chris Wilson ickle at kemper.freedesktop.org
Thu Oct 13 09:47:43 PDT 2011


 src/intel.h           |    2 
 src/sna/gen2_render.c |  138 +++++++++++++++++++++++++++++---------
 src/sna/kgem.c        |    6 -
 src/sna/sna.h         |    1 
 src/sna/sna_accel.c   |  177 +++++++++++++++++++++++++++-----------------------
 src/sna/sna_blt.c     |    9 ++
 src/sna/sna_render.h  |    1 
 7 files changed, 214 insertions(+), 120 deletions(-)

New commits:
commit b7fd6906c41e328649b97e16c42848a39f6e48f8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 13 17:46:48 2011 +0100

    sna/accel: Actually apply the clip to the glyph extents
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=41718
    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 99b0cef..4926499 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3339,6 +3339,9 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc,
 	if (box_empty(&box))
 		return;
 	translate_box(&box, drawable);
+	clip_box(&box, gc);
+	if (box_empty(&box))
+		return;
 
 	DBG(("%s: extents(%d, %d), (%d, %d)\n",
 	     __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
@@ -3392,6 +3395,9 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc,
 	if (box_empty(&box))
 		return;
 	translate_box(&box, drawable);
+	clip_box(&box, gc);
+	if (box_empty(&box))
+		return;
 
 	DBG(("%s: extents(%d, %d), (%d, %d)\n",
 	     __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
commit eb5f86b78181b174664aaa9bc689db5421b7e7bd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 13 17:32:54 2011 +0100

    sna/accel: Correctly offset the damage intersection for glyph runs
    
    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 4d41881..99b0cef 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3179,6 +3179,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 
 	region_set(&clip, extents);
 	region_maybe_clip(&clip, gc->pCompositeClip);
+	if (RegionNotEmpty(&clip))
+		return false;
 
 	/* XXX loop over clips using SETUP_CLIP? */
 	if (clip.data != NULL) {
@@ -3193,6 +3195,11 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 	x += drawable->x + dx;
 	y += drawable->y + dy;
 
+	clip.extents.x1 += dx;
+	clip.extents.x2 += dx;
+	clip.extents.y1 += dy;
+	clip.extents.y2 += dy;
+
 	kgem_set_mode(&sna->kgem, KGEM_BLT);
 	if (!kgem_check_batch(&sna->kgem, 16) ||
 	    !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL) ||
@@ -3209,8 +3216,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 		b[1] >>= 2;
 	}
 	b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16;
-	b[2] = (dy + clip.extents.y1) << 16 | (dx + clip.extents.x1);
-	b[3] = (dy + clip.extents.y2) << 16 | (dx + clip.extents.x2);
+	b[2] = clip.extents.y1 << 16 | clip.extents.x1;
+	b[3] = clip.extents.y2 << 16 | clip.extents.x2;
 	b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4,
 			      priv->gpu_bo,
 			      I915_GEM_DOMAIN_RENDER << 16 |
@@ -3255,8 +3262,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 				b[1] >>= 2;
 			}
 			b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16;
-			b[2] = (dy + clip.extents.y1) << 16 | (dx + clip.extents.x1);
-			b[3] = (dy + clip.extents.y2) << 16 | (dx + clip.extents.x2);
+			b[2] = clip.extents.y1 << 16 | clip.extents.x1;
+			b[3] = clip.extents.y2 << 16 | clip.extents.x2;
 			b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4,
 					      priv->gpu_bo,
 					      I915_GEM_DOMAIN_RENDER << 16 |
@@ -3297,7 +3304,7 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 			r.y1 = y1;
 			r.x2 = x1 + w;
 			r.y2 = y1 + h;
-			if (box_intersect(&r, extents))
+			if (box_intersect(&r, &clip.extents))
 				sna_damage_add_box(damage, &r);
 		}
 skip:
commit a4766026ad0aa14283e35598d33f13d311cc029b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 13 17:32:30 2011 +0100

    sna/accel: Check for reloc overflow when adding a new glyph run
    
    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 f40c132..4d41881 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3195,7 +3195,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 
 	kgem_set_mode(&sna->kgem, KGEM_BLT);
 	if (!kgem_check_batch(&sna->kgem, 16) ||
-	    !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) {
+	    !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL) ||
+	    !kgem_check_reloc(&sna->kgem, 1)) {
 		_kgem_submit(&sna->kgem);
 		_kgem_set_mode(&sna->kgem, KGEM_BLT);
 	}
commit b10850af4125b8dbc36d13fa83f1dcce13ac6684
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 13 17:09:25 2011 +0100

    sna/blt: Check for reloc overflow when initialising solid fills
    
    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 a8d39bd..1375a7a 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -152,7 +152,14 @@ static bool sna_blt_fill_init(struct sna *sna,
 	if (sna->blt_state.fill_bo != bo->handle ||
 	    sna->blt_state.fill_pixel != pixel)
 	{
-		uint32_t *b = kgem->batch + kgem->nbatch;
+		uint32_t *b;
+
+		if (kgem->nreloc + 1 > KGEM_RELOC_SIZE(kgem)) {
+			_kgem_submit(kgem);
+			_kgem_set_mode(kgem, KGEM_BLT);
+		}
+
+		b = kgem->batch + kgem->nbatch;
 		b[0] = blt->cmd;
 		b[1] = blt->br13;
 		b[2] = 0;
commit d5242565ef17cb4265177338df5b564b960e3692
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 12 21:14:43 2011 +0100

    sna/gen2: Trim some surplus state commands
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index a7ace88..d862235 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -310,30 +310,12 @@ gen2_emit_texture(struct sna *sna,
 	OUT_BATCH((channel->bo->pitch / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D);
 	OUT_BATCH(filter);
 	OUT_BATCH(0);	/* default color */
+
 	OUT_BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) |
 		  ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL |
 		  texcoordtype |
 		  ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) |
 		  ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode));
-	/* map texel stream */
-	OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD);
-	if (unit == 0)
-		OUT_BATCH(TEXBIND_SET0(TEXCOORDSRC_VTXSET_0) |
-			  TEXBIND_SET1(TEXCOORDSRC_KEEP) |
-			  TEXBIND_SET2(TEXCOORDSRC_KEEP) |
-			  TEXBIND_SET3(TEXCOORDSRC_KEEP));
-	else
-		OUT_BATCH(TEXBIND_SET0(TEXCOORDSRC_VTXSET_0) |
-			  TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
-			  TEXBIND_SET2(TEXCOORDSRC_KEEP) |
-			  TEXBIND_SET3(TEXCOORDSRC_KEEP));
-	OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
-		  (unit << 16) |
-		  DISABLE_TEX_STREAM_BUMP |
-		  ENABLE_TEX_STREAM_COORD_SET |
-		  TEX_STREAM_COORD_SET(unit) |
-		  ENABLE_TEX_STREAM_MAP_IDX |
-		  TEX_STREAM_MAP_IDX(unit));
 }
 
 static void
@@ -640,13 +622,14 @@ static void gen2_enable_logic_op(struct sna *sna, int op)
 static void gen2_emit_composite_state(struct sna *sna,
 				      const struct sna_composite_op *op)
 {
-	uint32_t texcoordfmt;
+	uint32_t texcoordfmt, v, unwind;
 	uint32_t cblend, ablend;
 	int tex;
 
 	gen2_get_batch(sna);
 	gen2_emit_target(sna, op);
 
+	unwind = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
 		  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
 	OUT_BATCH((!op->src.is_solid + (op->mask.bo != NULL)) << 12);
@@ -656,14 +639,27 @@ static void gen2_emit_composite_state(struct sna *sna,
 				      op->has_component_alpha,
 				      op->dst.format) |
 		  S8_ENABLE_COLOR_BUFFER_WRITE);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1,
+		    sna->kgem.batch + unwind,
+		    4 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = unwind;
+	else
+		sna->render_state.gen2.ls1 = unwind;
 
 	gen2_disable_logic_op(sna);
 
 	gen2_get_blend_factors(op, op->op, &cblend, &ablend);
+	unwind = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
 		  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
 	OUT_BATCH(cblend);
 	OUT_BATCH(ablend);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1,
+		    sna->kgem.batch + unwind + 1,
+		    2 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = unwind;
+	else
+		sna->render_state.gen2.ls2 = unwind;
 
 	tex = texcoordfmt = 0;
 	if (!op->src.is_solid) {
@@ -683,7 +679,12 @@ static void gen2_emit_composite_state(struct sna *sna,
 			texcoordfmt |= TEXCOORDFMT_3D << (2*tex);
 		gen2_emit_texture(sna, &op->mask, tex++);
 	}
-	OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD | texcoordfmt);
+
+	v = _3DSTATE_VERTEX_FORMAT_2_CMD | texcoordfmt;
+	if (sna->render_state.gen2.vft != v) {
+		OUT_BATCH(v);
+		sna->render_state.gen2.vft = v;
+	}
 }
 
 static inline void
@@ -871,12 +872,14 @@ static void gen2_magic_ca_pass(struct sna *sna,
 	OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |
 		  gen2_get_blend_cntl(PictOpAdd, TRUE, op->dst.format) |
 		  S8_ENABLE_COLOR_BUFFER_WRITE);
+	sna->render_state.gen2.ls1 = 0;
 
 	gen2_get_blend_factors(op, PictOpAdd, &cblend, &ablend);
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
 		  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
 	OUT_BATCH(cblend);
 	OUT_BATCH(ablend);
+	sna->render_state.gen2.ls2 = 0;
 
 	memcpy(sna->kgem.batch + sna->kgem.nbatch,
 	       sna->kgem.batch + sna->render_state.gen2.vertex_offset,
@@ -1525,6 +1528,7 @@ gen2_emit_spans_pipeline(struct sna *sna,
 			 const struct sna_composite_spans_op *op)
 {
 	uint32_t cblend, ablend;
+	uint32_t unwind;
 
 	cblend =
 		TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_MODULATE |
@@ -1555,18 +1559,28 @@ gen2_emit_spans_pipeline(struct sna *sna,
 			ablend |= TB0A_ARG2_SEL_TEXEL0;
 	}
 
+	unwind = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
 		  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
 	OUT_BATCH(cblend);
 	OUT_BATCH(ablend);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1,
+		    sna->kgem.batch + unwind + 1,
+		    2 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = unwind;
+	else
+		sna->render_state.gen2.ls2 = unwind;
 }
 
 static void gen2_emit_composite_spans_state(struct sna *sna,
 					    const struct sna_composite_spans_op *op)
 {
+	uint32_t unwind;
+
 	gen2_get_batch(sna);
 	gen2_emit_target(sna, &op->base);
 
+	unwind = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
 		  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
 	OUT_BATCH(!op->base.src.is_solid << 12);
@@ -1574,6 +1588,12 @@ static void gen2_emit_composite_spans_state(struct sna *sna,
 	OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |
 		  gen2_get_blend_cntl(op->base.op, FALSE, op->base.dst.format) |
 		  S8_ENABLE_COLOR_BUFFER_WRITE);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1,
+		    sna->kgem.batch + unwind,
+		    4 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = unwind;
+	else
+		sna->render_state.gen2.ls1 = unwind;
 
 	gen2_disable_logic_op(sna);
 	gen2_emit_spans_pipeline(sna, op);
@@ -1582,8 +1602,12 @@ static void gen2_emit_composite_spans_state(struct sna *sna,
 		OUT_BATCH(_3DSTATE_DFLT_SPECULAR_CMD);
 		OUT_BATCH(op->base.src.u.gen2.pixel);
 	} else {
-		OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD |
-			  (op->base.src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_3D));
+		uint32_t v =_3DSTATE_VERTEX_FORMAT_2_CMD |
+			(op->base.src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_3D);
+		if (sna->render_state.gen2.vft != v) {
+			OUT_BATCH(v);
+			sna->render_state.gen2.vft = v;
+		}
 		gen2_emit_texture(sna, &op->base.src, 0);
 	}
 }
@@ -1761,8 +1785,9 @@ cleanup_dst:
 static void
 gen2_emit_fill_pipeline(struct sna *sna, const struct sna_composite_op *op)
 {
-	uint32_t blend;
+	uint32_t blend, unwind;
 
+	unwind = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
 		  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
 
@@ -1776,15 +1801,25 @@ gen2_emit_fill_pipeline(struct sna *sna, const struct sna_composite_op *op)
 	OUT_BATCH(TB0A_RESULT_SCALE_1X | TB0A_OP_ARG1 |
 		  TB0A_ARG1_SEL_DIFFUSE |
 		  TB0A_OUTPUT_WRITE_CURRENT);
+
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1,
+		    sna->kgem.batch + unwind + 1,
+		    2 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = unwind;
+	else
+		sna->render_state.gen2.ls2 = unwind;
 }
 
 static void gen2_emit_fill_composite_state(struct sna *sna,
 					   const struct sna_composite_op *op,
 					   uint32_t pixel)
 {
+	uint32_t ls1;
+
 	gen2_get_batch(sna);
 	gen2_emit_target(sna, op);
 
+	ls1 = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
 		  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
 	OUT_BATCH(0);
@@ -1792,6 +1827,12 @@ static void gen2_emit_fill_composite_state(struct sna *sna,
 	OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |
 		  gen2_get_blend_cntl(op->op, FALSE, op->dst.format) |
 		  S8_ENABLE_COLOR_BUFFER_WRITE);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1,
+		    sna->kgem.batch + ls1,
+		    4 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = ls1;
+	else
+		sna->render_state.gen2.ls1 = ls1;
 
 	gen2_emit_fill_pipeline(sna, op);
 
@@ -1934,17 +1975,23 @@ gen2_render_fill_boxes(struct sna *sna,
 static void gen2_emit_fill_state(struct sna *sna,
 				 const struct sna_composite_op *op)
 {
+	uint32_t ls1;
+
 	gen2_get_batch(sna);
 	gen2_emit_target(sna, op);
 
+	ls1 = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
-		  I1_LOAD_S(2) |
-		  I1_LOAD_S(3) |
-		  I1_LOAD_S(8) |
-		  2);
+		  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
 	OUT_BATCH(0);
 	OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY);
 	OUT_BATCH(S8_ENABLE_COLOR_BUFFER_WRITE);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1,
+		    sna->kgem.batch + ls1,
+		    4 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = ls1;
+	else
+		sna->render_state.gen2.ls1 = ls1;
 
 	gen2_enable_logic_op(sna, op->op);
 	gen2_emit_fill_pipeline(sna, op);
@@ -2131,8 +2178,9 @@ gen2_render_copy_setup_source(struct sna_composite_channel *channel,
 static void
 gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op)
 {
-	uint32_t blend;
+	uint32_t blend, unwind;
 
+	unwind = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
 		  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
 
@@ -2153,26 +2201,44 @@ gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op)
 	else
 		blend |= TB0A_ARG1_SEL_TEXEL0;
 	OUT_BATCH(blend);
+
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1,
+		    sna->kgem.batch + unwind + 1,
+		    2 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = unwind;
+	else
+		sna->render_state.gen2.ls2 = unwind;
 }
 
 static void gen2_emit_copy_state(struct sna *sna, const struct sna_composite_op *op)
 {
+	uint32_t ls1, v;
+
 	gen2_get_batch(sna);
 	gen2_emit_target(sna, op);
 
+	ls1 = sna->kgem.nbatch;
 	OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
-		  I1_LOAD_S(2) |
-		  I1_LOAD_S(3) |
-		  I1_LOAD_S(8) |
-		  2);
+		  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
 	OUT_BATCH(1<<12);
 	OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY);
 	OUT_BATCH(S8_ENABLE_COLOR_BUFFER_WRITE);
+	if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1,
+		    sna->kgem.batch + ls1,
+		    4 * sizeof(uint32_t)) == 0)
+		sna->kgem.nbatch = ls1;
+	else
+		sna->render_state.gen2.ls1 = ls1;
 
 	gen2_enable_logic_op(sna, op->op);
 	gen2_emit_copy_pipeline(sna, op);
 
-	OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD | TEXCOORDFMT_2D);
+	v = _3DSTATE_VERTEX_FORMAT_2_CMD | TEXCOORDFMT_2D;
+	if (sna->render_state.gen2.vft != v) {
+		OUT_BATCH(v);
+		sna->render_state.gen2.vft = v;
+	}
+
 	gen2_emit_texture(sna, &op->src, 0);
 }
 
@@ -2386,6 +2452,10 @@ gen2_render_reset(struct sna *sna)
 	sna->render_state.gen2.logic_op_enabled = FALSE;
 	sna->render_state.gen2.vertex_offset = 0;
 	sna->render_state.gen2.target = 0;
+
+	sna->render_state.gen2.ls1 = 0;
+	sna->render_state.gen2.ls2 = 0;
+	sna->render_state.gen2.vft = 0;
 }
 
 static void
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index 9e658a8..223cae6 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -269,6 +269,7 @@ struct gen2_render_state {
 	uint32_t target;
 	Bool need_invariant;
 	Bool logic_op_enabled;
+	uint32_t ls1, ls2, vft;
 	uint16_t vertex_offset;
 };
 
commit 7c5020532335c07d9b0f6cecb0b004de4af6d273
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 12 20:36:53 2011 +0100

    Remove vestigial includes from DRI1
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel.h b/src/intel.h
index 2f72830..4acd0f2 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -65,9 +65,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <pciaccess.h>
 
 #include "xf86drm.h"
-#include "sarea.h"
 #define _XF86DRI_SERVER_
-#include "dri.h"
 #include "dri2.h"
 #include "intel_bufmgr.h"
 #include "i915_drm.h"
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 189e3d4..e27c333 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -60,7 +60,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "xf86drmMode.h"
 
 #define _XF86DRI_SERVER_
-#include "dri.h"
 #include "dri2.h"
 #include "i915_drm.h"
 
commit b6b3bb9b5e56949cbd9189d9857ffa1ff46377fd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 20 19:41:03 2011 +0100

    sna: compare against the right array of cache buckets
    
    Fortunately harmless today as there are the same number of
    inactive/active buckets.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index ffcfd9f..15ddd7a 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -309,15 +309,15 @@ static struct list *active(struct kgem *kgem,
 			     int size)
 {
 	uint32_t order = __fls(size / PAGE_SIZE);
-	if (order >= ARRAY_SIZE(kgem->inactive))
-		order = ARRAY_SIZE(kgem->inactive)-1;
+	if (order >= ARRAY_SIZE(kgem->active))
+		order = ARRAY_SIZE(kgem->active)-1;
 	return &kgem->active[order];
 }
 
 static size_t
 agp_aperture_size(struct pci_device *dev, int gen)
 {
-	return dev->regions[gen < 30 ? 0 :2].size;
+	return dev->regions[gen < 30 ? 0 : 2].size;
 }
 
 void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
commit 1f70095837a30d6a88b9e313d3583d38ea55221d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 11 16:06:31 2011 +0100

    sna: And free the clip after creation for PolySegments
    
    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 599f070..f40c132 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2330,8 +2330,10 @@ sna_poly_segment_blt(DrawablePtr drawable,
 		return success;
 	}
 
-	if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel))
+	if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) {
+		RegionUninit(&clip);
 		return FALSE;
+	}
 
 	get_drawable_deltas(drawable, pixmap, &dx, &dy);
 	while (n--) {
@@ -2388,6 +2390,7 @@ sna_poly_segment_blt(DrawablePtr drawable,
 		seg++;
 	}
 	fill.done(sna, &fill);
+	RegionUninit(&clip);
 	return TRUE;
 }
 
commit 92f4d978c8b1f5e9a6cf3affa15d90bfb3d4e7b9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 11 15:52:13 2011 +0100

    sna: More micro-optimisation of messing around with clip regions
    
    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 88c21c5..599f070 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -63,6 +63,18 @@
 
 DevPrivateKeyRec sna_pixmap_index;
 
+static inline void region_set(RegionRec *r, const BoxRec *b)
+{
+	r->extents = *b;
+	r->data = NULL;
+}
+
+static inline void region_maybe_clip(RegionRec *r, RegionRec *clip)
+{
+	if (clip && clip->data)
+		RegionIntersect(r, r, clip);
+}
+
 #define PM_IS_SOLID(_draw, _pm) \
 	(((_pm) & FbFullMask((_draw)->depth)) == FbFullMask((_draw)->depth))
 
@@ -1118,7 +1130,7 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth,
 	if (box_empty(&box))
 		return;
 
-	RegionInit(&region, &box, 1);
+	region_set(&region, &box);
 
 	clip = fbGetCompositeClip(gc);
 	if (clip) {
@@ -1451,8 +1463,7 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 		box.y1 = dst_y + dst->y;
 		box.x2 = box.x1 + width;
 		box.y2 = box.y1 + height;
-		RegionInit(&region, &box, 1);
-
+		region_set(&region, &box);
 		if (gc->pCompositeClip)
 			RegionIntersect(&region, &region, gc->pCompositeClip);
 
@@ -1517,12 +1528,12 @@ static Bool
 sna_fill_spans_blt(DrawablePtr drawable,
 		   struct kgem_bo *bo, struct sna_damage **damage,
 		   GCPtr gc, int n,
-		   DDXPointPtr pt, int *width, int sorted)
+		   DDXPointPtr pt, int *width, int sorted,
+		   const BoxRec *extents)
 {
 	struct sna *sna = to_sna_from_drawable(drawable);
 	PixmapPtr pixmap = get_drawable_pixmap(drawable);
-	BoxPtr extents;
-	int nclip = REGION_NUM_RECTS(gc->pCompositeClip);
+	RegionRec clip;
 	int need_translation = !gc->miTranslate;
 	int16_t dx, dy;
 	struct sna_fill_op fill;
@@ -1530,10 +1541,12 @@ sna_fill_spans_blt(DrawablePtr drawable,
 	if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel))
 		return false;
 
-	extents = REGION_EXTENTS(gc->screen, gc->pCompositeClip);
+	region_set(&clip, extents);
+	region_maybe_clip(&clip, gc->pCompositeClip);
+
 	DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n",
 	     __FUNCTION__,
-	     REGION_NUM_RECTS(gc->pCompositeClip),
+	     REGION_NUM_RECTS(&clip),
 	     extents->x1, extents->y1, extents->x2, extents->y2,
 	     n, pt->x, pt->y));
 
@@ -1565,7 +1578,7 @@ sna_fill_spans_blt(DrawablePtr drawable,
 			continue;
 
 		y += dy;
-		if (nclip == 1) {
+		if (clip.data == NULL) {
 			X1 += dx;
 			X2 += dx;
 			assert(X1 >= 0 && X2 <= pixmap->drawable.width);
@@ -1584,12 +1597,12 @@ sna_fill_spans_blt(DrawablePtr drawable,
 				}
 			}
 		} else {
-			int nc = nclip;
-			BoxPtr clip = REGION_RECTS(gc->pCompositeClip);
+			int nc = clip.data->numRects;
+			const BoxRec *b = RegionBoxptr(&clip);
 			while (nc--) {
-				if (clip->y1 <= y && y < clip->y2) {
-					int x1 = clip->x1;
-					int x2 = clip->x2;
+				if (b->y1 <= y && y < b->y2) {
+					int x1 = b->x1;
+					int x2 = b->x2;
 
 					if (x1 < X1)
 						x1 = X1;
@@ -1618,11 +1631,12 @@ sna_fill_spans_blt(DrawablePtr drawable,
 						}
 					}
 				}
-				clip++;
+				b++;
 			}
 		}
 	}
 	fill.done(sna, &fill);
+	RegionUninit(&clip);
 	return TRUE;
 }
 
@@ -1744,14 +1758,16 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n,
 		    sna_fill_spans_blt(drawable,
 				       priv->gpu_bo,
 				       priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, &extents),
-				       gc, n, pt, width, sorted))
+				       gc, n, pt, width, sorted,
+				       &extents))
 			return;
 
 		if (sna_drawable_use_cpu_bo(drawable, &extents) &&
 		    sna_fill_spans_blt(drawable,
 				       priv->cpu_bo,
 				       reduce_damage(drawable, &priv->cpu_damage, &extents),
-				       gc, n, pt, width, sorted))
+				       gc, n, pt, width, sorted,
+				       &extents))
 			return;
 	} else if (gc->fillStyle == FillTiled) {
 		xRectangle *rect;
@@ -1778,9 +1794,8 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n,
 
 fallback:
 	DBG(("%s: fallback\n", __FUNCTION__));
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -1804,9 +1819,8 @@ sna_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
 	DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__,
 	     extents.x1, extents.y1, extents.x2, extents.y2));
 
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -1834,9 +1848,8 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 	box.x2 = box.x1 + w;
 	box.y2 = box.y1 + h;
 
-	RegionInit(&region, &box, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &box);
+	region_maybe_clip(&region, gc->pCompositeClip);
 
 	sna_drawable_move_region_to_cpu(dst, &region, true);
 	RegionTranslate(&region,
@@ -1977,9 +1990,8 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc,
 
 fallback:
 	DBG(("%s: fallback\n", __FUNCTION__));
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -2220,9 +2232,8 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc,
 
 fallback:
 	DBG(("%s: fallback\n", __FUNCTION__));
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -2261,9 +2272,8 @@ sna_poly_segment_blt(DrawablePtr drawable,
 
 	DBG(("%s: alu=%d, fg=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel));
 
-	RegionInit(&clip, (BoxPtr)extents, 1);
-	if (gc->pCompositeClip && gc->pCompositeClip->data)
-		RegionIntersect(&clip, &clip, gc->pCompositeClip);
+	region_set(&clip, extents);
+	region_maybe_clip(&clip, gc->pCompositeClip);
 
 	if (n == 1 && clip.data == NULL) {
 		BoxRec r;
@@ -2524,9 +2534,8 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg)
 
 fallback:
 	DBG(("%s: fallback\n", __FUNCTION__));
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -2628,9 +2637,8 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc)
 	}
 
 fallback:
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -2728,7 +2736,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable,
 			r.y2 = bound(r.y1, rect->height);
 			rect++;
 
-			RegionInit(&region, &r, 1);
+			region_set(&region, &r);
 			RegionIntersect(&region, &region, clip);
 
 			nbox = REGION_NUM_RECTS(&region);
@@ -2836,7 +2844,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable,
 				r.y2 = bound(r.y1, rect->height);
 				rect++;
 
-				RegionInit(&region, &r, 1);
+				region_set(&region, &r);
 				RegionIntersect(&region, &region, clip);
 
 				nbox = REGION_NUM_RECTS(&region);
@@ -2939,7 +2947,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable,
 				r.y2 = bound(r.y1, rect->height);
 				rect++;
 
-				RegionInit(&region, &r, 1);
+				region_set(&region, &r);
 				RegionIntersect(&region, &region, clip);
 
 				nbox = REGION_NUM_RECTS(&region);
@@ -3097,9 +3105,8 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect)
 fallback:
 	DBG(("%s: fallback (%d, %d), (%d, %d)\n", __FUNCTION__,
 	     extents.x1, extents.y1, extents.x2, extents.y2));
-	RegionInit(&region, &extents, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &extents);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region)) {
 		DBG(("%s: nothing to do, all clipped\n", __FUNCTION__));
 		return;
@@ -3167,9 +3174,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 	if (priv->gpu_bo->tiling == I915_TILING_Y)
 		return false;
 
-	RegionInit(&clip, (BoxPtr)extents, 1);
-	if (gc->pCompositeClip && gc->pCompositeClip->data)
-		RegionIntersect(&clip, &clip, gc->pCompositeClip);
+	region_set(&clip, extents);
+	region_maybe_clip(&clip, gc->pCompositeClip);
 
 	/* XXX loop over clips using SETUP_CLIP? */
 	if (clip.data != NULL) {
@@ -3339,9 +3345,8 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc,
 		return;
 
 fallback:
-	RegionInit(&region, &box, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &box);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -3390,13 +3395,11 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc,
 
 	if (sna_drawable_use_gpu_bo(drawable, &box) &&
 	    sna_glyph_blt(drawable, gc, x, y, n, info, base, true, &box))
-
 		return;
 
 fallback:
-	RegionInit(&region, &box, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &box);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -3437,9 +3440,8 @@ sna_push_pixels(GCPtr gc, PixmapPtr bitmap, DrawablePtr drawable,
 	DBG(("%s: extents(%d, %d), (%d, %d)\n",
 	     __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
 
-	RegionInit(&region, &box, 1);
-	if (gc->pCompositeClip)
-		RegionIntersect(&region, &region, gc->pCompositeClip);
+	region_set(&region, &box);
+	region_maybe_clip(&region, gc->pCompositeClip);
 	if (!RegionNotEmpty(&region))
 		return;
 
@@ -3537,7 +3539,7 @@ sna_get_image(DrawablePtr drawable,
 	extents.y1 = y + drawable->y;
 	extents.x2 = extents.x1 + w;
 	extents.y2 = extents.y1 + h;
-	RegionInit(&region, &extents, 1);
+	region_set(&region, &extents);
 
 	sna_drawable_move_region_to_cpu(drawable, &region, false);
 	fbGetImage(drawable, x, y, w, h, format, mask, dst);
@@ -3555,7 +3557,7 @@ sna_get_spans(DrawablePtr drawable, int wMax,
 	if (sna_spans_extents(drawable, NULL, n, pt, width, &extents))
 		return;
 
-	RegionInit(&region, &extents, 1);
+	region_set(&region, &extents);
 	sna_drawable_move_region_to_cpu(drawable, &region, false);
 	RegionUninit(&region);
 
commit 57151f654752ed64716358ecb5e9217b59784da8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 11 15:23:17 2011 +0100

    sna: Micro-optimise checking for singular clip boxes
    
    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 227123d..88c21c5 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -405,7 +405,7 @@ region_subsumes_drawable(RegionPtr region, DrawablePtr drawable)
 {
 	const BoxRec *extents;
 
-	if (REGION_NUM_RECTS(region) != 1)
+	if (region->data)
 		return false;
 
 	extents = RegionExtents(region);
@@ -2658,8 +2658,8 @@ sna_poly_fill_rect_blt(DrawablePtr drawable,
 	DBG(("%s x %d [(%d, %d)+(%d, %d)...]\n",
 	     __FUNCTION__, n, rect->x, rect->y, rect->width, rect->height));
 
-	if (n == 1 && REGION_NUM_RECTS(clip) == 1) {
-		BoxPtr box = REGION_RECTS(clip);
+	if (n == 1 && clip->data == NULL) {
+		BoxPtr box = &clip->extents;
 		BoxRec r;
 		bool success = true;
 
@@ -2691,8 +2691,8 @@ sna_poly_fill_rect_blt(DrawablePtr drawable,
 	}
 
 	get_drawable_deltas(drawable, pixmap, &dx, &dy);
-	if (REGION_NUM_RECTS(clip) == 1) {
-		BoxPtr box = REGION_RECTS(clip);
+	if (clip->data == NULL) {
+		BoxPtr box = &clip->extents;
 		while (n--) {
 			BoxRec r;
 
@@ -2799,8 +2799,8 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable,
 			return FALSE;
 		}
 
-		if (REGION_NUM_RECTS(clip) == 1) {
-			BoxPtr box = REGION_RECTS(clip);
+		if (clip->data == NULL) {
+			BoxPtr box = &clip->extents;
 			while (n--) {
 				BoxRec r;
 
@@ -2875,8 +2875,8 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable,
 			return FALSE;
 		}
 
-		if (REGION_NUM_RECTS(clip) == 1) {
-			const BoxRec *box = REGION_RECTS(clip);
+		if (clip->data == NULL) {
+			const BoxRec *box = &clip->extents;
 			while (n--) {
 				BoxRec r;
 
@@ -3172,7 +3172,7 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 		RegionIntersect(&clip, &clip, gc->pCompositeClip);
 
 	/* XXX loop over clips using SETUP_CLIP? */
-	if (REGION_NUM_RECTS(&clip) != 1) {
+	if (clip.data != NULL) {
 		RegionUninit(&clip);
 		return false;
 	}


More information about the xorg-commit mailing list