Mesa (master): gallium: add point_quad_rasterization bit to rasterizer state

Roland Scheidegger sroland at kemper.freedesktop.org
Tue Feb 9 18:32:49 UTC 2010


Module: Mesa
Branch: master
Commit: 68f93ea3eb83cfad014b8ec93cec3564c1aa9833
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=68f93ea3eb83cfad014b8ec93cec3564c1aa9833

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Thu Feb  4 21:35:28 2010 +0100

gallium: add point_quad_rasterization bit to rasterizer state

This determines if points should be rasterized according to GL point rules
or as normal quads (GL point sprites / d3d points / d3d point sprites).

---

 src/gallium/auxiliary/draw/draw_pipe_wide_point.c |    1 +
 src/gallium/docs/source/cso/rasterizer.rst        |   14 ++++++++++++--
 src/gallium/drivers/nv30/nv30_state.c             |    2 +-
 src/gallium/drivers/nv40/nv40_state.c             |    2 +-
 src/gallium/drivers/nv50/nv50_state.c             |    2 +-
 src/gallium/drivers/softpipe/sp_video_context.c   |    1 +
 src/gallium/drivers/svga/svga_pipe_rasterizer.c   |    1 +
 src/gallium/drivers/trace/tr_dump_state.c         |    1 +
 src/gallium/include/pipe/p_state.h                |    1 +
 src/mesa/state_tracker/st_atom_rasterizer.c       |    3 ++-
 10 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index d9d4d2a..fdabce7 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -128,6 +128,7 @@ static void set_texcoords(const struct widepoint_stage *wide,
 static void widepoint_point( struct draw_stage *stage,
                              struct prim_header *header )
 {
+   /* XXX should take point_quad_rasterization into account? */
    const struct widepoint_stage *wide = widepoint_stage(stage);
    const unsigned pos = draw_current_shader_position_output(stage->draw);
    const boolean sprite = (boolean) stage->draw->rasterizer->sprite_coord_enable;
diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst
index 721229d..00d65fc 100644
--- a/src/gallium/docs/source/cso/rasterizer.rst
+++ b/src/gallium/docs/source/cso/rasterizer.rst
@@ -85,8 +85,10 @@ point_size
 sprite_coord_enable
     Specifies if a coord has its texture coordinates replaced or not. This
     is a packed bitfield containing the enable for all coords - if all are 0
-    point sprites are effectively disabled. If any coord is non-zero,
-    point_smooth should be disabled.
+    point sprites are effectively disabled, though points may still be
+    rendered slightly different according to point_quad_rasterization.
+    If any coord is non-zero, point_smooth should be disabled, and
+    point_quad_rasterization enabled.
     If enabled, the four vertices of the resulting quad will be assigned
     texture coordinates, according to sprite_coord_mode.
 sprite_coord_mode
@@ -103,6 +105,14 @@ sprite_coord_mode
     Note that when geometry shaders are available, this state could be
     removed.  A special geometry shader defined by the state tracker could
     convert the incoming points into quads with the proper texture coords.
+point_quad_rasterization
+    This determines if points should be rasterized as quads or points.
+    d3d always uses quad rasterization for points, regardless if point sprites
+    are enabled or not, but OGL has different rules. If point_quad_rasterization
+    is set, point_smooth should be disabled, and points will be rendered as
+    squares even if multisample is enabled.
+    sprite_coord_enable should be zero if point_quad_rasterization is not
+    enabled.
 
 scissor
     Whether the scissor test is enabled.
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index ab9fc52..66096de 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -391,7 +391,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
 	}
 
 	so_method(so, rankine, NV34TCL_POINT_SPRITE, 1);
-	if (cso->sprite_coord_enable) {
+	if (cso->point_quad_rasterization) {
 		unsigned psctl = (1 << 0), i;
 
 		for (i = 0; i < 8; i++) {
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index a5c5e29..5084c48 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -401,7 +401,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
 	}
 
 	so_method(so, curie, NV40TCL_POINT_SPRITE, 1);
-	if (cso->sprite_coord_enable) {
+	if (cso->point_quad_rasterization) {
 		unsigned psctl = (1 << 0), i;
 
 		for (i = 0; i < 8; i++) {
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index cbe2f34..f19a21d 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -318,7 +318,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
 	so_data  (so, fui(cso->point_size));
 
 	so_method(so, tesla, NV50TCL_POINT_SPRITE_ENABLE, 1);
-	so_data  (so, cso->sprite_coord_enable ? 1 : 0);
+	so_data  (so, cso->point_quad_rasterization ? 1 : 0);
 
 	so_method(so, tesla, NV50TCL_POLYGON_MODE_FRONT, 3);
 	if (cso->front_winding == PIPE_WINDING_CCW) {
diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c
index 7dde3c1..cfa2a0b 100644
--- a/src/gallium/drivers/softpipe/sp_video_context.c
+++ b/src/gallium/drivers/softpipe/sp_video_context.c
@@ -178,6 +178,7 @@ init_pipe_state(struct sp_mpeg12_context *ctx)
    rast.bypass_vs_clip_and_viewport = 0;
    rast.line_width = 1;
    rast.point_smooth = 0;
+   rast.point_quad_rasterization = 0;
    rast.point_size = 1;
    rast.offset_units = 1;
    rast.offset_scale = 1;
diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c
index 0a613cb..09ccb71 100644
--- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c
+++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c
@@ -72,6 +72,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
    /* poly_smooth            - XXX: no fallback available */
    /* poly_stipple_enable    - draw module */
    /* sprite_coord_enable    - ? */
+   /* point_quad_rasterization - ? */
    /* point_size_per_vertex  - ? */
    /* sprite_coord_mode      - ??? */
    /* bypass_vs_viewport_and_clip        - handled by viewport setup */
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index ed327f6..720b6cd 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -114,6 +114,7 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
    trace_dump_member(bool, state, point_smooth);
    trace_dump_member(uint, state, sprite_coord_enable);
    trace_dump_member(bool, state, sprite_coord_mode);
+   trace_dump_member(bool, state, point_quad_rasterization);
    trace_dump_member(bool, state, point_size_per_vertex);
    trace_dump_member(bool, state, multisample);
    trace_dump_member(bool, state, line_smooth);
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 50a4cd6..4387b92 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -103,6 +103,7 @@ struct pipe_rasterizer_state
    unsigned point_smooth:1;
    unsigned sprite_coord_enable:PIPE_MAX_SHADER_OUTPUTS;
    unsigned sprite_coord_mode:1;     /**< PIPE_SPRITE_COORD_ */
+   unsigned point_quad_rasterization:1; /** points rasterized as quads or points */
    unsigned point_size_per_vertex:1; /**< size computed in vertex shader */
    unsigned multisample:1;         /* XXX maybe more ms state in future */
    unsigned line_smooth:1;
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 16c842d..9c9a99b 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -183,7 +183,7 @@ static void update_raster_state( struct st_context *st )
 
    if (ctx->Polygon.StippleFlag)
       raster->poly_stipple_enable = 1;
-     
+
    /* _NEW_POINT
     */
    raster->point_size = ctx->Point.Size;
@@ -202,6 +202,7 @@ static void update_raster_state( struct st_context *st )
             raster->sprite_coord_enable |= 1 << i;
          }
       }
+      raster->point_quad_rasterization = 1;
    }
 
    /* ST_NEW_VERTEX_PROGRAM




More information about the mesa-commit mailing list