xf86-video-intel: 2 commits - 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
Fri Oct 24 01:57:13 PDT 2014


 src/sna/sna_trapezoids_imprecise.c |    8 ++++----
 src/sna/sna_trapezoids_mono.c      |   14 ++++++++------
 src/sna/sna_trapezoids_precise.c   |    8 ++++----
 3 files changed, 16 insertions(+), 14 deletions(-)

New commits:
commit d08a5f555a0c47ae23c0f9a890b512cb23e74feb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 24 09:53:29 2014 +0100

    sna/trapezoids: Prevent overflow of edge gradient in mono rasteriser
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=70461#c76
    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 4ad4573..808703a 100644
--- a/src/sna/sna_trapezoids_mono.c
+++ b/src/sna/sna_trapezoids_mono.c
@@ -41,7 +41,7 @@
 
 struct quorem {
 	int32_t quo;
-	int32_t rem;
+	int64_t rem;
 };
 
 struct mono_edge {
@@ -50,7 +50,7 @@ struct mono_edge {
 	int32_t height_left;
 	int32_t dir;
 
-	int32_t dy;
+	int64_t dy;
 	struct quorem x;
 	struct quorem dxdy;
 };
@@ -241,8 +241,8 @@ mono_add_line(struct mono *mono,
 		e->dxdy.rem = 0;
 		e->dy = 0;
 	} else {
-		int32_t dx = p2->x - p1->x;
-		int32_t dy = p2->y - p1->y;
+		int64_t dx = (int64_t)p2->x - p1->x;
+		int64_t dy = (int64_t)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);
@@ -364,8 +364,10 @@ static struct mono_edge *mono_filter(struct mono_edge *edges)
 		struct mono_edge *n = e->next;
 		if (e->dir == -n->dir &&
 		    e->height_left == n->height_left &&
-		    *(uint64_t *)&e->x == *(uint64_t *)&n->x &&
-		    *(uint64_t *)&e->dxdy == *(uint64_t *)&n->dxdy) {
+		    e->x.quo == n->x.quo &&
+		    e->x.rem == n->x.rem &&
+		    e->dxdy.quo == n->dxdy.quo &&
+		    e->dxdy.rem == n->dxdy.rem) {
 			if (e->prev)
 				e->prev->next = n->next;
 			else
commit f611f9580469661e585f419a7dd033ddffd7e20d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 24 09:41:47 2014 +0100

    sna/trapezoids: Difference between two 32-bit quantities is 33-bits in size
    
    When computing the edge distance, we subtract on 32-bit quantity from
    another. This requires 33-bits to store the full result so promote the
    subtraction to 64-bits (rather than the result of that subtraction as
    done currently).
    
    Reported-by: Jiri Slaby <jirislaby at gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70461#c76
    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 f88a8ae..37def2f 100644
--- a/src/sna/sna_trapezoids_imprecise.c
+++ b/src/sna/sna_trapezoids_imprecise.c
@@ -500,8 +500,8 @@ polygon_add_edge(struct polygon *polygon,
 	} else {
 		int64_t Ex, Ey, tmp;
 
-		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);
+		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;
@@ -594,8 +594,8 @@ polygon_add_line(struct polygon *polygon,
 	} else {
 		int64_t Ex, Ey, tmp;
 
-		Ex = (int64_t)(p2->x - p1->x) * FAST_SAMPLES_X;
-		Ey = (int64_t)(p2->y - p1->y) * FAST_SAMPLES_Y * (2 << 16);
+		Ex = ((int64_t)p2->x - p1->x) * FAST_SAMPLES_X;
+		Ey = ((int64_t)p2->y - p1->y) * FAST_SAMPLES_Y * (2 << 16);
 
 		e->dxdy.quo = Ex * (2 << 16) / Ey;
 		e->dxdy.rem = Ex * (2 << 16) % Ey;
diff --git a/src/sna/sna_trapezoids_precise.c b/src/sna/sna_trapezoids_precise.c
index 9925654..9187ab4 100644
--- a/src/sna/sna_trapezoids_precise.c
+++ b/src/sna/sna_trapezoids_precise.c
@@ -553,8 +553,8 @@ polygon_add_edge(struct polygon *polygon,
 		       edge->p2.x - edge->p1.x,
 		       edge->p2.y - edge->p1.y));
 
-		Ex = (int64_t)(edge->p2.x - edge->p1.x) * SAMPLES_X;
-		Ey = (int64_t)(edge->p2.y - edge->p1.y) * SAMPLES_Y * (2 << 16);
+		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;
@@ -663,8 +663,8 @@ polygon_add_line(struct polygon *polygon,
 		       p2->x - p1->x,
 		       p2->y - p1->y));
 
-		Ex = (int64_t)(p2->x - p1->x) * SAMPLES_X;
-		Ey = (int64_t)(p2->y - p1->y) * SAMPLES_Y * (2 << 16);
+		Ex = ((int64_t)p2->x - p1->x) * SAMPLES_X;
+		Ey = ((int64_t)p2->y - p1->y) * SAMPLES_Y * (2 << 16);
 		e->dxdy.quo = Ex * (2 << 16) / Ey;
 		e->dxdy.rem = Ex * (2 << 16) % Ey;
 


More information about the xorg-commit mailing list