gallium: add explicit control for point sprites (convert points to textured quads)
authorBrian <brian.paul@tungstengraphics.com>
Fri, 14 Mar 2008 22:13:35 +0000 (16:13 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 14 Mar 2008 22:13:35 +0000 (16:13 -0600)
New draw_enable_point_sprites() function.
Fixes spriteblast.c demo

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
src/gallium/auxiliary/draw/draw_wide_point.c

index e8473a4c572dba5ca644c27524662a778609f64b..4cca965ac1059c9cbba607692813941e96903b43 100644 (file)
@@ -86,6 +86,7 @@ struct draw_context *draw_create( void )
    draw->wide_point_threshold = 1000000.0; /* infinity */
    draw->wide_line_threshold = 1.0;
    draw->line_stipple = TRUE;
+   draw->point_sprite = TRUE;
 
    draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
 
@@ -266,6 +267,17 @@ draw_enable_line_stipple(struct draw_context *draw, boolean enable)
 }
 
 
+/**
+ * Tells draw module whether to convert points to quads for sprite mode.
+ */
+void
+draw_enable_point_sprites(struct draw_context *draw, boolean enable)
+{
+   draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
+   draw->point_sprite = enable;
+}
+
+
 /**
  * Ask the draw module for the location/slot of the given vertex attribute in
  * a post-transformed vertex.
index e8e2b56bae18130d3989422a8f1f31d97142e121..dae687e59063d2c49152d928fc4ab609b03ed67b 100644 (file)
@@ -96,6 +96,8 @@ void draw_wide_line_threshold(struct draw_context *draw, float threshold);
 
 void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
 
+void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
+
 
 boolean draw_use_sse(struct draw_context *draw);
 
index 379b6c3206ee0cb8bd509a0547ac91ce020b8bda..1c65c3d1b2a1eddc81e1b13af55680f974da2c16 100644 (file)
@@ -239,6 +239,7 @@ struct draw_context
    float wide_point_threshold; /**< convert pnts to tris if larger than this */
    float wide_line_threshold;  /**< convert lines to tris if wider than this */
    boolean line_stipple;       /**< do line stipple? */
+   boolean point_sprite;       /**< convert points to quads for sprites? */
    boolean use_sse;
 
    /* If a prim stage introduces new vertex attributes, they'll be stored here
index 602fa3429dedece2dc8e7f81d7abc86aa09422d9..33e55595081f2b22b95b4971c7205a7cc024b69b 100644 (file)
@@ -76,6 +76,10 @@ draw_need_pipeline(const struct draw_context *draw)
    if (draw->rasterizer->offset_cw || draw->rasterizer->offset_ccw)
       return TRUE;
 
+   /* point sprites */
+   if (draw->rasterizer->point_sprite && draw->point_sprite)
+      return TRUE;
+
    /* two-side lighting */
    if (draw->rasterizer->light_twoside)
       return TRUE;
@@ -110,7 +114,9 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
                  && !draw->rasterizer->line_smooth);
 
    /* drawing large points? */
-   if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
+   if (draw->rasterizer->point_sprite && draw->point_sprite)
+      wide_points = TRUE;
+   else if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
       wide_points = FALSE;
    else if (draw->rasterizer->point_size > draw->wide_point_threshold)
       wide_points = TRUE;
index 65bd50f2b8e40593d25d8e965c1b2c9b6f42b53a..c53f7e6cb3745e01666500a03bda7a2836bb8046 100644 (file)
@@ -184,7 +184,8 @@ static void widepoint_first_point( struct draw_stage *stage,
    wide->half_point_size = 0.5f * draw->rasterizer->point_size;
 
    /* XXX we won't know the real size if it's computed by the vertex shader! */
-   if (draw->rasterizer->point_size > draw->wide_point_threshold) {
+   if ((draw->rasterizer->point_size > draw->wide_point_threshold) ||
+       (draw->rasterizer->point_sprite && draw->point_sprite)) {
       stage->point = widepoint_point;
    }
    else {