gallium: a lot more complete implementation of stream output
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_post_vs.c
index 08d77649a364ec51cfb92fa1fdef66db7c006e05..5525dfc748df616e315843e95081f6eee8b075d3 100644 (file)
@@ -30,7 +30,6 @@
 #include "draw/draw_context.h"
 #include "draw/draw_private.h"
 #include "draw/draw_vbuf.h"
-#include "draw/draw_vertex.h"
 #include "draw/draw_pt.h"
 
 struct pt_post_vs {
@@ -100,7 +99,7 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
    struct vertex_header *out = vertices;
    const float *scale = pvs->draw->viewport.scale;
    const float *trans = pvs->draw->viewport.translate;
-   const unsigned pos = pvs->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(pvs->draw);
    unsigned clipped = 0;
    unsigned j;
 
@@ -109,6 +108,11 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
    for (j = 0; j < count; j++) {
       float *position = out->data[pos];
 
+#if 0
+      debug_printf("%d) io = %p, data = %p = [%f, %f, %f, %f]\n",
+                   j, out, position, position[0], position[1], position[2], position[3]);
+#endif
+
       out->clip[0] = position[0];
       out->clip[1] = position[1];
       out->clip[2] = position[2];
@@ -156,8 +160,9 @@ post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
                                       unsigned stride )
 {
    unsigned j;
-   if (!post_vs_cliptest_viewport_gl( pvs, vertices, count, stride))
-      return FALSE;
+   boolean needpipe;
+
+   needpipe = post_vs_cliptest_viewport_gl( pvs, vertices, count, stride);
 
    /* If present, copy edgeflag VS output into vertex header.
     * Otherwise, leave header as is.
@@ -168,10 +173,12 @@ post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
 
       for (j = 0; j < count; j++) {
          const float *edgeflag = out->data[ef];
-         out->edgeflag = (edgeflag[0] != 1.0f);
+         out->edgeflag = !(edgeflag[0] != 1.0f);
+         needpipe |= !out->edgeflag;
+         out = (struct vertex_header *)( (char *)out + stride );
       }
    }
-   return TRUE;
+   return needpipe;
 }
 
 
@@ -187,7 +194,7 @@ static boolean post_vs_viewport( struct pt_post_vs *pvs,
    struct vertex_header *out = vertices;
    const float *scale = pvs->draw->viewport.scale;
    const float *trans = pvs->draw->viewport.translate;
-   const unsigned pos = pvs->draw->vs.position_output;
+   const unsigned pos = draw_current_shader_position_output(pvs->draw);
    unsigned j;
 
    if (0) debug_printf("%s\n", __FUNCTION__);