gallium: add a flag to turn on gl rasterization rules
authorKeith Whitwell <keith@tungstengraphics.com>
Wed, 2 Apr 2008 10:38:33 +0000 (11:38 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Wed, 2 Apr 2008 10:38:33 +0000 (11:38 +0100)
Use this to set up hardware rasterization (if your hardware can
do it) or otherwise turn on various tweaks in the draw module.

Currently only hooked up to point biasing code.

src/gallium/auxiliary/draw/draw_wide_point.c
src/gallium/include/pipe/p_state.h
src/mesa/state_tracker/st_atom_rasterizer.c

index 86281ca3d8c755f148e1b0aa40f2bba12f11b693..6fc7c9fcd7a8726768cf4512ad12ee29561c793b 100644 (file)
@@ -41,6 +41,9 @@ struct widepoint_stage {
    float point_size_min;
    float point_size_max;
 
+   float xbias;
+   float ybias;
+
    uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS];
    uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS];
    uint num_texcoords;
@@ -126,8 +129,6 @@ static void widepoint_point( struct draw_stage *stage,
    float *pos2 = v2->data[0];
    float *pos3 = v3->data[0];
 
-   const float xbias = 0.0, ybias = -0.125;
-
    /* point size is either per-vertex or fixed size */
    if (wide->psize_slot >= 0) {
       half_size = header->v[0]->data[wide->psize_slot][0];
@@ -144,10 +145,10 @@ static void widepoint_point( struct draw_stage *stage,
       half_size = wide->half_point_size;
    }
 
-   left_adj = -half_size + xbias;
-   right_adj = half_size + xbias;
-   bot_adj = half_size + ybias;
-   top_adj = -half_size + ybias;
+   left_adj = -half_size + wide->xbias;
+   right_adj = half_size + wide->xbias;
+   bot_adj = half_size + wide->ybias;
+   top_adj = -half_size + wide->ybias;
 
    pos0[0] += left_adj;
    pos0[1] += top_adj;
@@ -194,6 +195,12 @@ static void widepoint_first_point( struct draw_stage *stage,
    wide->half_point_size = 0.5f * draw->rasterizer->point_size;
    wide->point_size_min = draw->rasterizer->point_size_min;
    wide->point_size_max = draw->rasterizer->point_size_max;
+   wide->xbias = 0.0;
+   wide->ybias = 0.0;
+
+   if (draw->rasterizer->gl_rasterization_rules) {
+      wide->ybias = -0.125;
+   }
 
    /* 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) ||
index e407e3bc725b48845a2af577268b6e0bb9f6e429..3593446e1c4a2aab9a2ec3235ea2cabd26ba5b63 100644 (file)
@@ -115,6 +115,7 @@ struct pipe_rasterizer_state
                             still needed though, to indicate inputs/outputs */
    unsigned origin_lower_left:1;  /**< Is (0,0) the lower-left corner? */
    unsigned flatshade_first:1;   /**< take color attribute from the first vertex of a primitive */
+   unsigned gl_rasterization_rules:1; /**< enable tweaks for GL rasterization?  */
 
    float line_width;
    float point_size;           /**< used when no per-vertex size */
index 14c26c16c0410b8ab22433ce14aa5cc7aba340d7..bb14cf9045a6bf47d5240b2eed01e88f069804a5 100644 (file)
@@ -261,6 +261,8 @@ static void update_raster_state( struct st_context *st )
    if (ctx->Scissor.Enabled)
       raster->scissor = 1;
 
+   raster->gl_rasterization_rules = 1;
+
    cso_set_rasterizer(st->cso_context, raster);
 }