draw: take primitive into account when deciding if the pipeline is active
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 25 Mar 2008 15:17:53 +0000 (15:17 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 25 Mar 2008 15:22:32 +0000 (15:22 +0000)
src/gallium/auxiliary/draw/draw_passthrough.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_validate.c

index dd00894..2198079 100644 (file)
@@ -424,7 +424,7 @@ draw_passthrough_arrays(struct draw_context *draw,
 
    debug_printf("%s %d %d %d\n", __FUNCTION__, prim, start, count);
 
-   if (draw_need_pipeline(draw))
+   if (draw_need_pipeline(draw, prim))
       return FALSE;
 
    debug_printf("%s AAA\n", __FUNCTION__);
index 0c5afca..8a87980 100644 (file)
@@ -364,7 +364,8 @@ extern void draw_vertex_shader_queue_flush( struct draw_context *draw );
 
 extern void draw_update_vertex_fetch( struct draw_context *draw );
 
-extern boolean draw_need_pipeline(const struct draw_context *draw);
+extern boolean draw_need_pipeline(const struct draw_context *draw,
+                                  unsigned prim );
 
 
 /* Passthrough mode (second attempt):
index d7169f7..3ec31ec 100644 (file)
@@ -55,7 +55,7 @@ draw_pt_arrays(struct draw_context *draw,
                unsigned start, 
                unsigned count)
 {
-   const boolean pipeline = draw_need_pipeline(draw);
+   const boolean pipeline = draw_need_pipeline(draw, prim);
    const boolean cliptest = !draw->rasterizer->bypass_clipping;
    const boolean shading  = !draw->rasterizer->bypass_vs;
    struct draw_pt_front_end *frontend = NULL;
index 70b477b..e163e07 100644 (file)
 #include "pipe/p_defines.h"
 #include "draw_private.h"
 
+static boolean points( unsigned prim )
+{
+   return (prim == PIPE_PRIM_POINTS);
+}
+
+static boolean lines( unsigned prim )
+{
+   return (prim == PIPE_PRIM_LINES ||
+           prim == PIPE_PRIM_LINE_STRIP ||
+           prim == PIPE_PRIM_LINE_LOOP);
+}
+
+static boolean triangles( unsigned prim )
+{
+   return prim >= PIPE_PRIM_TRIANGLES;
+}
 
 /**
  * Check if we need any special pipeline stages, or whether
  * pipeline stages.
  */
 boolean
-draw_need_pipeline(const struct draw_context *draw)
+draw_need_pipeline(const struct draw_context *draw, 
+                   unsigned int prim )
 {
-   /* line stipple */
-   if (draw->rasterizer->line_stipple_enable && draw->line_stipple)
-      return TRUE;
-
-   /* wide lines */
-   if (draw->rasterizer->line_width > draw->wide_line_threshold)
-      return TRUE;
+   /* Don't have to worry about triangles turning into lines/points
+    * and triggering the pipeline, because we have to trigger the
+    * pipeline *anyway* if unfilled mode is active.
+    */
+   if (lines(prim)) 
+   {
+      /* line stipple */
+      if (draw->rasterizer->line_stipple_enable && draw->line_stipple)
+         return TRUE;
 
-   /* large points */
-   if (draw->rasterizer->point_size > draw->wide_point_threshold)
-      return TRUE;
+      /* wide lines */
+      if (draw->rasterizer->line_width > draw->wide_line_threshold)
+         return TRUE;
 
-   /* AA lines */
-   if (draw->rasterizer->line_smooth && draw->pipeline.aaline)
-      return TRUE;
-
-   /* AA points */
-   if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
-      return TRUE;
+      /* AA lines */
+      if (draw->rasterizer->line_smooth && draw->pipeline.aaline)
+         return TRUE;
+   }
 
-   /* polygon stipple */
-   if (draw->rasterizer->poly_stipple_enable && draw->pipeline.pstipple)
-      return TRUE;
+   if (points(prim))
+   {
+      /* large points */
+      if (draw->rasterizer->point_size > draw->wide_point_threshold)
+         return TRUE;
 
-   /* unfilled polygons */
-   if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
-       draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL)
-      return TRUE;
+      /* AA points */
+      if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
+         return TRUE;
 
-   /* polygon offset */
-   if (draw->rasterizer->offset_cw || draw->rasterizer->offset_ccw)
-      return TRUE;
+      /* point sprites */
+      if (draw->rasterizer->point_sprite && draw->point_sprite)
+         return TRUE;
+   }
 
-   /* point sprites */
-   if (draw->rasterizer->point_sprite && draw->point_sprite)
-      return TRUE;
 
-   /* two-side lighting */
-   if (draw->rasterizer->light_twoside)
-      return TRUE;
+   if (triangles(prim)) 
+   {
+      /* polygon stipple */
+      if (draw->rasterizer->poly_stipple_enable && draw->pipeline.pstipple)
+         return TRUE;
+
+      /* unfilled polygons */
+      if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
+          draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL)
+         return TRUE;
+      
+      /* polygon offset */
+      if (draw->rasterizer->offset_cw || draw->rasterizer->offset_ccw)
+         return TRUE;
+
+      /* two-side lighting */
+      if (draw->rasterizer->light_twoside)
+         return TRUE;
+   }
 
    /* polygon cull - this is difficult - hardware can cull just fine
     * most of the time (though sometimes CULL_NEITHER is unsupported.