From 4c5f052959234d18b6504ba9dbc3378cf3f5cd20 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 26 Jul 2013 21:00:28 -0700 Subject: [PATCH] Debug printfs for bug54805 --- src/mesa/tnl/t_vb_cliptmp.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index c3259aa..ae1af76 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -25,6 +25,40 @@ * Keith Whitwell */ +static inline GLboolean +DIFF_SIGNS(GLfloat x, GLfloat y) +{ + GLboolean result = signbit(x) != signbit(y); + printf("signbit(%f) != signbit(%f) -> %d != %d -> %x\n", x, y, signbit(x), signbit(y), result); + return result; +} + +static inline GLboolean +DIFF_SIGNS_OLD(GLfloat x, GLfloat y) +{ + GLboolean result; + fi_type xfi, yfi; + xfi.f = x; + yfi.f = y; + result = ((xfi.i ^ yfi.i) & (1u << 31)); + printf("old macro(%f, %f) -> %x\n", x, y, result); + printf(" (%x ^ %x) & (1u << 31)\n", xfi.i, yfi.i); + printf(" %x & (1u << 31)\n", xfi.i ^ yfi.i); + printf(" %x\n", (xfi.i ^ yfi.i) & (1u << 31)); + printf(" %x\n", (GLboolean) ((xfi.i ^ yfi.i) & (1u << 31))); + return result; +} + +static GLboolean +DIFFERING_SIGNS(GLfloat dp, GLfloat dpPrev) +{ + printf("DEBUG: Considering dp = %f, dpPrev = %f\n", dp, dpPrev); + GLboolean diff1 = DIFF_SIGNS(dp, dpPrev); + GLboolean diff2 = DIFF_SIGNS_OLD(dp, dpPrev); + printf("%s\n", diff1 == diff2 ? "OK" : "FAIL"); + printf("----------\n"); + return diff2; +} #define CLIP_DOTPROD(K, A, B, C, D) X(K)*A + Y(K)*B + Z(K)*C + W(K)*D @@ -44,8 +78,7 @@ do { \ if (!IS_NEGATIVE(dpPrev)) { \ outlist[outcount++] = idxPrev; \ } \ - \ - if (DIFFERENT_SIGNS(dp, dpPrev)) { \ + if (DIFFERING_SIGNS(dp, dpPrev)) { \ if (IS_NEGATIVE(dp)) { \ /* Going out of bounds. Avoid division by zero as we \ * know dp != dpPrev from DIFFERENT_SIGNS, above. \ -- 1.7.10.3