[Bug 70461] [sna suse] ddx assertion hits

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Oct 9 23:36:19 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=70461

--- Comment #72 from Chris Wilson <chris at chris-wilson.co.uk> ---
The only think that strikes me is overflow, could you please test:

diff --git a/src/sna/sna_trapezoids_precise.c
b/src/sna/sna_trapezoids_precise.c
index c595bfd..f8512e3 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,12 @@ 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 (Ey < INT64_MAX / (1 << 16))
+                       tmp = (tmp * Ey) / (1 << 16);
+               else /* Handle overflow by sacrificing precision. */
+                       tmp *= Ey / (1 << 16);
+               e->x.rem +=  tmp;

                if (e->x.rem < 0) {
                        e->x.quo--;

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/intel-gfx-bugs/attachments/20141010/1bcc348c/attachment.html>


More information about the intel-gfx-bugs mailing list