xf86-video-intel: 8 commits - configure.ac src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_display.c src/sna/sna_video.c src/sna/sna_video.h src/sna/sna_video_overlay.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Jun 22 03:08:31 PDT 2011


 configure.ac                |    4 -
 src/sna/gen3_render.c       |    4 -
 src/sna/gen4_render.c       |   19 +++---
 src/sna/gen5_render.c       |    4 -
 src/sna/gen6_render.c       |    4 -
 src/sna/kgem.c              |    2 
 src/sna/kgem.h              |    8 +-
 src/sna/sna_accel.c         |   29 +++++----
 src/sna/sna_display.c       |    3 
 src/sna/sna_video.c         |  138 ++++++++++++++++++++++++++------------------
 src/sna/sna_video.h         |    9 +-
 src/sna/sna_video_overlay.c |    2 
 12 files changed, 134 insertions(+), 92 deletions(-)

New commits:
commit 8fb98e22a63a4354b049ace7870abb6406541c28
Author: Jian Zhao <jian.j.zhao at intel.com>
Date:   Wed Jun 22 08:54:59 2011 +0800

    configure: Define required_xorg_xserver_version later so it can make successfully.

diff --git a/configure.ac b/configure.ac
index 7bde768..eea4708 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,8 +20,6 @@
 #
 # Process this file with autoconf to produce a configure script
 
-required_xorg_xserver_version=1.6
-
 # Initialize Autoconf
 AC_PREREQ([2.63])
 AC_INIT([xf86-video-intel],
@@ -101,6 +99,8 @@ AC_ARG_ENABLE(sna,
 	      [SNA=no])
 AM_CONDITIONAL(SNA, test x$SNA != xno)
 AC_MSG_CHECKING([whether to include SNA support])
+
+required_xorg_xserver_version=1.6
 if test "x$SNA" != "xno"; then
 	required_xorg_xserver_version=1.10
 	AC_DEFINE(USE_SNA, 1, [Enable SNA support])
commit ea71133da78632d4cfee5b0b4c96e8dddd6cdf44
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 21 12:28:13 2011 +0100

    sna/video: Use pwrite for upload of unclipped, unrotated frames
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 542856d..c40718b 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -2837,7 +2837,7 @@ gen3_emit_video_state(struct sna *sna,
 		OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch,
 					 frame->bo,
 					 I915_GEM_DOMAIN_SAMPLER << 16,
-					 frame->YBufOffset));
+					 0));
 
 		ms3 = MAPSURF_422;
 		switch (frame->id) {
@@ -2951,7 +2951,7 @@ gen3_emit_video_state(struct sna *sna,
 		OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch,
 					 frame->bo,
 					 I915_GEM_DOMAIN_SAMPLER << 16,
-					 frame->YBufOffset));
+					 0));
 
 		ms3 = MAPSURF_8BIT | MT_8BIT_I8;
 		ms3 |= (frame->height - 1) << MS3_HEIGHT_SHIFT;
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 20f8bf0..2a2ecab 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1546,8 +1546,8 @@ static void gen4_video_bind_surfaces(struct sna *sna,
 	uint16_t offset;
 	int n_src, n;
 
-	src_surf_base[0] = frame->YBufOffset;
-	src_surf_base[1] = frame->YBufOffset;
+	src_surf_base[0] = 0;
+	src_surf_base[1] = 0;
 	src_surf_base[2] = frame->VBufOffset;
 	src_surf_base[3] = frame->VBufOffset;
 	src_surf_base[4] = frame->UBufOffset;
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 69c71f5..77ad1bb 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1559,8 +1559,8 @@ static void gen5_video_bind_surfaces(struct sna *sna,
 	uint16_t offset;
 
 
-	src_surf_base[0] = frame->YBufOffset;
-	src_surf_base[1] = frame->YBufOffset;
+	src_surf_base[0] = 0;
+	src_surf_base[1] = 0;
 	src_surf_base[2] = frame->VBufOffset;
 	src_surf_base[3] = frame->VBufOffset;
 	src_surf_base[4] = frame->UBufOffset;
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 80d1f3d..4f3e41a 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1735,8 +1735,8 @@ static void gen6_emit_video_state(struct sna *sna,
 
 	gen6_get_batch(sna);
 
-	src_surf_base[0] = frame->YBufOffset;
-	src_surf_base[1] = frame->YBufOffset;
+	src_surf_base[0] = 0;
+	src_surf_base[1] = 0;
 	src_surf_base[2] = frame->VBufOffset;
 	src_surf_base[3] = frame->VBufOffset;
 	src_surf_base[4] = frame->UBufOffset;
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index b217996..6b3fe7e 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -274,10 +274,8 @@ uint32_t kgem_add_reloc(struct kgem *kgem,
 void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo, int prot);
 uint32_t kgem_bo_flink(struct kgem *kgem, struct kgem_bo *bo);
 
-Bool kgem_bo_write(struct kgem *kgem,
-		   struct kgem_bo *bo,
-		   const void *data,
-		   int length);
+Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
+		   const void *data, int length);
 
 static inline bool kgem_bo_is_busy(struct kgem *kgem, struct kgem_bo *bo)
 {
diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c
index 8839ab7..7f520da 100644
--- a/src/sna/sna_video.c
+++ b/src/sna/sna_video.c
@@ -236,16 +236,12 @@ sna_video_frame_init(struct sna *sna,
 		frame->pitch[1] = 0;
 	}
 
-	frame->YBufOffset = 0;
-
 	if (video->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
-		frame->UBufOffset =
-			frame->YBufOffset + frame->pitch[1] * width;
+		frame->UBufOffset = frame->pitch[1] * width;
 		frame->VBufOffset =
 			frame->UBufOffset + frame->pitch[0] * width / 2;
 	} else {
-		frame->UBufOffset =
-			frame->YBufOffset + frame->pitch[1] * height;
+		frame->UBufOffset = frame->pitch[1] * height;
 		frame->VBufOffset =
 			frame->UBufOffset + frame->pitch[0] * height / 2;
 	}
@@ -319,52 +315,50 @@ static void sna_memcpy_plane(unsigned char *dst, unsigned char *src,
 static void
 sna_copy_planar_data(struct sna *sna,
 		     struct sna_video *video,
-		     struct sna_video_frame *frame,
-		     unsigned char *buf,
+		     const struct sna_video_frame *frame,
+		     unsigned char *src,
 		     unsigned char *dst,
 		     int srcPitch, int srcPitch2,
 		     int srcH, int top, int left)
 {
-	unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3;
+	unsigned char *src1, *dst1;
 
 	/* Copy Y data */
-	src1 = buf + (top * srcPitch) + left;
+	src1 = src + (top * srcPitch) + left;
 
-	dst1 = dst + frame->YBufOffset;
-
-	sna_memcpy_plane(dst1, src1,
+	sna_memcpy_plane(dst, src1,
 			 frame->height, frame->width,
 			 frame->pitch[1], srcPitch,
 			 video->rotation);
 
 	/* Copy V data for YV12, or U data for I420 */
-	src2 = buf +		/* start of YUV data */
+	src1 = src +		/* start of YUV data */
 	    (srcH * srcPitch) +	/* move over Luma plane */
 	    ((top >> 1) * srcPitch2) +	/* move down from by top lines */
 	    (left >> 1);	/* move left by left pixels */
 
 	if (frame->id == FOURCC_I420)
-		dst2 = dst + frame->UBufOffset;
+		dst1 = dst + frame->UBufOffset;
 	else
-		dst2 = dst + frame->VBufOffset;
+		dst1 = dst + frame->VBufOffset;
 
-	sna_memcpy_plane(dst2, src2,
+	sna_memcpy_plane(dst1, src1,
 			 frame->height / 2, frame->width / 2,
 			 frame->pitch[0], srcPitch2,
 			 video->rotation);
 
 	/* Copy U data for YV12, or V data for I420 */
-	src3 = buf +		/* start of YUV data */
+	src1 = src +		/* start of YUV data */
 	    (srcH * srcPitch) +	/* move over Luma plane */
 	    ((srcH >> 1) * srcPitch2) +	/* move over Chroma plane */
 	    ((top >> 1) * srcPitch2) +	/* move down from by top lines */
 	    (left >> 1);	/* move left by left pixels */
 	if (frame->id == FOURCC_I420)
-		dst3 = dst + frame->VBufOffset;
+		dst1 = dst + frame->VBufOffset;
 	else
-		dst3 = dst + frame->UBufOffset;
+		dst1 = dst + frame->UBufOffset;
 
-	sna_memcpy_plane(dst3, src3,
+	sna_memcpy_plane(dst1, src1,
 			 frame->height / 2, frame->width / 2,
 			 frame->pitch[0], srcPitch2,
 			 video->rotation);
@@ -373,99 +367,99 @@ sna_copy_planar_data(struct sna *sna,
 static void
 sna_copy_packed_data(struct sna *sna,
 		     struct sna_video *video,
-		     struct sna_video_frame *frame,
+		     const struct sna_video_frame *frame,
 		     unsigned char *buf,
 		     unsigned char *dst,
 		     int srcPitch,
 		     int top, int left)
 {
+	int w = frame->width;
+	int h = frame->height;
 	unsigned char *src;
 	unsigned char *s;
 	int i, j;
 
 	src = buf + (top * srcPitch) + (left << 1);
 
-	dst += frame->YBufOffset;
-
 	switch (video->rotation) {
 	case RR_Rotate_0:
-		frame->width <<= 1;
-		for (i = 0; i < frame->height; i++) {
-			memcpy(dst, src, frame->width);
+		w <<= 1;
+		for (i = 0; i < h; i++) {
+			memcpy(dst, src, w);
 			src += srcPitch;
 			dst += frame->pitch[0];
 		}
 		break;
 	case RR_Rotate_90:
-		frame->height <<= 1;
-		for (i = 0; i < frame->height; i += 2) {
+		h <<= 1;
+		for (i = 0; i < h; i += 2) {
 			s = src;
-			for (j = 0; j < frame->width; j++) {
+			for (j = 0; j < w; j++) {
 				/* Copy Y */
-				dst[(i + 0) + ((frame->width - j - 1) * frame->pitch[0])] = *s++;
+				dst[(i + 0) + ((w - j - 1) * frame->pitch[0])] = *s++;
 				(void)*s++;
 			}
 			src += srcPitch;
 		}
-		frame->height >>= 1;
+		h >>= 1;
 		src = buf + (top * srcPitch) + (left << 1);
-		for (i = 0; i < frame->height; i += 2) {
-			for (j = 0; j < frame->width; j += 2) {
+		for (i = 0; i < h; i += 2) {
+			for (j = 0; j < w; j += 2) {
 				/* Copy U */
-				dst[((i * 2) + 1) + ((frame->width - j - 1) * frame->pitch[0])] =
+				dst[((i * 2) + 1) + ((w - j - 1) * frame->pitch[0])] =
 				    src[(j * 2) + 1 + (i * srcPitch)];
-				dst[((i * 2) + 1) + ((frame->width - j - 2) * frame->pitch[0])] =
+				dst[((i * 2) + 1) + ((w - j - 2) * frame->pitch[0])] =
 				    src[(j * 2) + 1 + ((i + 1) * srcPitch)];
 				/* Copy V */
-				dst[((i * 2) + 3) + ((frame->width - j - 1) * frame->pitch[0])] =
+				dst[((i * 2) + 3) + ((w - j - 1) * frame->pitch[0])] =
 				    src[(j * 2) + 3 + (i * srcPitch)];
-				dst[((i * 2) + 3) + ((frame->width - j - 2) * frame->pitch[0])] =
+				dst[((i * 2) + 3) + ((w - j - 2) * frame->pitch[0])] =
 				    src[(j * 2) + 3 + ((i + 1) * srcPitch)];
 			}
 		}
 		break;
 	case RR_Rotate_180:
-		frame->width <<= 1;
-		for (i = 0; i < frame->height; i++) {
+		w <<= 1;
+		for (i = 0; i < h; i++) {
 			s = src;
-			for (j = 0; j < frame->width; j += 4) {
-				dst[(frame->width - j - 4) + ((frame->height - i - 1) * frame->pitch[0])] =
+			for (j = 0; j < w; j += 4) {
+				dst[(w - j - 4) + ((h - i - 1) * frame->pitch[0])] =
 				    *s++;
-				dst[(frame->width - j - 3) + ((frame->height - i - 1) * frame->pitch[0])] =
+				dst[(w - j - 3) + ((h - i - 1) * frame->pitch[0])] =
 				    *s++;
-				dst[(frame->width - j - 2) + ((frame->height - i - 1) * frame->pitch[0])] =
+				dst[(w - j - 2) + ((h - i - 1) * frame->pitch[0])] =
 				    *s++;
-				dst[(frame->width - j - 1) + ((frame->height - i - 1) * frame->pitch[0])] =
+				dst[(w - j - 1) + ((h - i - 1) * frame->pitch[0])] =
 				    *s++;
 			}
 			src += srcPitch;
 		}
 		break;
 	case RR_Rotate_270:
-		frame->height <<= 1;
-		for (i = 0; i < frame->height; i += 2) {
+		h <<= 1;
+		for (i = 0; i < h; i += 2) {
 			s = src;
-			for (j = 0; j < frame->width; j++) {
+			for (j = 0; j < w; j++) {
 				/* Copy Y */
-				dst[(frame->height - i - 2) + (j * frame->pitch[0])] = *s++;
+				dst[(h - i - 2) + (j * frame->pitch[0])] = *s++;
 				(void)*s++;
 			}
 			src += srcPitch;
 		}
-		frame->height >>= 1;
+		h >>= 1;
 		src = buf + (top * srcPitch) + (left << 1);
-		for (i = 0; i < frame->height; i += 2) {
-			for (j = 0; j < frame->width; j += 2) {
+		for (i = 0; i < h; i += 2) {
+			for (j = 0; j < w; j += 2) {
 				/* Copy U */
-				dst[(((frame->height - i) * 2) - 3) + (j * frame->pitch[0])] =
+				dst[(((h - i) * 2) - 3) + (j * frame->pitch[0])] =
 				    src[(j * 2) + 1 + (i * srcPitch)];
-				dst[(((frame->height - i) * 2) - 3) +
+				dst[(((h - i) * 2) - 3) +
 				    ((j + 1) * frame->pitch[0])] =
 				    src[(j * 2) + 1 + ((i + 1) * srcPitch)];
 				/* Copy V */
-				dst[(((frame->height - i) * 2) - 1) + (j * frame->pitch[0])] =
+				dst[(((h - i) * 2) - 1) + (j * frame->pitch[0])] =
 				    src[(j * 2) + 3 + (i * srcPitch)];
-				dst[(((frame->height - i) * 2) - 1) +
+				dst[(((h - i) * 2) - 1) +
 				    ((j + 1) * frame->pitch[0])] =
 				    src[(j * 2) + 3 + ((i + 1) * srcPitch)];
 			}
@@ -488,6 +482,38 @@ sna_video_copy_data(struct sna *sna,
 	if (frame->bo == NULL)
 		return FALSE;
 
+	/* In the common case, we can simply the upload to a single pwrite */
+	if (video->rotation == RR_Rotate_0) {
+		if (is_planar_fourcc(frame->id)) {
+			uint16_t pitch[2] = {
+				ALIGN((frame->width >> 1), 0x4),
+				ALIGN(frame->width, 0x4),
+			};
+			if (pitch[0] == frame->pitch[0] &&
+			    pitch[1] == frame->pitch[1] &&
+			    top == 0 && left == 0) {
+				kgem_bo_write(&sna->kgem, frame->bo,
+					      buf,
+					      pitch[1]*frame->height +
+					      pitch[0]*frame->height);
+				if (frame->id != FOURCC_I420) {
+					uint32_t tmp;
+					tmp = frame->VBufOffset;
+					frame->VBufOffset = frame->UBufOffset;
+					frame->UBufOffset = tmp;
+				}
+				return TRUE;
+			}
+		} else {
+			if (frame->width*2 == frame->pitch[0]) {
+				kgem_bo_write(&sna->kgem, frame->bo,
+					      buf + (top * frame->width*2) + (left << 1),
+					      frame->height*frame->width*2);
+				return TRUE;
+			}
+		}
+	}
+
 	/* copy data */
 	dst = kgem_bo_map(&sna->kgem, frame->bo, PROT_READ | PROT_WRITE);
 	if (dst == NULL)
diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h
index f66a697..bf4f6a4 100644
--- a/src/sna/sna_video.h
+++ b/src/sna/sna_video.h
@@ -64,13 +64,12 @@ struct sna_video {
 
 struct sna_video_frame {
 	struct kgem_bo *bo;
-	int id;
-	int width, height;
-	int pitch[2];
-	int size;
-	uint32_t YBufOffset;
+	uint32_t id;
+	uint32_t size;
 	uint32_t UBufOffset;
 	uint32_t VBufOffset;
+	uint16_t width, height;
+	uint16_t pitch[2];
 };
 
 void sna_video_init(struct sna *sna, ScreenPtr screen);
diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c
index 3f7d955..c4838c2 100644
--- a/src/sna/sna_video_overlay.c
+++ b/src/sna/sna_video_overlay.c
@@ -398,7 +398,7 @@ sna_video_overlay_show(struct sna *sna,
 		request.stride_Y = frame->pitch[0];
 		request.stride_UV = 0;
 	}
-	request.offset_Y = frame->YBufOffset;
+	request.offset_Y = 0;
 	request.offset_U = frame->UBufOffset;
 	request.offset_V = frame->VBufOffset;
 	DBG(("%s: handle=%d, stride_Y=%d, stride_UV=%d, off_Y: %i, off_U: %i, off_V: %i\n",
commit 2f6afb5b1f02cc448da1b342627108ceddda4f0d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 20 17:29:17 2011 +0100

    sna: Only reduce gpu damage after migration
    
    Otherwise we end up doing work for no reason, ala the regression in
    grads-heat-map. However, it is important that the damage is reduced at
    some point or else it may grow unbounded. Hopefully normal usage will
    never hit the pathologocial case...
    
    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 b465a34..2b78e92 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -790,8 +790,8 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap)
 	__sna_damage_destroy(priv->cpu_damage);
 	priv->cpu_damage = NULL;
 
-done:
 	sna_damage_reduce(&priv->gpu_damage);
+done:
 	list_del(&priv->list);
 	return priv;
 }
commit 88d840b53d64e67cfee14cc4cef8da46d716c401
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 20 15:22:57 2011 +0100

    sna/gen4: Check for sufficient batch space before emitting pipelined pointers
    
    For the broken shader workaround, we need to reset the pipeline state
    before every blt as the state is changed by the magic CA pass. So we
    need to check that we actually have sufficient space to emit the
    pipelined pointers before doing so.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 0412f81..20f8bf0 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1453,10 +1453,14 @@ gen4_render_composite_blt(struct sna *sna,
 	     r->dst.x, r->dst.y, op->dst.x, op->dst.y,
 	     r->width, r->height));
 
-	if (FLUSH_EVERY_VERTEX && op->need_magic_ca_pass)
+	if (FLUSH_EVERY_VERTEX && op->need_magic_ca_pass) {
 		/* We have to reset the state after every FLUSH */
-		gen4_emit_pipelined_pointers(sna, op,
-					     op->op, op->u.gen4.wm_kernel);
+		if (kgem_check_batch(&sna->kgem, 20)) {
+			gen4_emit_pipelined_pointers(sna, op, op->op,
+						     op->u.gen4.wm_kernel);
+		} else
+			gen4_bind_surfaces(sna, op);
+	}
 
 	if (!gen4_get_rectangles(sna, op, 1)) {
 		gen4_bind_surfaces(sna, op);
commit 84bd6e51199bf8b49e6f6e0c29a1d71c89f6996f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 20 15:22:00 2011 +0100

    sna/gen4: Correct the number of dwods required to emit the ca pass
    
    We need 7 for pipelined pointers, 6 for the primitive and 1 for the
    flush.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index da2bb76..0412f81 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1047,7 +1047,7 @@ static bool gen4_rectangle_begin(struct sna *sna,
 
 	ndwords = 0;
 	if (FLUSH_EVERY_VERTEX)
-		ndwords = 1;
+		ndwords += 1;
 	if ((sna->render_state.gen4.vb_id & (1 << id)) == 0)
 		ndwords += 5;
 	if (sna->render_state.gen4.vertex_offset == 0)
@@ -1056,7 +1056,8 @@ static bool gen4_rectangle_begin(struct sna *sna,
 		return true;
 
 	if (op->need_magic_ca_pass)
-		ndwords += 12; /* pipelined pointers + primitive + flush */
+		/* 7xpipelined pointers + 6xprimitive + 1xflush */
+		ndwords += 14;
 
 	if (!kgem_check_batch(&sna->kgem, ndwords))
 		return false;
commit 22255335e428cb1f349fe4198d36e0ab3fe06948
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 20 13:51:12 2011 +0100

    sna: Don't perform a GPU copy of the scanout if it is wedged.
    
    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 a0acea2..42e3f59 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -504,6 +504,9 @@ void sna_copy_fbcon(struct sna *sna)
 	bool ok;
 	int i;
 
+	if (sna->kgem.wedged)
+		return;
+
 	/* Scan the connectors for a framebuffer and assume that is the fbcon */
 	fbcon = NULL;
 	for (i = 0; fbcon == NULL && i < xf86_config->num_crtc; i++) {
commit e2684498a4905b4ac157a1c752c1c4f75301e7ad
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 20 13:50:43 2011 +0100

    sna: Add some debugging asserts for handling wedged GPUs
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index f039735..df1546d 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -771,6 +771,8 @@ void _kgem_submit(struct kgem *kgem)
 	uint32_t batch_end;
 	int size;
 
+	assert(!DBG_NO_HW);
+
 	assert(kgem->nbatch);
 	assert(kgem->nbatch <= KGEM_BATCH_SIZE(kgem));
 	assert(kgem->nbatch <= kgem->surface);
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index eb16ceb..b217996 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -197,6 +197,8 @@ void kgem_clear_dirty(struct kgem *kgem);
 
 static inline void kgem_set_mode(struct kgem *kgem, enum kgem_mode mode)
 {
+	assert(!kgem->wedged);
+
 #if DEBUG_FLUSH_CACHE
 	kgem_emit_flush(kgem);
 #endif
commit d0362a20bb3ead2fab9401b63209f917bdd72d55
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 19 19:33:01 2011 +0100

    sna: Bypass the gpu-is-wedged? check for forced bo creation
    
    In order to attach a scanout (and use swrast) on a wedged GPU, we need to
    bypass the safety checks for normal pixmap creation.
    
    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 23f2cb2..b465a34 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -139,6 +139,21 @@ static uint32_t sna_pixmap_choose_tiling(PixmapPtr pixmap)
 				  pixmap->drawable.bitsPerPixel);
 }
 
+static struct sna_pixmap *_sna_pixmap_attach(PixmapPtr pixmap)
+{
+	struct sna_pixmap *priv;
+
+	priv = calloc(1, sizeof(*priv));
+	if (!priv)
+		return NULL;
+
+	list_init(&priv->list);
+	priv->pixmap = pixmap;
+
+	sna_set_pixmap(pixmap, priv);
+	return priv;
+}
+
 struct sna_pixmap *sna_pixmap_attach(PixmapPtr pixmap)
 {
 	struct sna *sna;
@@ -164,15 +179,7 @@ struct sna_pixmap *sna_pixmap_attach(PixmapPtr pixmap)
 				sna_pixmap_choose_tiling(pixmap)))
 		return NULL;
 
-	priv = calloc(1, sizeof(*priv));
-	if (!priv)
-		return NULL;
-
-	list_init(&priv->list);
-	priv->pixmap = pixmap;
-
-	sna_set_pixmap(pixmap, priv);
-	return priv;
+	return _sna_pixmap_attach(pixmap);
 }
 
 static PixmapPtr
@@ -677,7 +684,7 @@ sna_pixmap_force_to_gpu(PixmapPtr pixmap)
 
 	priv = sna_pixmap(pixmap);
 	if (priv == NULL) {
-		priv = sna_pixmap_attach(pixmap);
+		priv = _sna_pixmap_attach(pixmap);
 		if (priv == NULL)
 			return NULL;
 


More information about the xorg-commit mailing list