aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast_setup
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-10-08 13:15:52 +0000
committermarha <marha@users.sourceforge.net>2009-10-08 13:15:52 +0000
commita0c4815433ccd57322f4f7703ca35e9ccfa59250 (patch)
treef5213802ec12adb86ec3136001c1c29fe5343700 /mesalib/src/mesa/swrast_setup
parentc73dc01b6de45612b24dc2dd34fba24d81ebf46c (diff)
downloadvcxsrv-a0c4815433ccd57322f4f7703ca35e9ccfa59250.tar.gz
vcxsrv-a0c4815433ccd57322f4f7703ca35e9ccfa59250.tar.bz2
vcxsrv-a0c4815433ccd57322f4f7703ca35e9ccfa59250.zip
Added MesaLib-7.6
Diffstat (limited to 'mesalib/src/mesa/swrast_setup')
-rw-r--r--mesalib/src/mesa/swrast_setup/descrip.mms42
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_context.c317
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_context.h46
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_triangle.c317
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_triangle.h38
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_tritmp.h266
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_vb.h38
-rw-r--r--mesalib/src/mesa/swrast_setup/swrast_setup.h61
8 files changed, 1125 insertions, 0 deletions
diff --git a/mesalib/src/mesa/swrast_setup/descrip.mms b/mesalib/src/mesa/swrast_setup/descrip.mms
new file mode 100644
index 000000000..32ffd8073
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/descrip.mms
@@ -0,0 +1,42 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define tnl [-.tnl]
+ define vbo [-.vbo]
+ define swrast [-.swrast]
+ define array_cache [-.array_cache]
+ define glapi [-.glapi]
+ define main [-.main]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES = ss_context.c ss_triangle.c
+
+OBJECTS = ss_context.obj,ss_triangle.obj
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+ss_context.obj : ss_context.c
+ss_triangle.obj : ss_triangle.c
diff --git a/mesalib/src/mesa/swrast_setup/ss_context.c b/mesalib/src/mesa/swrast_setup/ss_context.c
new file mode 100644
index 000000000..61172f997
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/ss_context.c
@@ -0,0 +1,317 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/colormac.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vertex.h"
+#include "swrast_setup.h"
+#include "ss_context.h"
+#include "ss_triangle.h"
+
+
+/* Need to check lighting state and vertex program state to know
+ * if two-sided lighting is in effect.
+ */
+#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT|_NEW_PROGRAM)
+
+
+#define VARYING_EMIT_STYLE EMIT_4F
+
+
+GLboolean
+_swsetup_CreateContext( GLcontext *ctx )
+{
+ SScontext *swsetup = (SScontext *)CALLOC(sizeof(SScontext));
+
+ if (!swsetup)
+ return GL_FALSE;
+
+ ctx->swsetup_context = swsetup;
+
+ swsetup->NewState = ~0;
+ _swsetup_trifuncs_init( ctx );
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ sizeof(SWvertex) );
+
+
+ return GL_TRUE;
+}
+
+void
+_swsetup_DestroyContext( GLcontext *ctx )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ if (swsetup) {
+ FREE(swsetup);
+ ctx->swsetup_context = 0;
+ }
+
+ _tnl_free_vertices( ctx );
+}
+
+static void
+_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode )
+{
+ SWSETUP_CONTEXT(ctx)->render_prim = mode;
+ _swrast_render_primitive( ctx, mode );
+}
+
+
+/**
+ * Helper macros for setup_vertex_format()
+ */
+#define SWZ ((SWvertex *)0)
+#define SWOffset(MEMBER) (((char *)&(SWZ->MEMBER)) - ((char *)SWZ))
+
+#define EMIT_ATTR( ATTR, STYLE, MEMBER ) \
+do { \
+ map[e].attrib = (ATTR); \
+ map[e].format = (STYLE); \
+ map[e].offset = SWOffset(MEMBER); \
+ e++; \
+} while (0)
+
+
+/**
+ * Tell the tnl module how to build SWvertex objects for swrast.
+ * We'll build the map[] array with that info and pass it to
+ * _tnl_install_attrs().
+ */
+static void
+setup_vertex_format(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ GLboolean intColors = !ctx->FragmentProgram._Current
+ && !ctx->ATIFragmentShader._Enabled
+ && ctx->RenderMode == GL_RENDER
+ && CHAN_TYPE == GL_UNSIGNED_BYTE;
+
+ if (intColors != swsetup->intColors ||
+ !RENDERINPUTS_EQUAL(tnl->render_inputs_bitset,
+ swsetup->last_index_bitset)) {
+ DECLARE_RENDERINPUTS(index_bitset);
+ struct tnl_attr_map map[_TNL_ATTRIB_MAX];
+ int i, e = 0;
+
+ swsetup->intColors = intColors;
+
+ RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
+
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] );
+
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) {
+ if (swsetup->intColors)
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color );
+ else
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F, attrib[FRAG_ATTRIB_COL0]);
+ }
+
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[FRAG_ATTRIB_COL1]);
+ }
+
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR_INDEX )) {
+ EMIT_ATTR( _TNL_ATTRIB_COLOR_INDEX, EMIT_1F,
+ attrib[FRAG_ATTRIB_CI][0] );
+ }
+
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
+ const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F;
+ EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[FRAG_ATTRIB_FOGC]);
+ }
+
+ if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX))
+ {
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
+ EMIT_ATTR( _TNL_ATTRIB_TEX(i), EMIT_4F,
+ attrib[FRAG_ATTRIB_TEX0 + i] );
+ }
+ }
+ }
+
+ /* shader varying vars */
+ if (RENDERINPUTS_TEST_RANGE( index_bitset,
+ _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC )) {
+ for (i = 0; i < ctx->Const.MaxVarying; i++) {
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_GENERIC(i) )) {
+ EMIT_ATTR( _TNL_ATTRIB_GENERIC(i), VARYING_EMIT_STYLE,
+ attrib[FRAG_ATTRIB_VAR0 + i] );
+ }
+ }
+ }
+
+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE ))
+ EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize );
+
+ _tnl_install_attrs( ctx, map, e,
+ ctx->Viewport._WindowMap.m,
+ sizeof(SWvertex) );
+
+ RENDERINPUTS_COPY( swsetup->last_index_bitset, index_bitset );
+ }
+}
+
+
+/**
+ * Prepare to render a vertex buffer.
+ * Called via tnl->Driver.Render.Start.
+ */
+static void
+_swsetup_RenderStart( GLcontext *ctx )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+
+ if (swsetup->NewState & _SWSETUP_NEW_RENDERINDEX) {
+ _swsetup_choose_trifuncs(ctx);
+ }
+
+ if (swsetup->NewState & _NEW_PROGRAM) {
+ RENDERINPUTS_ZERO( swsetup->last_index_bitset );
+ }
+
+ swsetup->NewState = 0;
+
+ /* This will change if drawing unfilled tris */
+ _swrast_SetFacing(ctx, 0);
+
+ _swrast_render_start(ctx);
+
+ /* Important */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+
+ setup_vertex_format(ctx);
+}
+
+
+/*
+ * We patch this function into tnl->Driver.Render.Finish.
+ * It's called when we finish rendering a vertex buffer.
+ */
+static void
+_swsetup_RenderFinish( GLcontext *ctx )
+{
+ _swrast_render_finish( ctx );
+}
+
+void
+_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ swsetup->NewState |= new_state;
+ _tnl_invalidate_vertex_state( ctx, new_state );
+}
+
+
+void
+_swsetup_Wakeup( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ tnl->Driver.Render.Start = _swsetup_RenderStart;
+ tnl->Driver.Render.Finish = _swsetup_RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive;
+ tnl->Driver.Render.Interp = _tnl_interp;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; /* new */
+ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; /* new */
+ /* points */
+ /* line */
+ /* triangle */
+ /* quad */
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.Multipass = 0;
+
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ _swsetup_InvalidateState( ctx, ~0 );
+
+ swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf;
+ RENDERINPUTS_ZERO( swsetup->last_index_bitset );
+}
+
+
+/**
+ * Populate a swrast SWvertex from an attrib-style vertex.
+ */
+void
+_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
+{
+ const GLfloat *m = ctx->Viewport._WindowMap.m;
+ GLfloat tmp[4];
+ GLuint i;
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POS, tmp );
+
+ dest->attrib[FRAG_ATTRIB_WPOS][0] = m[0] * tmp[0] + m[12];
+ dest->attrib[FRAG_ATTRIB_WPOS][1] = m[5] * tmp[1] + m[13];
+ dest->attrib[FRAG_ATTRIB_WPOS][2] = m[10] * tmp[2] + m[14];
+ dest->attrib[FRAG_ATTRIB_WPOS][3] = tmp[3];
+
+ /** XXX try to limit these loops someday */
+ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0 + i,
+ dest->attrib[FRAG_ATTRIB_TEX0 + i] );
+
+ for (i = 0 ; i < ctx->Const.MaxVarying ; i++)
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i,
+ dest->attrib[FRAG_ATTRIB_VAR0 + i] );
+
+ if (ctx->Visual.rgbMode) {
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0,
+ dest->attrib[FRAG_ATTRIB_COL0] );
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1,
+ dest->attrib[FRAG_ATTRIB_COL1]);
+ }
+ else {
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
+ dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
+ }
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp );
+ dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0];
+
+ /* XXX See _tnl_get_attr about pointsize ... */
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp );
+ dest->pointSize = tmp[0];
+}
+
diff --git a/mesalib/src/mesa/swrast_setup/ss_context.h b/mesalib/src/mesa/swrast_setup/ss_context.h
new file mode 100644
index 000000000..1ec293fad
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/ss_context.h
@@ -0,0 +1,46 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SS_CONTEXT_H
+#define SS_CONTEXT_H
+
+#include "main/mtypes.h"
+#include "swrast/swrast.h"
+#include "swrast_setup.h"
+#include "tnl/t_context.h"
+
+typedef struct {
+ GLuint NewState;
+ GLenum render_prim;
+ DECLARE_RENDERINPUTS(last_index_bitset);
+ SWvertex *verts;
+ GLboolean intColors;
+} SScontext;
+
+#define SWSETUP_CONTEXT(ctx) ((SScontext *)ctx->swsetup_context)
+
+#endif
diff --git a/mesalib/src/mesa/swrast_setup/ss_triangle.c b/mesalib/src/mesa/swrast_setup/ss_triangle.c
new file mode 100644
index 000000000..e15b1348d
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/ss_triangle.c
@@ -0,0 +1,317 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "ss_triangle.h"
+#include "ss_context.h"
+
+#define SS_RGBA_BIT 0x1
+#define SS_OFFSET_BIT 0x2
+#define SS_TWOSIDE_BIT 0x4
+#define SS_UNFILLED_BIT 0x8
+#define SS_MAX_TRIFUNC 0x10
+
+static tnl_triangle_func tri_tab[SS_MAX_TRIFUNC];
+static tnl_quad_func quad_tab[SS_MAX_TRIFUNC];
+
+
+/*
+ * Render a triangle respecting edge flags.
+ */
+typedef void (* swsetup_edge_render_prim_tri)(GLcontext *ctx,
+ const GLubyte *ef,
+ GLuint e0,
+ GLuint e1,
+ GLuint e2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2);
+
+/*
+ * Render a triangle using lines and respecting edge flags.
+ */
+static void
+_swsetup_edge_render_line_tri(GLcontext *ctx,
+ const GLubyte *ef,
+ GLuint e0,
+ GLuint e1,
+ GLuint e2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ if (swsetup->render_prim == GL_POLYGON) {
+ if (ef[e2]) _swrast_Line( ctx, v2, v0 );
+ if (ef[e0]) _swrast_Line( ctx, v0, v1 );
+ if (ef[e1]) _swrast_Line( ctx, v1, v2 );
+ } else {
+ if (ef[e0]) _swrast_Line( ctx, v0, v1 );
+ if (ef[e1]) _swrast_Line( ctx, v1, v2 );
+ if (ef[e2]) _swrast_Line( ctx, v2, v0 );
+ }
+}
+
+/*
+ * Render a triangle using points and respecting edge flags.
+ */
+static void
+_swsetup_edge_render_point_tri(GLcontext *ctx,
+ const GLubyte *ef,
+ GLuint e0,
+ GLuint e1,
+ GLuint e2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ if (ef[e0]) _swrast_Point( ctx, v0 );
+ if (ef[e1]) _swrast_Point( ctx, v1 );
+ if (ef[e2]) _swrast_Point( ctx, v2 );
+
+ _swrast_flush(ctx);
+}
+
+/*
+ * Render a triangle respecting cull and shade model.
+ */
+static void _swsetup_render_tri(GLcontext *ctx,
+ GLuint e0,
+ GLuint e1,
+ GLuint e2,
+ GLuint facing,
+ swsetup_edge_render_prim_tri render)
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ef = VB->EdgeFlag;
+ SWvertex *verts = swsetup->verts;
+ SWvertex *v0 = &verts[e0];
+ SWvertex *v1 = &verts[e1];
+ SWvertex *v2 = &verts[e2];
+
+ /* cull testing */
+ if (ctx->Polygon.CullFlag) {
+ if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT)
+ return;
+ if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK)
+ return;
+ }
+
+ _swrast_SetFacing(ctx, facing);
+
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ GLchan c[2][4];
+ GLfloat s[2][4];
+ GLfloat i[2];
+
+ /* save colors/indexes for v0, v1 vertices */
+ COPY_CHAN4(c[0], v0->color);
+ COPY_CHAN4(c[1], v1->color);
+ COPY_4V(s[0], v0->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(s[1], v1->attrib[FRAG_ATTRIB_COL1]);
+ i[0] = v0->attrib[FRAG_ATTRIB_CI][0];
+ i[1] = v1->attrib[FRAG_ATTRIB_CI][0];
+
+ /* copy v2 color/indexes to v0, v1 indexes */
+ COPY_CHAN4(v0->color, v2->color);
+ COPY_CHAN4(v1->color, v2->color);
+ COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
+ v0->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
+ v1->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
+
+ render(ctx, ef, e0, e1, e2, v0, v1, v2);
+
+ COPY_CHAN4(v0->color, c[0]);
+ COPY_CHAN4(v1->color, c[1]);
+ COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], s[0]);
+ COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], s[1]);
+ v0->attrib[FRAG_ATTRIB_CI][0] = i[0];
+ v1->attrib[FRAG_ATTRIB_CI][0] = i[1];
+ }
+ else {
+ render(ctx, ef, e0, e1, e2, v0, v1, v2);
+ }
+}
+
+#define SS_COLOR(a,b) UNCLAMPED_FLOAT_TO_RGBA_CHAN(a,b)
+#define SS_SPEC(a,b) UNCLAMPED_FLOAT_TO_RGB_CHAN(a,b)
+#define SS_IND(a,b) (a = b)
+
+#define IND (0)
+#define TAG(x) x
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
+#define TAG(x) x##_offset_twoside
+#include "ss_tritmp.h"
+
+#define IND (SS_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_offset_twoside_unfilled
+#include "ss_tritmp.h"
+
+#define IND (0|SS_RGBA_BIT)
+#define TAG(x) x##_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_twoside_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_twoside_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_twoside_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_twoside_unfilled_rgba
+#include "ss_tritmp.h"
+
+
+void _swsetup_trifuncs_init( GLcontext *ctx )
+{
+ (void) ctx;
+
+ init();
+ init_offset();
+ init_twoside();
+ init_offset_twoside();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_offset_twoside_unfilled();
+
+ init_rgba();
+ init_offset_rgba();
+ init_twoside_rgba();
+ init_offset_twoside_rgba();
+ init_unfilled_rgba();
+ init_offset_unfilled_rgba();
+ init_twoside_unfilled_rgba();
+ init_offset_twoside_unfilled_rgba();
+}
+
+
+static void swsetup_points( GLcontext *ctx, GLuint first, GLuint last )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ GLuint i;
+
+ if (VB->Elts) {
+ for (i = first; i < last; i++)
+ if (VB->ClipMask[VB->Elts[i]] == 0)
+ _swrast_Point( ctx, &verts[VB->Elts[i]] );
+ }
+ else {
+ for (i = first; i < last; i++)
+ if (VB->ClipMask[i] == 0)
+ _swrast_Point( ctx, &verts[i] );
+ }
+}
+
+static void swsetup_line( GLcontext *ctx, GLuint v0, GLuint v1 )
+{
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ _swrast_Line( ctx, &verts[v0], &verts[v1] );
+}
+
+
+
+void _swsetup_choose_trifuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = 0;
+
+ if (ctx->Polygon.OffsetPoint ||
+ ctx->Polygon.OffsetLine ||
+ ctx->Polygon.OffsetFill)
+ ind |= SS_OFFSET_BIT;
+
+ if ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) ||
+ (ctx->VertexProgram._Current && ctx->VertexProgram.TwoSideEnabled))
+ ind |= SS_TWOSIDE_BIT;
+
+ /* We piggyback the two-sided stencil front/back determination on the
+ * unfilled triangle path.
+ */
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL ||
+ (ctx->Stencil.Enabled && ctx->Stencil._TestTwoSide))
+ ind |= SS_UNFILLED_BIT;
+
+ if (ctx->Visual.rgbMode)
+ ind |= SS_RGBA_BIT;
+
+ tnl->Driver.Render.Triangle = tri_tab[ind];
+ tnl->Driver.Render.Quad = quad_tab[ind];
+ tnl->Driver.Render.Line = swsetup_line;
+ tnl->Driver.Render.Points = swsetup_points;
+}
diff --git a/mesalib/src/mesa/swrast_setup/ss_triangle.h b/mesalib/src/mesa/swrast_setup/ss_triangle.h
new file mode 100644
index 000000000..007fa2e91
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/ss_triangle.h
@@ -0,0 +1,38 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SS_TRIANGLE_H
+#define SS_TRIANGLE_H
+
+#include "ss_context.h"
+
+
+void _swsetup_trifuncs_init( GLcontext *ctx );
+void _swsetup_choose_trifuncs( GLcontext *ctx );
+
+#endif
diff --git a/mesalib/src/mesa/swrast_setup/ss_tritmp.h b/mesalib/src/mesa/swrast_setup/ss_tritmp.h
new file mode 100644
index 000000000..724b5e94f
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/ss_tritmp.h
@@ -0,0 +1,266 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/**
+ * This is where we handle assigning vertex colors based on front/back
+ * facing, compute polygon offset and handle glPolygonMode().
+ */
+static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ SWvertex *v[3];
+ GLfloat z[3];
+ GLfloat offset, oz0, oz1, oz2;
+ GLenum mode = GL_FILL;
+ GLuint facing = 0;
+ GLchan saved_color[3][4];
+ GLfloat saved_col0[3][4];
+ GLfloat saved_spec[3][4];
+ GLfloat saved_index[3];
+
+ v[0] = &verts[e0];
+ v[1] = &verts[e1];
+ v[2] = &verts[e2];
+
+ if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
+ {
+ GLfloat ex = v[0]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0];
+ GLfloat ey = v[0]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1];
+ GLfloat fx = v[1]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0];
+ GLfloat fy = v[1]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1];
+ GLfloat cc = ex*fy - ey*fx;
+
+ if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
+ {
+ facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
+
+ if (IND & SS_UNFILLED_BIT)
+ mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;
+
+ if (facing == 1) {
+ if (IND & SS_TWOSIDE_BIT) {
+ if (IND & SS_RGBA_BIT) {
+ if (VB->ColorPtr[1]) {
+ GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+
+ if (swsetup->intColors) {
+ COPY_CHAN4(saved_color[0], v[0]->color);
+ COPY_CHAN4(saved_color[1], v[1]->color);
+ COPY_CHAN4(saved_color[2], v[2]->color);
+ }
+ else {
+ COPY_4V(saved_col0[0], v[0]->attrib[FRAG_ATTRIB_COL0]);
+ COPY_4V(saved_col0[1], v[1]->attrib[FRAG_ATTRIB_COL0]);
+ COPY_4V(saved_col0[2], v[2]->attrib[FRAG_ATTRIB_COL0]);
+ }
+
+ if (VB->ColorPtr[1]->stride) {
+ if (swsetup->intColors) {
+ SS_COLOR(v[0]->color, vbcolor[e0]);
+ SS_COLOR(v[1]->color, vbcolor[e1]);
+ SS_COLOR(v[2]->color, vbcolor[e2]);
+ }
+ else {
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[e0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[e1]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[e2]);
+ }
+ }
+ else {
+ /* flat shade */
+ if (swsetup->intColors) {
+ SS_COLOR(v[0]->color, vbcolor[0]);
+ SS_COLOR(v[1]->color, vbcolor[0]);
+ SS_COLOR(v[2]->color, vbcolor[0]);
+ }
+ else {
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
+ }
+ }
+ }
+
+ if (VB->SecondaryColorPtr[1]) {
+ GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+
+ COPY_4V(saved_spec[0], v[0]->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(saved_spec[1], v[1]->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(saved_spec[2], v[2]->attrib[FRAG_ATTRIB_COL1]);
+
+ if (VB->SecondaryColorPtr[1]->stride) {
+ SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[e0]);
+ SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[e1]);
+ SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[e2]);
+ }
+ else {
+ SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
+ SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
+ SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
+ }
+ }
+ } else {
+ GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
+ saved_index[0] = v[0]->attrib[FRAG_ATTRIB_CI][0];
+ saved_index[1] = v[1]->attrib[FRAG_ATTRIB_CI][0];
+ saved_index[2] = v[2]->attrib[FRAG_ATTRIB_CI][0];
+
+ SS_IND(v[0]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e0]);
+ SS_IND(v[1]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e1]);
+ SS_IND(v[2]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e2]);
+ }
+ }
+ }
+ }
+
+ if (IND & SS_OFFSET_BIT) {
+ const GLfloat max = ctx->DrawBuffer->_DepthMaxF;
+ /* save original Z values (restored later) */
+ z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2];
+ z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2];
+ z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2];
+ /* Note that Z values are already scaled to [0,65535] (for example)
+ * so no MRD value is used here.
+ */
+ offset = ctx->Polygon.OffsetUnits;
+ if (cc * cc > 1e-16) {
+ const GLfloat ez = z[0] - z[2];
+ const GLfloat fz = z[1] - z[2];
+ const GLfloat oneOverArea = 1.0F / cc;
+ const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
+ const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
+ offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
+ }
+ /* new Z values */
+ oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
+ oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
+ oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
+ }
+ }
+
+ if (mode == GL_POINT) {
+ if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
+ }
+ _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_point_tri);
+ } else if (mode == GL_LINE) {
+ if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
+ }
+ _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_line_tri);
+ } else {
+ if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
+ }
+ _swrast_Triangle( ctx, v[0], v[1], v[2] );
+ }
+
+ /*
+ * Restore original vertex colors, etc.
+ */
+ if (IND & SS_OFFSET_BIT) {
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = z[0];
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = z[1];
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = z[2];
+ }
+
+ if (IND & SS_TWOSIDE_BIT) {
+ if (facing == 1) {
+ if (IND & SS_RGBA_BIT) {
+ if (VB->ColorPtr[1]) {
+ if (swsetup->intColors) {
+ COPY_CHAN4(v[0]->color, saved_color[0]);
+ COPY_CHAN4(v[1]->color, saved_color[1]);
+ COPY_CHAN4(v[2]->color, saved_color[2]);
+ }
+ else {
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], saved_col0[0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], saved_col0[1]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], saved_col0[2]);
+ }
+ }
+
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL1], saved_spec[0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL1], saved_spec[1]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL1], saved_spec[2]);
+ }
+ } else {
+ v[0]->attrib[FRAG_ATTRIB_CI][0] = saved_index[0];
+ v[1]->attrib[FRAG_ATTRIB_CI][0] = saved_index[1];
+ v[2]->attrib[FRAG_ATTRIB_CI][0] = saved_index[2];
+ }
+ }
+ }
+}
+
+
+
+/* Need to fixup edgeflags when decomposing to triangles:
+ */
+static void TAG(quadfunc)( GLcontext *ctx, GLuint v0,
+ GLuint v1, GLuint v2, GLuint v3 )
+{
+ if (IND & SS_UNFILLED_BIT) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ if (VB->EdgeFlag) { /* XXX this test shouldn't be needed (bug 12614) */
+ GLubyte ef1 = VB->EdgeFlag[v1];
+ GLubyte ef3 = VB->EdgeFlag[v3];
+ VB->EdgeFlag[v1] = 0;
+ TAG(triangle)( ctx, v0, v1, v3 );
+ VB->EdgeFlag[v1] = ef1;
+ VB->EdgeFlag[v3] = 0;
+ TAG(triangle)( ctx, v1, v2, v3 );
+ VB->EdgeFlag[v3] = ef3;
+ }
+ } else {
+ TAG(triangle)( ctx, v0, v1, v3 );
+ TAG(triangle)( ctx, v1, v2, v3 );
+ }
+}
+
+
+
+
+static void TAG(init)( void )
+{
+ tri_tab[IND] = TAG(triangle);
+ quad_tab[IND] = TAG(quadfunc);
+}
+
+
+#undef IND
+#undef TAG
diff --git a/mesalib/src/mesa/swrast_setup/ss_vb.h b/mesalib/src/mesa/swrast_setup/ss_vb.h
new file mode 100644
index 000000000..2ad1f56f3
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/ss_vb.h
@@ -0,0 +1,38 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SS_VB_H
+#define SS_VB_H
+
+#include "main/mtypes.h"
+#include "swrast_setup.h"
+
+void _swsetup_vb_init( GLcontext *ctx );
+void _swsetup_choose_rastersetup_func( GLcontext *ctx );
+
+#endif
diff --git a/mesalib/src/mesa/swrast_setup/swrast_setup.h b/mesalib/src/mesa/swrast_setup/swrast_setup.h
new file mode 100644
index 000000000..5dcbe2675
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/swrast_setup.h
@@ -0,0 +1,61 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/* Public interface to the swrast_setup module. This module provides
+ * an implementation of the driver interface to t_vb_render.c, and uses
+ * the software rasterizer (swrast) to perform actual rasterization.
+ *
+ * The internals of the implementation are private, but can be hooked
+ * into tnl at any time (except between RenderStart/RenderEnd) by
+ * calling _swsetup_Wakeup().
+ */
+
+#ifndef SWRAST_SETUP_H
+#define SWRAST_SETUP_H
+
+#include "swrast/swrast.h"
+
+extern GLboolean
+_swsetup_CreateContext( GLcontext *ctx );
+
+extern void
+_swsetup_DestroyContext( GLcontext *ctx );
+
+extern void
+_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+extern void
+_swsetup_Wakeup( GLcontext *ctx );
+
+/* Helper function to translate a hardware vertex (as understood by
+ * the tnl/t_vertex.c code) to a swrast vertex.
+ */
+extern void
+_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest );
+
+#endif