mesa: Replace IS_NEGATIVE(x) with x < 0.0f.
authorMatt Turner <mattst88@gmail.com>
Mon, 22 Sep 2014 04:03:14 +0000 (21:03 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 25 Sep 2014 20:57:29 +0000 (13:57 -0700)
I only made IS_NEGATIVE(x) use signbit in commit 0f3ba405 in an attempt
to fix 54805, but it didn't help. We didn't use signbit on some
platforms and instead defined it to x < 0.0f.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/gallium/auxiliary/draw/draw_pipe_clip.c
src/mesa/drivers/dri/i965/brw_clip_line.c
src/mesa/drivers/dri/i965/brw_clip_tri.c
src/mesa/main/macros.h
src/mesa/tnl/t_vb_cliptmp.h

index d8b56de4d2ff576a545c672637a10f6f7e1e7cc4..2fbd655e07fc6639194f7b389823d4b7820152b4 100644 (file)
 #define DEBUG_CLIP 0
 
 
-#ifndef IS_NEGATIVE
-#define IS_NEGATIVE(X) ((X) < 0.0)
-#endif
-
 #ifndef DIFFERENT_SIGNS
 #define DIFFERENT_SIGNS(x, y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
 #endif
@@ -437,7 +433,7 @@ do_clip_tri( struct draw_stage *stage,
          if (util_is_inf_or_nan(dp))
             return; //discard nan
 
-        if (!IS_NEGATIVE(dp_prev)) {
+        if (dp_prev >= 0.0f) {
             assert(outcount < MAX_CLIPPED_VERTICES);
             if (outcount >= MAX_CLIPPED_VERTICES)
                return;
@@ -461,7 +457,7 @@ do_clip_tri( struct draw_stage *stage,
             new_edge = &outEdges[outcount];
            outlist[outcount++] = new_vert;
 
-           if (IS_NEGATIVE(dp)) {
+           if (dp < 0.0f) {
               /* Going out of bounds.  Avoid division by zero as we
                * know dp != dp_prev from DIFFERENT_SIGNS, above.
                */
index 90cd07cd4a34932c3a1382dfba9731755ba986a7..3b8af58ec7631d58636006f33aff69db1a0d9652 100644 (file)
@@ -109,7 +109,7 @@ static void brw_clip_line_alloc_regs( struct brw_clip_compile *c )
  *        GLfloat dp0 = DOTPROD( vtx0, plane[p] );
  *        GLfloat dp1 = DOTPROD( vtx1, plane[p] );
  *
- *        if (IS_NEGATIVE(dp1)) {
+ *        if (dp1 < 0.0f) {
  *           GLfloat t = dp1 / (dp1 - dp0);
  *           if (t > t1) t1 = t;
  *        } else {
index 62336fc795b298d3bc4ced6faf67735423ba5baa..2227a65ae4c778985262e07b830cdd428192a06f 100644 (file)
@@ -320,7 +320,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
            brw_MOV(p, get_addr_reg(vtx), deref_1uw(inlist_ptr, 0));
 
             load_clip_distance(c, vtxPrev, c->reg.dpPrev, hpos_offset, BRW_CONDITIONAL_L);
-           /* IS_NEGATIVE(prev) */
+           /* (prev < 0.0f) */
            brw_IF(p, BRW_EXECUTE_1);
            {
                load_clip_distance(c, vtx, c->reg.dp, hpos_offset, BRW_CONDITIONAL_GE);
@@ -366,7 +366,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
               brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
 
                load_clip_distance(c, vtx, c->reg.dp, hpos_offset, BRW_CONDITIONAL_L);
-              /* IS_NEGATIVE(next)
+              /* (next < 0.0f)
                */
               brw_IF(p, BRW_EXECUTE_1);
               {
index 712699f75a8aa47862641adfa74cb2d62a82cdde..cd5f2d6f28b9b1fa38ff3f56abc5f85c2cb9cc58 100644 (file)
@@ -799,13 +799,6 @@ NORMALIZE_3FV(GLfloat v[3])
 }
 
 
-/** Is float value negative? */
-static inline GLboolean
-IS_NEGATIVE(float x)
-{
-   return signbit(x) != 0;
-}
-
 /** Test two floats have opposite signs */
 static inline GLboolean
 DIFFERENT_SIGNS(GLfloat x, GLfloat y)
index 83de16d76fb49c1212ff36eeccc3ee69b6b9176e..7dafb83cf170ef8da6fa2d726935507ec398b683 100644 (file)
@@ -41,12 +41,12 @@ do {                                                                        \
         GLuint idx = inlist[i];                                        \
         GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D );                   \
                                                                        \
-        if (!IS_NEGATIVE(dpPrev)) {                                    \
+        if (dpPrev >= 0.0f) {                                          \
            outlist[outcount++] = idxPrev;                              \
         }                                                              \
                                                                        \
         if (DIFFERENT_SIGNS(dp, dpPrev)) {                             \
-           if (IS_NEGATIVE(dp)) {                                      \
+           if (dp < 0.0f) {                                            \
               /* Going out of bounds.  Avoid division by zero as we    \
                * know dp != dpPrev from DIFFERENT_SIGNS, above.        \
                */                                                      \
@@ -85,15 +85,15 @@ do {                                                                        \
    if (mask & PLANE_BIT) {                                             \
       const GLfloat dp0 = CLIP_DOTPROD( v0, A, B, C, D );              \
       const GLfloat dp1 = CLIP_DOTPROD( v1, A, B, C, D );              \
-      const GLboolean neg_dp0 = IS_NEGATIVE(dp0);                      \
-      const GLboolean neg_dp1 = IS_NEGATIVE(dp1);                      \
+      const GLboolean neg_dp0 = dp0 < 0.0f;                            \
+      const GLboolean neg_dp1 = dp1 < 0.0f;                            \
                                                                        \
       /* For regular clipping, we know from the clipmask that one      \
        * (or both) of these must be negative (otherwise we wouldn't    \
        * be here).                                                     \
        * For userclip, there is only a single bit for all active       \
        * planes, so we can end up here when there is nothing to do,    \
-       * hence the second IS_NEGATIVE() test:                          \
+       * hence the second < 0.0f test:                                 \
        */                                                              \
       if (neg_dp0 && neg_dp1)                                          \
          return; /* both vertices outside clip plane: discard */       \