gallium: split draw_wide_prim stage into separate point/line stages.
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 29 Feb 2008 00:49:22 +0000 (17:49 -0700)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 29 Feb 2008 00:49:22 +0000 (17:49 -0700)
This fixes a validation/code-path problem.  Enabling the stage for the sake
of wide points also inadvertantly caused wide lines to be converted to tris
when we actually want them passed through, such as for the AA line stage.
This is just cleaner now.
Also, replace draw_convert_wide_lines() with draw_wide_line_threshold() as
was done for points.  Allows for 1-pixel lines to be converted too if needed.

src/gallium/auxiliary/draw/Makefile
src/gallium/auxiliary/draw/SConscript
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_validate.c

index c9980f0b8355a47e4a467cce6cfd7db1264e252d..2daa1636f36ec4e3dc1402693d868229b29ea237 100644 (file)
@@ -29,7 +29,9 @@ C_SOURCES = \
        draw_vf.c \
        draw_vf_generic.c \
        draw_vf_sse.c \
-       draw_wide_prims.c
+       draw_wide_line.c \
+       draw_wide_point.c
+
 
 include ../../Makefile.template
 
index 3302dc44f7885fcab10b113d5d2ffb8b317d2ca3..c18dcb2927ab97ce08abd03e2c137ee2f8916a85 100644 (file)
@@ -28,7 +28,8 @@ draw = env.ConvenienceLibrary(
                'draw_vf.c',
                'draw_vf_generic.c',
                'draw_vf_sse.c',
-               'draw_wide_prims.c',
+               'draw_wide_point.c',
+               'draw_wide_line.c'
        ])
 
 auxiliaries.insert(0, draw)
index 3500c34811c5fa59309e36574ea8ef3a5b1ae983..428b6209e05dea065760e89cf6eed752737fce01 100644 (file)
@@ -48,7 +48,8 @@ struct draw_context *draw_create( void )
 #endif
 
    /* create pipeline stages */
-   draw->pipeline.wide      = draw_wide_stage( draw );
+   draw->pipeline.wide_line  = draw_wide_line_stage( draw );
+   draw->pipeline.wide_point = draw_wide_point_stage( draw );
    draw->pipeline.stipple   = draw_stipple_stage( draw );
    draw->pipeline.unfilled  = draw_unfilled_stage( draw );
    draw->pipeline.twoside   = draw_twoside_stage( draw );
@@ -80,8 +81,9 @@ struct draw_context *draw_create( void )
 
    draw->shader_queue_flush = draw_vertex_shader_queue_flush;
 
+   /* these defaults are oriented toward the needs of softpipe */
    draw->wide_point_threshold = 1000000.0; /* infinity */
-   draw->convert_wide_lines = TRUE;
+   draw->wide_line_threshold = 1.0;
 
    draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
 
@@ -94,7 +96,8 @@ struct draw_context *draw_create( void )
 
 void draw_destroy( struct draw_context *draw )
 {
-   draw->pipeline.wide->destroy( draw->pipeline.wide );
+   draw->pipeline.wide_line->destroy( draw->pipeline.wide_line );
+   draw->pipeline.wide_point->destroy( draw->pipeline.wide_point );
    draw->pipeline.stipple->destroy( draw->pipeline.stipple );
    draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
    draw->pipeline.twoside->destroy( draw->pipeline.twoside );
@@ -232,14 +235,14 @@ draw_wide_point_threshold(struct draw_context *draw, float threshold)
 
 
 /**
- * Tells the draw module whether to convert wide lines (width != 1)
- * into triangles.
+ * Tells the draw module to draw lines with triangles if their width
+ * is greater than this threshold.
  */
 void
-draw_convert_wide_lines(struct draw_context *draw, boolean enable)
+draw_wide_line_threshold(struct draw_context *draw, float threshold)
 {
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-   draw->convert_wide_lines = enable;
+   draw->wide_line_threshold = threshold;
 }
 
 
index 99bfef55f43e75055873ef8050ead791227ef5fe..ab87b4127c0e9567f5277ffdb223a68cc9ff8b3a 100644 (file)
@@ -92,9 +92,7 @@ void draw_set_rasterize_stage( struct draw_context *draw,
 
 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
 
-void draw_convert_wide_points(struct draw_context *draw, boolean enable);
-
-void draw_convert_wide_lines(struct draw_context *draw, boolean enable);
+void draw_wide_line_threshold(struct draw_context *draw, float threshold);
 
 boolean draw_use_sse(struct draw_context *draw);
 
index e988e71d23e39c8d4733b6fbc7e654c27ba1c613..c732d723a7f3f51edb2bf1e228cf6935b4ba1a01 100644 (file)
@@ -186,7 +186,8 @@ struct draw_context
       struct draw_stage *aapoint;
       struct draw_stage *aaline;
       struct draw_stage *pstipple;
-      struct draw_stage *wide;
+      struct draw_stage *wide_line;
+      struct draw_stage *wide_point;
       struct draw_stage *rasterize;
    } pipeline;
 
@@ -219,7 +220,7 @@ struct draw_context
    unsigned nr_planes;
 
    float wide_point_threshold; /**< convert pnts to tris if larger than this */
-   boolean convert_wide_lines;  /**< convert wide lines to tris? */
+   float wide_line_threshold;  /**< convert lines to tris if wider than this */
    boolean use_sse;
 
    /* If a prim stage introduces new vertex attributes, they'll be stored here
@@ -304,7 +305,8 @@ extern struct draw_stage *draw_clip_stage( struct draw_context *context );
 extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
 extern struct draw_stage *draw_cull_stage( struct draw_context *context );
 extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
-extern struct draw_stage *draw_wide_stage( struct draw_context *context );
+extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
+extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
 extern struct draw_stage *draw_validate_stage( struct draw_context *context );
 
 
index ded7d10c081e9fb1bad054dba47ecec7cc10b7f7..084eee9b6e9ace87969f345a35ee104a0fdb6c78 100644 (file)
@@ -53,8 +53,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
    stage->next = next;
 
    /* drawing wide lines? */
-   wide_lines = (draw->rasterizer->line_width != 1.0
-                 && draw->convert_wide_lines
+   wide_lines = (draw->rasterizer->line_width > draw->wide_line_threshold
                  && !draw->rasterizer->line_smooth);
 
    /* drawing large points? */
@@ -82,11 +81,14 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
       next = draw->pipeline.aapoint;
    }
 
-   if (wide_lines ||
-       wide_points ||
-       draw->rasterizer->point_sprite) {
-      draw->pipeline.wide->next = next;
-      next = draw->pipeline.wide;
+   if (wide_lines) {
+      draw->pipeline.wide_line->next = next;
+      next = draw->pipeline.wide_line;
+   }
+
+   if (wide_points || draw->rasterizer->point_sprite) {
+      draw->pipeline.wide_point->next = next;
+      next = draw->pipeline.wide_point;
    }
 
    if (draw->rasterizer->line_stipple_enable) {