i965/fs: Swap if/else conditions in SEL peephole.
[mesa.git] / src / gallium / auxiliary / draw / draw_pipe_clip.c
index 8bdb882218b0f935e19a6340924bb7e07e200d64..d8b56de4d2ff576a545c672637a10f6f7e1e7cc4 100644 (file)
@@ -588,7 +588,12 @@ do_clip_line( struct draw_stage *stage,
 
    if (v0->clipmask) {
       interp( clipper, stage->tmp[0], t0, v0, v1, viewport_index );
-      copy_flat(stage, stage->tmp[0], v0);
+      if (stage->draw->rasterizer->flatshade_first) {
+         copy_flat(stage, stage->tmp[0], v0);  /* copy v0 color to tmp[0] */
+      }
+      else {
+         copy_flat(stage, stage->tmp[0], v1);  /* copy v1 color to tmp[0] */
+      }
       newprim.v[0] = stage->tmp[0];
    }
    else {
@@ -597,6 +602,12 @@ do_clip_line( struct draw_stage *stage,
 
    if (v1->clipmask) {
       interp( clipper, stage->tmp[1], t1, v1, v0, viewport_index );
+      if (stage->draw->rasterizer->flatshade_first) {
+         copy_flat(stage, stage->tmp[1], v0);  /* copy v0 color to tmp[1] */
+      }
+      else {
+         copy_flat(stage, stage->tmp[1], v1);  /* copy v1 color to tmp[1] */
+      }
       newprim.v[1] = stage->tmp[1];
    }
    else {
@@ -635,8 +646,13 @@ clip_point_guard_xy( struct draw_stage *stage,
          clipmask &= ~(1 << plane_idx);  /* turn off this plane's bit */
          /* TODO: this should really do proper guardband clipping,
           * currently just throw out infs/nans.
+          * Also note that vertices with negative w values MUST be tossed
+          * out (not sure if proper guardband clipping would do this
+          * automatically). These would usually be captured by depth clip
+          * too but this can be disabled.
           */
-         if (util_is_inf_or_nan(header->v[0]->clip[0]) ||
+         if (header->v[0]->clip[3] <= 0.0f ||
+             util_is_inf_or_nan(header->v[0]->clip[0]) ||
              util_is_inf_or_nan(header->v[0]->clip[1]))
             return;
       }
@@ -645,7 +661,6 @@ clip_point_guard_xy( struct draw_stage *stage,
 }
 
 
-
 static void
 clip_first_point( struct draw_stage *stage,
                   struct prim_header *header )