xf86-video-intel: 4 commits - src/compat-api.h src/sna/sna_display.c src/sna/sna_trapezoids_imprecise.c src/sna/sna_trapezoids_mono.c src/sna/sna_trapezoids_precise.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Oct 11 08:16:45 PDT 2014


 src/compat-api.h                   |   10 +++++++++
 src/sna/sna_display.c              |   40 ++++++++++++++++++-------------------
 src/sna/sna_trapezoids_imprecise.c |   11 +++++++++-
 src/sna/sna_trapezoids_mono.c      |   30 ++++++++++++++++++---------
 src/sna/sna_trapezoids_precise.c   |   10 ++++++++-
 5 files changed, 69 insertions(+), 32 deletions(-)

New commits:
commit 70a1710e18f874f9efd8e97f0f873d65bf1b46ca
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 10 11:42:09 2014 +0100

    sna/trapezoids: Sacrifice precision to avoid 64bit overflow
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=70461#c71
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c
index 414e80a..0887d4f 100644
--- a/src/sna/sna_trapezoids_imprecise.c
+++ b/src/sna/sna_trapezoids_imprecise.c
@@ -502,6 +502,7 @@ polygon_add_edge(struct polygon *polygon,
 
 		Ex = (int64_t)(edge->p2.x - edge->p1.x) * FAST_SAMPLES_X;
 		Ey = (int64_t)(edge->p2.y - edge->p1.y) * FAST_SAMPLES_Y * (2 << 16);
+		assert(Ey > 0);
 
 		e->dxdy.quo = Ex * (2 << 16) / Ey;
 		e->dxdy.rem = Ex * (2 << 16) % Ey;
@@ -514,7 +515,14 @@ polygon_add_edge(struct polygon *polygon,
 
 		tmp = (int64_t)edge->p1.x * FAST_SAMPLES_X;
 		e->x.quo += tmp / (1 << 16) + dx;
-		e->x.rem += ((tmp & ((1 << 16) - 1)) * Ey) / (1 << 16);
+		tmp &= (1 << 16) - 1;
+		if (tmp) {
+			if (Ey < INT64_MAX >> 16)
+				tmp = (tmp * Ey) / (1 << 16);
+			else /* Handle overflow by losing precision */
+				tmp = tmp * (Ey / (1 << 16));
+			e->x.rem += tmp;
+		}
 
 		if (e->x.rem < 0) {
 			--e->x.quo;
@@ -523,6 +531,7 @@ polygon_add_edge(struct polygon *polygon,
 			++e->x.quo;
 			e->x.rem -= Ey;
 		}
+		assert(e->x.rem >= 0 && e->x.rem < Ey);
 
 		e->cell = e->x.quo + (e->x.rem >= Ey/2);
 		e->dy = Ey;
diff --git a/src/sna/sna_trapezoids_precise.c b/src/sna/sna_trapezoids_precise.c
index c595bfd..2c5dad5 100644
--- a/src/sna/sna_trapezoids_precise.c
+++ b/src/sna/sna_trapezoids_precise.c
@@ -555,6 +555,7 @@ polygon_add_edge(struct polygon *polygon,
 
 		Ex = (int64_t)(edge->p2.x - edge->p1.x) * SAMPLES_X;
 		Ey = (int64_t)(edge->p2.y - edge->p1.y) * SAMPLES_Y * (2 << 16);
+		assert(Ey > 0);
 		e->dxdy.quo = Ex * (2 << 16) / Ey;
 		e->dxdy.rem = Ex * (2 << 16) % Ey;
 
@@ -566,7 +567,14 @@ polygon_add_edge(struct polygon *polygon,
 
 		tmp = (int64_t)edge->p1.x * SAMPLES_X;
 		e->x.quo += (tmp >> 16) + dx;
-		e->x.rem += ((tmp & ((1 << 16) - 1)) * Ey) / (1 << 16);
+		tmp &= (1 << 16) - 1;
+		if (tmp) {
+			if (Ey < INT64_MAX >> 16)
+				tmp = (tmp * Ey) / (1 << 16);
+			else /* Handle overflow by losing precision */
+				tmp = tmp * (Ey / (1 << 16));
+			e->x.rem += tmp;
+		}
 
 		if (e->x.rem < 0) {
 			e->x.quo--;
commit 069f7878dc57dca39ad79b2f3ad5248244090b70
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 10 11:31:45 2014 +0100

    sna/trapezoids: Treat mono-edges within a single column as vertical
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_trapezoids_mono.c b/src/sna/sna_trapezoids_mono.c
index 7f34829..be95875 100644
--- a/src/sna/sna_trapezoids_mono.c
+++ b/src/sna/sna_trapezoids_mono.c
@@ -193,8 +193,6 @@ mono_add_line(struct mono *mono,
 {
 	struct mono_polygon *polygon = &mono->polygon;
 	struct mono_edge *e;
-	pixman_fixed_t dx;
-	pixman_fixed_t dy;
 	int y, ytop, ybot;
 
 	__DBG(("%s: top=%d, bottom=%d, line=(%d, %d), (%d, %d) delta=%dx%d, dir=%d\n",
@@ -224,6 +222,8 @@ mono_add_line(struct mono *mono,
 	y = I(bottom) + dst_y;
 	ybot = MIN(y, mono->clip.extents.y2);
 
+	__DBG(("%s: edge height [%d, %d] = %d\n",
+	       __FUNCTION__, ytop, ybot, ybot - ytop));
 	if (ybot <= ytop) {
 		__DBG(("discard clipped line\n"));
 		return;
@@ -233,23 +233,33 @@ mono_add_line(struct mono *mono,
 	e->height_left = ybot - ytop;
 	e->dir = dir;
 
-	dx = p2->x - p1->x;
-	dy = p2->y - p1->y;
-
-	if (dx == 0) {
+	if (I(p1->x) == I(p2->x)) {
+		__DBG(("%s: vertical edge x:%d\n", __FUNCTION__, I(p1->x)));
 		e->x.quo = p1->x;
 		e->x.rem = 0;
 		e->dxdy.quo = 0;
 		e->dxdy.rem = 0;
 		e->dy = 0;
 	} else {
-		e->dxdy = floored_muldivrem (dx, pixman_fixed_1, dy);
-		e->dy = dy;
+		int32_t dx = p2->x - p1->x;
+		int32_t dy = p2->y - p1->y;
+
+		__DBG(("%s: diagonal edge (%d, %d), x:[%d, %d]\n", __FUNCTION__, dx, dy, I(p1->x), I(p2->x)));
+		assert(dy > 0);
+
+		e->dxdy = floored_muldivrem(dx, pixman_fixed_1, dy);
 
-		e->x = floored_muldivrem ((ytop-dst_y) * pixman_fixed_1 + pixman_fixed_1_minus_e/2 - p1->y,
-					  dx, dy);
+		e->x = floored_muldivrem((ytop - dst_y) * pixman_fixed_1 + pixman_fixed_1_minus_e/2 - p1->y,
+					 dx, dy);
 		e->x.quo += p1->x;
 		e->x.rem -= dy;
+
+		e->dy = dy;
+
+		__DBG(("%s: initial x=%d [%d.%d/%d] + dxdy=%d.%d/%d\n",
+		       __FUNCTION__,
+		       I(e->x.quo), e->x.quo, e->x.rem, e->dy,
+		       e->dxdy.quo, e->dxdy.rem, e->dy));
 	}
 	e->x.quo += dst_x*pixman_fixed_1;
 
commit 0c1b4f913c20370736327c44a9fa3b5c55c05d52
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 10 08:35:16 2014 +0100

    sna: Log if we disable the backlight after failure to switch it on
    
    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 48cdb25..2ab928f 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -602,24 +602,31 @@ static void sna_backlight_drain_uevents(struct sna *sna) { }
 static void sna_backlight_close(struct sna *sna) { }
 #endif
 
+static void
+sna_output_backlight_disable(struct sna_output *sna_output)
+{
+	xf86OutputPtr output = sna_output->base;
+
+	xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+		   "Failed to set backlight %s for output %s, disabling\n",
+		   sna_output->backlight.iface, output->name);
+	backlight_disable(&sna_output->backlight);
+	if (output->randr_output) {
+		RRDeleteOutputProperty(output->randr_output, backlight_atom);
+		RRDeleteOutputProperty(output->randr_output, backlight_deprecated_atom);
+	}
+}
+
 static int
 sna_output_backlight_set(struct sna_output *sna_output, int level)
 {
-	xf86OutputPtr output = sna_output->base;
 	int ret = 0;
 
 	DBG(("%s(%s) level=%d, max=%d\n", __FUNCTION__,
-	     output->name, level, sna_output->backlight.max));
+	     sna_output->base->name, level, sna_output->backlight.max));
 
 	if (backlight_set(&sna_output->backlight, level)) {
-		xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-			   "Failed to set backlight %s for output %s to brightness level %d, disabling\n",
-			   sna_output->backlight.iface, output->name, level);
-		backlight_disable(&sna_output->backlight);
-		if (output->randr_output) {
-			RRDeleteOutputProperty(output->randr_output, backlight_atom);
-			RRDeleteOutputProperty(output->randr_output, backlight_deprecated_atom);
-		}
+		sna_output_backlight_disable(sna_output);
 		ret = -1;
 	}
 
@@ -627,7 +634,7 @@ sna_output_backlight_set(struct sna_output *sna_output, int level)
 	 * the change latter when we wake up and the output is in a different
 	 * state.
 	 */
-	sna_backlight_drain_uevents(to_sna(output->scrn));
+	sna_backlight_drain_uevents(to_sna(sna_output->base->scrn));
 	return ret;
 }
 
@@ -645,15 +652,8 @@ sna_output_backlight_on(struct sna_output *sna_output)
 	DBG(("%s(%s)\n", __FUNCTION__, sna_output->base->name));
 	sna_output_backlight_set(sna_output,
 				 sna_output->backlight_active_level);
-	if (backlight_on(&sna_output->backlight) < 0) {
-		xf86OutputPtr output = sna_output->base;
-
-		backlight_disable(&sna_output->backlight);
-		if (output->randr_output) {
-			RRDeleteOutputProperty(output->randr_output, backlight_atom);
-			RRDeleteOutputProperty(output->randr_output, backlight_deprecated_atom);
-		}
-	}
+	if (backlight_on(&sna_output->backlight) < 0)
+		sna_output_backlight_disable(sna_output);
 }
 
 static int
commit f7f7383de0da0776cfbe98481578ab6680732a2a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 9 16:35:36 2014 +0100

    compat: Hide changes in miHandleExposures() interface
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84901

diff --git a/src/compat-api.h b/src/compat-api.h
index 46a755b..d09e1fb 100644
--- a/src/compat-api.h
+++ b/src/compat-api.h
@@ -213,4 +213,14 @@ static inline void FreePixmap(PixmapPtr pixmap)
 
 #endif
 
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,16,99,1,0)
+#include <mi.h>
+#define miHandleExposures(pSrcDrawable, pDstDrawable, \
+			  pGC, srcx, srcy, width, height, \
+			  dstx, dsty, plane) \
+	miHandleExposures(pSrcDrawable, pDstDrawable, \
+			  pGC, srcx, srcy, width, height, \
+			  dstx, dsty)
+#endif
+
 #endif


More information about the xorg-commit mailing list