Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / src / gallium / auxiliary / draw / draw_pipe_clip.c
index c11ed934a460b8372a5d63543320cc93e0767465..0670268a196f2c6d933dfa32fb5654bafbc06ca2 100644 (file)
@@ -32,7 +32,9 @@
  */
 
 
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
 #include "pipe/p_shader_tokens.h"
 
 #include "draw_vs.h"
@@ -113,6 +115,7 @@ static void interp( const struct clipper *clip,
                    const struct vertex_header *in )
 {
    const unsigned nr_attrs = clip->stage.draw->vs.num_vs_outputs;
+   const unsigned pos_attr = clip->stage.draw->vs.position_output;
    unsigned j;
 
    /* Vertex header.
@@ -138,18 +141,17 @@ static void interp( const struct clipper *clip,
       const float *trans = clip->stage.draw->viewport.translate;
       const float oow = 1.0f / pos[3];
 
-      dst->data[0][0] = pos[0] * oow * scale[0] + trans[0];
-      dst->data[0][1] = pos[1] * oow * scale[1] + trans[1];
-      dst->data[0][2] = pos[2] * oow * scale[2] + trans[2];
-      dst->data[0][3] = oow;
+      dst->data[pos_attr][0] = pos[0] * oow * scale[0] + trans[0];
+      dst->data[pos_attr][1] = pos[1] * oow * scale[1] + trans[1];
+      dst->data[pos_attr][2] = pos[2] * oow * scale[2] + trans[2];
+      dst->data[pos_attr][3] = oow;
    }
 
    /* Other attributes
-    * Note: start at 1 to skip winpos (data[0]) since we just computed
-    * it above.
     */
-   for (j = 1; j < nr_attrs; j++) {
-      interp_attr(dst->data[j], t, in->data[j], out->data[j]);
+   for (j = 0; j < nr_attrs; j++) {
+      if (j != pos_attr)
+         interp_attr(dst->data[j], t, in->data[j], out->data[j]);
    }
 }
 
@@ -171,7 +173,7 @@ static void emit_poly( struct draw_stage *stage,
    header.flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
    header.pad = 0;
 
-   for (i = 2; i < n; i++, header.flags = 0) {
+   for (i = 2; i < n; i++, header.flags = edge_middle) {
       header.v[0] = inlist[i-1];
       header.v[1] = inlist[i];
       header.v[2] = inlist[0]; /* keep in v[2] for flatshading */
@@ -494,6 +496,7 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw )
       goto fail;
 
    clipper->stage.draw = draw;
+   clipper->stage.name = "clipper";
    clipper->stage.point = clip_point;
    clipper->stage.line = clip_first_line;
    clipper->stage.tri = clip_first_tri;