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);
/** Software quad rendering pipeline */
struct {
+ struct quad_stage *polygon_stipple;
struct quad_stage *shade;
struct quad_stage *alpha_test;
struct quad_stage *stencil_test;
}
+/**
+ * Create a new primitive setup/render stage.
+ */
struct prim_stage *prim_setup( struct softpipe_context *softpipe )
{
struct setup_stage *setup = CALLOC_STRUCT(setup_stage);
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;
+ }
}
};
+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 );
--- /dev/null
+
+/**
+ * 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;
+}
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;
pipe/softpipe/sp_quad_depth_test.c \
pipe/softpipe/sp_quad_fs.c \
pipe/softpipe/sp_quad_output.c \
+ pipe/softpipe/sp_quad_stipple.c \
pipe/softpipe/sp_quad_stencil.c \
pipe/softpipe/sp_state_blend.c \
pipe/softpipe/sp_state_clip.c \
state_tracker/st_atom_scissor.c \
state_tracker/st_atom_setup.c \
state_tracker/st_atom_stencil.c \
+ state_tracker/st_atom_stipple.c \
state_tracker/st_atom_viewport.c \
state_tracker/st_cb_program.c \
state_tracker/st_draw.c \
&st_update_clip,
&st_update_fs,
&st_update_setup,
+ &st_update_polygon_stipple,
&st_update_viewport,
&st_update_scissor,
&st_update_blend,
const struct st_tracked_state st_update_depth;
const struct st_tracked_state st_update_fs;
const struct st_tracked_state st_update_setup;
+const struct st_tracked_state st_update_polygon_stipple;
const struct st_tracked_state st_update_viewport;
const struct st_tracked_state st_update_constants;
const struct st_tracked_state st_update_scissor;
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ /*
+ * \brief polygon stipple state
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+
+
+static void
+update_stipple( struct st_context *st )
+{
+ const GLuint sz = sizeof(st->state.poly_stipple.stipple);
+ assert(sz == sizeof(st->ctx->PolygonStipple));
+
+ if (memcmp(&st->state.poly_stipple.stipple, st->ctx->PolygonStipple, sz)) {
+ /* state has changed */
+ memcpy(st->state.poly_stipple.stipple, st->ctx->PolygonStipple, sz);
+ st->pipe->set_polygon_stipple(st->pipe, &st->state.poly_stipple);
+ }
+}
+
+
+const struct st_tracked_state st_update_polygon_stipple = {
+ .dirty = {
+ .mesa = (_NEW_POLYGONSTIPPLE),
+ .st = 0,
+ },
+ .update = update_stipple
+};