Bug #10571: Fix 965 line clipping when neither vertex needs clipping.
authorDavid Moore <dcm@acm.org>
Thu, 30 Aug 2007 21:43:30 +0000 (14:43 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 30 Aug 2007 21:45:56 +0000 (14:45 -0700)
src/mesa/drivers/dri/i965/brw_clip_line.c

index 83182270eac6f2b7f17720362a440e960e70869e..0103be43458a027f04c3f920418cc14a6870794b 100644 (file)
@@ -130,6 +130,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
    struct brw_instruction *plane_loop;
    struct brw_instruction *plane_active;
    struct brw_instruction *is_negative;
+   struct brw_instruction *is_neg2;
    struct brw_instruction *not_culled;
    struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), BRW_REGISTER_TYPE_UD);
 
@@ -183,13 +184,20 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
            /* Coming back in.  We know that both cannot be negative
             * because the line would have been culled in that case.
             */
-           brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1));
-           brw_math_invert(p, c->reg.t, c->reg.t);
-           brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0);
 
-           brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 );
-           brw_MOV(p, c->reg.t0, c->reg.t);
-           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+           /* If both are positive, do nothing */
+             brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.dp0, brw_imm_f(0.0));
+             is_neg2 = brw_IF(p, BRW_EXECUTE_1);
+             {
+               brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1));
+               brw_math_invert(p, c->reg.t, c->reg.t);
+               brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0);
+
+               brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 );
+               brw_MOV(p, c->reg.t0, c->reg.t);
+               brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+            }
+            brw_ENDIF(p, is_neg2);
         }
         brw_ENDIF(p, is_negative);      
       }