summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-07-11 11:34:19 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-07-11 11:34:19 -0600
commite89bd0fbc56ecfb96f3aff926c5891c45221dd37 (patch)
tree9522b593d58a4117c21b42eab0010812dad7c62a /src/mesa/pipe/softpipe
parent300e97081e7e752c0ff9133149d15935baac7a46 (diff)
Implement polygon stipple state tracking, application.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c1
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c3
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_stipple.c56
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c7
7 files changed, 72 insertions, 1 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 50434600c3..a5bd61b784 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -83,6 +83,7 @@ struct pipe_context *softpipe_create( void )
softpipe->pipe.draw_vb = softpipe_draw_vb;
softpipe->pipe.clear = softpipe_clear;
+ softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
softpipe->quad.shade = sp_quad_shade_stage(softpipe);
softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe);
softpipe->quad.blend = sp_quad_blend_stage(softpipe);
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index 2379a99b81..21d6108ac6 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -117,6 +117,7 @@ struct softpipe_context {
/** Software quad rendering pipeline */
struct {
+ struct quad_stage *polygon_stipple;
struct quad_stage *shade;
struct quad_stage *alpha_test;
struct quad_stage *stencil_test;
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 332113979c..0148a26259 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -922,6 +922,9 @@ static void setup_end( struct prim_stage *stage )
}
+/**
+ * Create a new primitive setup/render stage.
+ */
struct prim_stage *prim_setup( struct softpipe_context *softpipe )
{
struct setup_stage *setup = CALLOC_STRUCT(setup_stage);
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c
index 31278f529d..aba5ab280e 100644
--- a/src/mesa/pipe/softpipe/sp_quad.c
+++ b/src/mesa/pipe/softpipe/sp_quad.c
@@ -37,4 +37,8 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->quad.first = sp->quad.shade;
}
+ if (sp->setup.poly_stipple_enable) {
+ sp->quad.polygon_stipple->next = sp->quad.first;
+ sp->quad.first = sp->quad.polygon_stipple;
+ }
}
diff --git a/src/mesa/pipe/softpipe/sp_quad.h b/src/mesa/pipe/softpipe/sp_quad.h
index df416dfa7f..8b8e12261b 100644
--- a/src/mesa/pipe/softpipe/sp_quad.h
+++ b/src/mesa/pipe/softpipe/sp_quad.h
@@ -46,6 +46,7 @@ struct quad_stage {
};
+struct quad_stage *sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_alpha_test_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe );
diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c
new file mode 100644
index 0000000000..f9a3c0ba26
--- /dev/null
+++ b/src/mesa/pipe/softpipe/sp_quad_stipple.c
@@ -0,0 +1,56 @@
+
+/**
+ * quad polygon stipple stage
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "sp_context.h"
+#include "sp_headers.h"
+#include "sp_quad.h"
+#include "pipe/p_defines.h"
+
+
+/**
+ * Apply polygon stipple to quads produced by triangle rasterization
+ */
+static void
+stipple_quad(struct quad_stage *qs, struct quad_header *quad)
+{
+ struct softpipe_context *softpipe = qs->softpipe;
+ const GLint col0 = quad->x0 % 32;
+ const GLint row0 = quad->y0 % 32;
+ const GLuint stipple0 = softpipe->poly_stipple.stipple[row0];
+ const GLuint stipple1 = softpipe->poly_stipple.stipple[row0 + 1];
+ GLbitfield mask = 0x0;
+
+ /* XXX this could be optimize a bit to use just two conditionals */
+ if ((1 << col0) & stipple0)
+ mask |= MASK_BOTTOM_LEFT;
+
+ if ((2 << col0) & stipple0)
+ mask |= MASK_BOTTOM_RIGHT;
+
+ if ((1 << col0) & stipple1)
+ mask |= MASK_TOP_LEFT;
+
+ if ((2 << col0) & stipple1)
+ mask |= MASK_TOP_RIGHT;
+
+ quad->mask &= mask;
+
+ if (quad->mask)
+ qs->next->run(qs->next, quad);
+}
+
+
+struct quad_stage *
+sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe )
+{
+ struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
+
+ stage->softpipe = softpipe;
+ stage->run = stipple_quad;
+
+ return stage;
+}
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index 429ae55397..34c893e396 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -137,7 +137,12 @@ void softpipe_update_derived( struct softpipe_context *softpipe )
if (softpipe->dirty & (SP_NEW_SETUP | SP_NEW_FS))
calculate_vertex_layout( softpipe );
- if (softpipe->dirty & (SP_NEW_BLEND | SP_NEW_DEPTH_TEST | SP_NEW_ALPHA_TEST | SP_NEW_FS))
+ if (softpipe->dirty & (SP_NEW_BLEND |
+ SP_NEW_DEPTH_TEST |
+ SP_NEW_ALPHA_TEST |
+ SP_NEW_STENCIL |
+ SP_NEW_SETUP |
+ SP_NEW_FS))
sp_build_quad_pipeline(softpipe);
softpipe->dirty = 0;