i965/vec4: Simplify opt_reduce_swizzle() using the swizzle utils.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_clip_line.c
index 73c9687d9b8456f6223859d883c6d5f154e9b9d1..3b8af58ec7631d58636006f33aff69db1a0d9652 100644 (file)
@@ -1,6 +1,6 @@
 /*
  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ Intel funded Tungsten Graphics to
  develop this 3D driver.
 
  Permission is hereby granted, free of charge, to any person obtaining
@@ -26,7 +26,7 @@
  **********************************************************************/
  /*
   * Authors:
-  *   Keith Whitwell <keith@tungstengraphics.com>
+  *   Keith Whitwell <keithw@vmware.com>
   */
 
 #include "main/glheader.h"
@@ -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 {
@@ -156,14 +156,13 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
    /* -ve rhw workaround */
    if (brw->has_negative_rhw_bug) {
-      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
               brw_imm_ud(1<<20));
+      brw_inst_set_cond_modifier(brw, brw_last_inst, BRW_CONDITIONAL_NZ);
       brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f));
+      brw_inst_set_pred_control(brw, brw_last_inst, BRW_PREDICATE_NORMAL);
    }
 
-   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
    /* Set the initial vertex source mask: The first 6 planes are the bounds
     * of the view volume; the next 8 planes are the user clipping planes.
     */
@@ -177,13 +176,13 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
    {
       /* if (planemask & 1)
        */
-      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_AND(p, v1_null_ud, c->reg.planemask, brw_imm_ud(1));
+      brw_inst_set_cond_modifier(brw, brw_last_inst, BRW_CONDITIONAL_NZ);
 
       brw_IF(p, BRW_EXECUTE_1);
       {
-         brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
          brw_AND(p, v1_null_ud, c->reg.vertex_src_mask, brw_imm_ud(1));
+         brw_inst_set_cond_modifier(brw, brw_last_inst, BRW_CONDITIONAL_NZ);
          brw_IF(p, BRW_EXECUTE_1);
          {
             /* user clip distance: just fetch the correct float from each vertex */
@@ -229,7 +228,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
              brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t1 );
              brw_MOV(p, c->reg.t1, c->reg.t);
-             brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+             brw_inst_set_pred_control(brw, brw_last_inst, BRW_PREDICATE_NORMAL);
         }
         brw_ELSE(p);
         {
@@ -251,7 +250,8 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
                  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_inst_set_pred_control(brw, brw_last_inst,
+                                           BRW_PREDICATE_NORMAL);
              }
 
              if (brw->has_negative_rhw_bug) {
@@ -268,12 +268,15 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
       /* while (planemask>>=1) != 0
        */
-      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
+      brw_inst_set_cond_modifier(brw, brw_last_inst, BRW_CONDITIONAL_NZ);
       brw_SHR(p, c->reg.vertex_src_mask, c->reg.vertex_src_mask, brw_imm_ud(1));
+      brw_inst_set_pred_control(brw, brw_last_inst, BRW_PREDICATE_NORMAL);
       brw_ADD(p, c->reg.clipdistance_offset, c->reg.clipdistance_offset, brw_imm_w(sizeof(float)));
+      brw_inst_set_pred_control(brw, brw_last_inst, BRW_PREDICATE_NORMAL);
    }
    brw_WHILE(p);
+   brw_inst_set_pred_control(brw, brw_last_inst, BRW_PREDICATE_NORMAL);
 
    brw_ADD(p, c->reg.t, c->reg.t0, c->reg.t1);
    brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.t, brw_imm_f(1.0));