aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast_setup
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-12-28 16:10:20 +0000
committermarha <marha@users.sourceforge.net>2010-12-28 16:10:20 +0000
commit807c6931fe683fd844ceec1b023232181e6aae03 (patch)
tree1a131ed95fe2200d0ad33da8f7755a7ed2364adc /mesalib/src/mesa/swrast_setup
parent973099dda7e49e5abe29819a7124b3b1e7bd8b92 (diff)
downloadvcxsrv-807c6931fe683fd844ceec1b023232181e6aae03.tar.gz
vcxsrv-807c6931fe683fd844ceec1b023232181e6aae03.tar.bz2
vcxsrv-807c6931fe683fd844ceec1b023232181e6aae03.zip
xserver and mesa git update 28-12-2010
Diffstat (limited to 'mesalib/src/mesa/swrast_setup')
-rw-r--r--mesalib/src/mesa/swrast_setup/NOTES65
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_context.c612
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_triangle.c530
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_triangle.h76
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_tritmp.h496
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_vb.h74
-rw-r--r--mesalib/src/mesa/swrast_setup/swrast_setup.h122
7 files changed, 1020 insertions, 955 deletions
diff --git a/mesalib/src/mesa/swrast_setup/NOTES b/mesalib/src/mesa/swrast_setup/NOTES
new file mode 100644
index 000000000..b5d2c503e
--- /dev/null
+++ b/mesalib/src/mesa/swrast_setup/NOTES
@@ -0,0 +1,65 @@
+INTRODUCTION
+
+A helper module which provides glue to bind the software rasterizer to
+the software t&l module. The main task of this module is to build
+swrast vertices from the t&l vertex_buffer structs, and to use them to
+perform triangle setup functions not implemented in the software
+rasterizer.
+
+The module implements a full set of functions to plug into the
+t_vb_render.c driver interface (tnl->Driver.Render.*).
+
+There are strong advantages to decoupling the software rasterizer from
+the t&l module, primarily allowing hardware drivers better control
+over fallbacks, the removal of implicit knowledge about the software
+rasterizer in the t&l module, allowing the two modules to evolve
+independently and allowing either to be substituted with equivalent
+functionality from another codebase.
+
+This module implements triangle/quad setup for offset, unfilled and
+twoside-lit triangles. The software rasterizer doesn't handle these
+primitives directly.
+
+Hardware rasterization drivers typically use this module in situations
+where no hardware rasterization is possible, ie during total
+fallbacks.
+
+STATE
+
+To create and destroy the module:
+
+ GLboolean _swsetup_CreateContext( struct gl_context *ctx );
+ void _swsetup_DestroyContext( struct gl_context *ctx );
+
+The module is not active by default, and must be installed by calling
+_swrast_Wakeup(). This function installs internal swrast_setup
+functions into all the tnl->Driver.Render driver hooks, thus taking
+over the task of rasterization entirely:
+
+ void _swrast_Wakeup( struct gl_context *ctx );
+
+
+This module tracks state changes internally and maintains derived
+values based on the current state. For this to work, the driver
+ensure the following funciton is called whenever the state changes and
+the swsetup module is 'awake':
+
+ void _swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state );
+
+There is no explicit call to put the swsetup module to sleep. Simply
+install other function pointers into all the tnl->Driver.Render.*
+hooks, and (optionally) cease calling _swsetup_InvalidateState().
+
+DRIVER INTERFACE
+
+The module offers a minimal driver interface:
+
+ void (*Start)( struct gl_context *ctx );
+ void (*Finish)( struct gl_context *ctx );
+
+These are called before and after the completion of all swrast drawing
+activity. As swrast doesn't call callbacks during triangle, line or
+point rasterization, these are necessary to provide locking hooks for
+some drivers. They may otherwise be left null.
+
+
diff --git a/mesalib/src/mesa/swrast_setup/ss_context.c b/mesalib/src/mesa/swrast_setup/ss_context.c
index 0fcb7c77a..384cf425a 100644
--- a/mesalib/src/mesa/swrast_setup/ss_context.c
+++ b/mesalib/src/mesa/swrast_setup/ss_context.c
@@ -1,306 +1,306 @@
-/*
- * 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_FLOAT;
-
- 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];
- unsigned 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_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] );
-
- _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]);
-
- _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];
-}
-
+/*
+ * 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( struct gl_context *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( struct gl_context *ctx )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ if (swsetup) {
+ FREE(swsetup);
+ ctx->swsetup_context = 0;
+ }
+
+ _tnl_free_vertices( ctx );
+}
+
+static void
+_swsetup_RenderPrimitive( struct gl_context *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(struct gl_context *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_FLOAT;
+
+ 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];
+ unsigned 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_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( struct gl_context *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( struct gl_context *ctx )
+{
+ _swrast_render_finish( ctx );
+}
+
+void
+_swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ swsetup->NewState |= new_state;
+ _tnl_invalidate_vertex_state( ctx, new_state );
+}
+
+
+void
+_swsetup_Wakeup( struct gl_context *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( struct gl_context *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] );
+
+ _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]);
+
+ _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_triangle.c b/mesalib/src/mesa/swrast_setup/ss_triangle.c
index f22bc52f0..4fc9a0756 100644
--- a/mesalib/src/mesa/swrast_setup/ss_triangle.c
+++ b/mesalib/src/mesa/swrast_setup/ss_triangle.c
@@ -1,265 +1,265 @@
-/*
- * 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_OFFSET_BIT 0x1
-#define SS_TWOSIDE_BIT 0x2
-#define SS_UNFILLED_BIT 0x4
-#define SS_MAX_TRIFUNC 0x8
-
-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];
-
- /* 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]);
-
- /* 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]);
-
- 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]);
- }
- 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) COPY_4V(a,b)
-#define SS_IND(a,b) (a = b)
-
-#define IND (0)
-#define TAG(x) x##_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT)
-#define TAG(x) x##_offset_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_TWOSIDE_BIT)
-#define TAG(x) x##_twoside_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
-#define TAG(x) x##_offset_twoside_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_UNFILLED_BIT)
-#define TAG(x) x##_unfilled_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_offset_unfilled_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled_rgba
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_offset_twoside_unfilled_rgba
-#include "ss_tritmp.h"
-
-
-void _swsetup_trifuncs_init( GLcontext *ctx )
-{
- (void) ctx;
-
- 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;
-
- 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;
-}
+/*
+ * 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_OFFSET_BIT 0x1
+#define SS_TWOSIDE_BIT 0x2
+#define SS_UNFILLED_BIT 0x4
+#define SS_MAX_TRIFUNC 0x8
+
+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)(struct gl_context *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(struct gl_context *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(struct gl_context *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(struct gl_context *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];
+
+ /* 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]);
+
+ /* 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]);
+
+ 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]);
+ }
+ 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) COPY_4V(a,b)
+#define SS_IND(a,b) (a = b)
+
+#define IND (0)
+#define TAG(x) x##_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT)
+#define TAG(x) x##_offset_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT)
+#define TAG(x) x##_twoside_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
+#define TAG(x) x##_offset_twoside_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_UNFILLED_BIT)
+#define TAG(x) x##_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_offset_twoside_unfilled_rgba
+#include "ss_tritmp.h"
+
+
+void _swsetup_trifuncs_init( struct gl_context *ctx )
+{
+ (void) ctx;
+
+ 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( struct gl_context *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( struct gl_context *ctx, GLuint v0, GLuint v1 )
+{
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ _swrast_Line( ctx, &verts[v0], &verts[v1] );
+}
+
+
+
+void _swsetup_choose_trifuncs( struct gl_context *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;
+
+ 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
index ac553cbd0..e21a9749a 100644
--- a/mesalib/src/mesa/swrast_setup/ss_triangle.h
+++ b/mesalib/src/mesa/swrast_setup/ss_triangle.h
@@ -1,38 +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 "main/mtypes.h"
-
-
-void _swsetup_trifuncs_init( GLcontext *ctx );
-void _swsetup_choose_trifuncs( GLcontext *ctx );
-
-#endif
+
+/*
+ * 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
+
+struct gl_context;
+
+
+void _swsetup_trifuncs_init( struct gl_context *ctx );
+void _swsetup_choose_trifuncs( struct gl_context *ctx );
+
+#endif
diff --git a/mesalib/src/mesa/swrast_setup/ss_tritmp.h b/mesalib/src/mesa/swrast_setup/ss_tritmp.h
index 8e9fa1bd5..9b2b7cf6a 100644
--- a/mesalib/src/mesa/swrast_setup/ss_tritmp.h
+++ b/mesalib/src/mesa/swrast_setup/ss_tritmp.h
@@ -1,248 +1,248 @@
-/*
- * 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] = { { 0 } };
- GLfloat saved_col0[3][4] = { { 0 } };
- GLfloat saved_spec[3][4] = { { 0 } };
-
- 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 (VB->BackfaceColorPtr) {
- GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->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->BackfaceColorPtr->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->BackfaceSecondaryColorPtr) {
- GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->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->BackfaceSecondaryColorPtr->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]);
- }
- }
- }
- }
- }
-
- 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.0F, max);
- oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
- oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, 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 (VB->BackfaceColorPtr) {
- 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->BackfaceSecondaryColorPtr) {
- 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]);
- }
- }
- }
-}
-
-
-
-/* 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
+/*
+ * 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)(struct gl_context *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] = { { 0 } };
+ GLfloat saved_col0[3][4] = { { 0 } };
+ GLfloat saved_spec[3][4] = { { 0 } };
+
+ 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 (VB->BackfaceColorPtr) {
+ GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->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->BackfaceColorPtr->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->BackfaceSecondaryColorPtr) {
+ GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->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->BackfaceSecondaryColorPtr->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]);
+ }
+ }
+ }
+ }
+ }
+
+ 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.0F, max);
+ oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
+ oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, 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 (VB->BackfaceColorPtr) {
+ 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->BackfaceSecondaryColorPtr) {
+ 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]);
+ }
+ }
+ }
+}
+
+
+
+/* Need to fixup edgeflags when decomposing to triangles:
+ */
+static void TAG(quadfunc)( struct gl_context *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
index 944a3b78d..35d5da6f7 100644
--- a/mesalib/src/mesa/swrast_setup/ss_vb.h
+++ b/mesalib/src/mesa/swrast_setup/ss_vb.h
@@ -1,37 +1,37 @@
-
-/*
- * 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"
-
-void _swsetup_vb_init( GLcontext *ctx );
-void _swsetup_choose_rastersetup_func( GLcontext *ctx );
-
-#endif
+
+/*
+ * 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
+
+struct gl_context;
+
+void _swsetup_vb_init( struct gl_context *ctx );
+void _swsetup_choose_rastersetup_func( struct gl_context *ctx );
+
+#endif
diff --git a/mesalib/src/mesa/swrast_setup/swrast_setup.h b/mesalib/src/mesa/swrast_setup/swrast_setup.h
index 5dcbe2675..6d82ef58f 100644
--- a/mesalib/src/mesa/swrast_setup/swrast_setup.h
+++ b/mesalib/src/mesa/swrast_setup/swrast_setup.h
@@ -1,61 +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
+
+/*
+ * 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( struct gl_context *ctx );
+
+extern void
+_swsetup_DestroyContext( struct gl_context *ctx );
+
+extern void
+_swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state );
+
+extern void
+_swsetup_Wakeup( struct gl_context *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( struct gl_context *ctx, const void *vertex, SWvertex *dest );
+
+#endif