summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-07-11 11:34:19 -0600
committerBrian <[email protected]>2007-07-11 11:34:19 -0600
commite89bd0fbc56ecfb96f3aff926c5891c45221dd37 (patch)
tree9522b593d58a4117c21b42eab0010812dad7c62a /src/mesa/pipe
parent300e97081e7e752c0ff9133149d15935baac7a46 (diff)
Implement polygon stipple state tracking, application.
Diffstat (limited to 'src/mesa/pipe')
-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 50434600c3f..a5bd61b7842 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 2379a99b81f..21d6108ac6e 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 332113979c0..0148a26259b 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 31278f529d7..aba5ab280e6 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 df416dfa7f2..8b8e12261b4 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 00000000000..f9a3c0ba265
--- /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 429ae55397e..34c893e396a 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;