s_tritemp.h revision ac3958ea1bf8f7b1648f9c1b2ffbe93ffd40b602
1ac3958ea1bf8f7b1648f9c1b2ffbe93ffd40b602Brian Paul/* $Id: s_tritemp.h,v 1.21 2001/07/14 16:05:44 brianp Exp $ */
2e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
3e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell/*
4e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Mesa 3-D graphics library
5e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Version:  3.5
622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
74b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
9e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
10e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * copy of this software and associated documentation files (the "Software"),
11e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * to deal in the Software without restriction, including without limitation
12e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the
14e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Software is furnished to do so, subject to the following conditions:
1522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
16e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * The above copyright notice and this permission notice shall be included
17e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * in all copies or substantial portions of the Software.
1822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
19e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */
26e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
27e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
28e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell/*
29e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Triangle Rasterizer Template
30e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
31e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * This file is #include'd to generate custom triangle rasterizers.
32e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
33e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * The following macros may be defined to indicate what auxillary information
34e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * must be interplated across the triangle:
35e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_Z        - if defined, interpolate Z values
3695e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul *    INTERP_FOG      - if defined, interpolate fog values
37e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_RGB      - if defined, interpolate RGB values
38e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_ALPHA    - if defined, interpolate Alpha values
3995e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul *    INTERP_SPEC     - if defined, interpolate specular RGB values
40e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_INDEX    - if defined, interpolate color index values
41e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_INT_TEX  - if defined, interpolate integer ST texcoords
42e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *                         (fast, simple 2-D texture mapping)
43e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_TEX      - if defined, interpolate set 0 float STRQ texcoords
44e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *                         NOTE:  OpenGL STRQ = Mesa STUV (R was taken for red)
45e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    INTERP_MULTITEX - if defined, interpolate N units of STRQ texcoords
469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul *    INTERP_LAMBDA   - if defined, compute lambda value (for mipmapping)
4719bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul *                         a lambda value for every texture unit
48e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
49e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * When one can directly address pixels in the color buffer the following
50e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * macros can be defined and used to compute pixel addresses during
51e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * rasterization (see pRow):
52e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    PIXEL_TYPE          - the datatype of a pixel (GLubyte, GLushort, GLuint)
53e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    BYTES_PER_ROW       - number of bytes per row in the color buffer
54e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    PIXEL_ADDRESS(X,Y)  - returns the address of pixel at (X,Y) where
55e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *                          Y==0 at bottom of screen and increases upward.
56e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
57e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Similarly, for direct depth buffer access, this type is used for depth
58e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * buffer addressing:
59e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    DEPTH_TYPE          - either GLushort or GLuint
60e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
61e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Optionally, one may provide one-time setup code per triangle:
62e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *    SETUP_CODE    - code which is to be executed once per triangle
6347cf442c1164b6b406117fccfb8b564602741ee3Brian Paul *    CLEANUP_CODE    - code to execute at end of triangle
6422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
65e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * The following macro MUST be defined:
669bf68ad963ba92b5d1e725f965979042495a5313Brian Paul *    RENDER_SPAN(span) - code to write a span of pixels.
67e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
68e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * This code was designed for the origin to be in the lower-left corner.
69e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell *
70e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Inspired by triangle rasterizer code written by Allen Akin.  Thanks Allen!
71e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */
72e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
73cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell/*void triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 )*/
74e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell{
75e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   typedef struct {
76a852378a6289d154364dde440f89a39bbfc33e2dBrian Paul        const SWvertex *v0, *v1;   /* Y(v0) < Y(v1) */
77e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfloat dx;	/* X(v1) - X(v0) */
78e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfloat dy;	/* Y(v1) - Y(v0) */
79e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfixed fdxdy;	/* dx/dy in fixed-point */
80e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfixed fsx;	/* first sample point x coord */
81e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfixed fsy;
82e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfloat adjy;	/* adjust from v[0]->fy to fsy, scaled */
83e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLint lines;	/* number of lines to be sampled on this edge */
84e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	GLfixed fx0;	/* fixed pt X of lower endpoint */
85e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   } EdgeT;
86e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
87e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
88b6bcae5698df88f7730d40004ce7ce0462e97a20Brian Paul   const GLint depthBits = ctx->Visual.depthBits;
89e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
90b6bcae5698df88f7730d40004ce7ce0462e97a20Brian Paul   const GLfloat maxDepth = ctx->DepthMaxF;
91e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#define FixedToDepth(F)  ((F) >> fixedToDepthShift)
92e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
93e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   EdgeT eMaj, eTop, eBot;
94e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   GLfloat oneOverArea;
95a852378a6289d154364dde440f89a39bbfc33e2dBrian Paul   const SWvertex *vMin, *vMid, *vMax;  /* Y(vMin)<=Y(vMid)<=Y(vMax) */
961e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell   float bf = SWRAST_CONTEXT(ctx)->_backface_sign;
97ac3958ea1bf8f7b1648f9c1b2ffbe93ffd40b602Brian Paul   const GLint snapMask = ~((FIXED_ONE / 16) - 1); /* for x/y coord snapping */
98a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   GLfixed vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy;
99e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul   struct triangle_span span;
1019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
1029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_Z
1039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul   (void) fixedToDepthShift;
1049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
1059bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
106a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   /* Compute fixed point x,y coords w/ half-pixel offsets and snapping.
107a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul    * And find the order of the 3 vertices along the Y axis.
108a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul    */
109e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   {
1101178ed817f835e2a9b1fdd33b32d39e2d6070cc8Brian Paul      const GLfixed fy0 = FloatToFixed(v0->win[1] - 0.5F) & snapMask;
1111178ed817f835e2a9b1fdd33b32d39e2d6070cc8Brian Paul      const GLfixed fy1 = FloatToFixed(v1->win[1] - 0.5F) & snapMask;
1121178ed817f835e2a9b1fdd33b32d39e2d6070cc8Brian Paul      const GLfixed fy2 = FloatToFixed(v2->win[1] - 0.5F) & snapMask;
113a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul
114a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul      if (fy0 <= fy1) {
115a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	 if (fy1 <= fy2) {
116a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            /* y0 <= y1 <= y2 */
117a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	    vMin = v0;   vMid = v1;   vMax = v2;
118a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            vMin_fy = fy0;  vMid_fy = fy1;  vMax_fy = fy2;
119e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 }
120a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	 else if (fy2 <= fy0) {
121a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            /* y2 <= y0 <= y1 */
122a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	    vMin = v2;   vMid = v0;   vMax = v1;
123a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            vMin_fy = fy2;  vMid_fy = fy0;  vMax_fy = fy1;
124e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 }
125e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 else {
126a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            /* y0 <= y2 <= y1 */
127a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	    vMin = v0;   vMid = v2;   vMax = v1;
128a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            vMin_fy = fy0;  vMid_fy = fy2;  vMax_fy = fy1;
129a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            bf = -bf;
130e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 }
131e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
132e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      else {
133a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	 if (fy0 <= fy2) {
134a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            /* y1 <= y0 <= y2 */
135a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	    vMin = v1;   vMid = v0;   vMax = v2;
136a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            vMin_fy = fy1;  vMid_fy = fy0;  vMax_fy = fy2;
137a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            bf = -bf;
138e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 }
139a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	 else if (fy2 <= fy1) {
140a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            /* y2 <= y1 <= y0 */
141a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	    vMin = v2;   vMid = v1;   vMax = v0;
142a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            vMin_fy = fy2;  vMid_fy = fy1;  vMax_fy = fy0;
143a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            bf = -bf;
144e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 }
145e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 else {
146a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            /* y1 <= y2 <= y0 */
147a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul	    vMin = v1;   vMid = v2;   vMax = v0;
148a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul            vMin_fy = fy1;  vMid_fy = fy2;  vMax_fy = fy0;
149e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 }
150e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
151a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul
152a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul      /* fixed point X coords */
153a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul      vMin_fx = FloatToFixed(vMin->win[0] + 0.5F) & snapMask;
154a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul      vMid_fx = FloatToFixed(vMid->win[0] + 0.5F) & snapMask;
155a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul      vMax_fx = FloatToFixed(vMax->win[0] + 0.5F) & snapMask;
156e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   }
157e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
158e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   /* vertex/edge relationship */
159e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   eMaj.v0 = vMin;   eMaj.v1 = vMax;   /*TODO: .v1's not needed */
160e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   eTop.v0 = vMid;   eTop.v1 = vMax;
161e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   eBot.v0 = vMin;   eBot.v1 = vMid;
162e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
163a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   /* compute deltas for each edge:  vertex[upper] - vertex[lower] */
164a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   eMaj.dx = FixedToFloat(vMax_fx - vMin_fx);
165a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   eMaj.dy = FixedToFloat(vMax_fy - vMin_fy);
166a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   eTop.dx = FixedToFloat(vMax_fx - vMid_fx);
167a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   eTop.dy = FixedToFloat(vMax_fy - vMid_fy);
168a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   eBot.dx = FixedToFloat(vMid_fx - vMin_fx);
169a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   eBot.dy = FixedToFloat(vMid_fy - vMin_fy);
170e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
171a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul   /* compute area, oneOverArea and perform backface culling */
172e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   {
173e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
174e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
175e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      /* Do backface culling */
176e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      if (area * bf < 0.0)
177e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 return;
178e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
179e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      if (area == 0.0F)
180e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         return;
181e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
182ac3958ea1bf8f7b1648f9c1b2ffbe93ffd40b602Brian Paul      oneOverArea = 1.0F / area;
183e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   }
184e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
185e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifndef DO_OCCLUSION_TEST
186e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   ctx->OcclusionResult = GL_TRUE;
187e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
188e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
189e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   /* Edge setup.  For a triangle strip these could be reused... */
190e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   {
191e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      eMaj.fsy = FixedCeil(vMin_fy);
19226d729581fcf1991fbcc8320f64fa40d73170e95Brian Paul      eMaj.lines = FixedToInt(FixedCeil(vMax_fy - eMaj.fsy));
193e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      if (eMaj.lines > 0) {
194e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat dxdy = eMaj.dx / eMaj.dy;
195e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eMaj.fdxdy = SignedFloatToFixed(dxdy);
196e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eMaj.adjy = (GLfloat) (eMaj.fsy - vMin_fy);  /* SCALED! */
197e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eMaj.fx0 = vMin_fx;
198e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eMaj.fsx = eMaj.fx0 + (GLfixed) (eMaj.adjy * dxdy);
199e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
200e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      else {
201e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         return;  /*CULLED*/
202e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
203e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
204e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      eTop.fsy = FixedCeil(vMid_fy);
20526d729581fcf1991fbcc8320f64fa40d73170e95Brian Paul      eTop.lines = FixedToInt(FixedCeil(vMax_fy - eTop.fsy));
206e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      if (eTop.lines > 0) {
207e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat dxdy = eTop.dx / eTop.dy;
208e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eTop.fdxdy = SignedFloatToFixed(dxdy);
209e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eTop.adjy = (GLfloat) (eTop.fsy - vMid_fy); /* SCALED! */
210e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eTop.fx0 = vMid_fx;
211e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eTop.fsx = eTop.fx0 + (GLfixed) (eTop.adjy * dxdy);
212e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
213e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
214e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      eBot.fsy = FixedCeil(vMin_fy);
21526d729581fcf1991fbcc8320f64fa40d73170e95Brian Paul      eBot.lines = FixedToInt(FixedCeil(vMid_fy - eBot.fsy));
216e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      if (eBot.lines > 0) {
217e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat dxdy = eBot.dx / eBot.dy;
218e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eBot.fdxdy = SignedFloatToFixed(dxdy);
219e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eBot.adjy = (GLfloat) (eBot.fsy - vMin_fy);  /* SCALED! */
220e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eBot.fx0 = vMin_fx;
221e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         eBot.fsx = eBot.fx0 + (GLfixed) (eBot.adjy * dxdy);
222e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
223e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   }
224e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
225e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   /*
226e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * Conceptually, we view a triangle as two subtriangles
227e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * separated by a perfectly horizontal line.  The edge that is
228e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * intersected by this line is one with maximal absolute dy; we
229e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * call it a ``major'' edge.  The other two edges are the
230e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * ``top'' edge (for the upper subtriangle) and the ``bottom''
231e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * edge (for the lower subtriangle).  If either of these two
232e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * edges is horizontal or very close to horizontal, the
233e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * corresponding subtriangle might cover zero sample points;
234e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * we take care to handle such cases, for performance as well
235e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * as correctness.
236e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    *
237e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * By stepping rasterization parameters along the major edge,
238e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * we can avoid recomputing them at the discontinuity where
239e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * the top and bottom edges meet.  However, this forces us to
24022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes    * be able to scan both left-to-right and right-to-left.
241e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * Also, we must determine whether the major edge is at the
242e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * left or right side of the triangle.  We do this by
243e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * computing the magnitude of the cross-product of the major
244e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * and top edges.  Since this magnitude depends on the sine of
245e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * the angle between the two edges, its sign tells us whether
246e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * we turn to the left or to the right when travelling along
247e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * the major edge to the top edge, and from this we infer
248e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * whether the major edge is on the left or the right.
249e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    *
250e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * Serendipitously, this cross-product magnitude is also a
251e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * value we need to compute the iteration parameter
252e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * derivatives for the triangle, and it can be used to perform
253e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * backface culling because its sign tells us whether the
254e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * triangle is clockwise or counterclockwise.  In this code we
255e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * refer to it as ``area'' because it's also proportional to
256e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    * the pixel area of the triangle.
257e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell    */
258e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
259e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   {
260e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      GLint ltor;		/* true if scanning left-to-right */
261e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
2629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dzdx, dzdy;
26395e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
26495e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
2659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dfogdy;
266e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
267e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
2689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat drdx, drdy;
2699bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dgdx, dgdy;
2709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dbdx, dbdy;
271e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
272e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA
2739bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dadx, dady;
2749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
2759bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC
2769bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dsrdx, dsrdy;
2779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dsgdx, dsgdy;
2789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dsbdx, dsbdy;
279e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
280e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
2819bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat didx, didy;
282e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
283e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
284e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      GLfloat dsdx, dsdy;
285e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      GLfloat dtdx, dtdy;
2869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
2879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_TEX
2889bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dsdy;
2899bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dtdy;
2909bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dudy;
2919bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dvdy;
292e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
293e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
2949bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dsdy[MAX_TEXTURE_UNITS];
2959bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dtdy[MAX_TEXTURE_UNITS];
2969bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dudy[MAX_TEXTURE_UNITS];
2979bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      GLfloat dvdy[MAX_TEXTURE_UNITS];
298e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
2994b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul
3009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#if defined(INTERP_LAMBDA) && !defined(INTERP_TEX) && !defined(INTERP_MULTITEX)
3014b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul#error "Mipmapping without texturing doesn't make sense."
3024b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul#endif
303e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
304e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      /*
305e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * Execute user-supplied setup code
306e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       */
307e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef SETUP_CODE
308e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      SETUP_CODE
309e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
310e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
311e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      ltor = (oneOverArea < 0.0F);
312e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
3139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask = 0;
3149bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
315e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      /* compute d?/dx and d?/dy derivatives */
316e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
3179bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_Z;
318e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
319e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dz, eBot_dz;
320cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eMaj_dz = vMax->win[2] - vMin->win[2];
321cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eBot_dz = vMid->win[2] - vMin->win[2];
322e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
323e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         if (dzdx > maxDepth || dzdx < -maxDepth) {
324e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            /* probably a sliver triangle */
325e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            dzdx = 0.0;
326e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            dzdy = 0.0;
327e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         }
328e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         else {
329e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx);
330e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         }
331e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         if (depthBits <= 16)
3329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            span.zStep = SignedFloatToFixed(dzdx);
333e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         else
3349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            span.zStep = (GLint) dzdx;
335e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
33695e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
33795e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
3389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_FOG;
339e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
3401b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         const GLfloat eMaj_dfog = vMax->fog - vMin->fog;
3411b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         const GLfloat eBot_dfog = vMid->fog - vMin->fog;
3429bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.fogStep = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog);
343e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx);
344e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
345e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
346e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
3479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_RGBA;
348ac3958ea1bf8f7b1648f9c1b2ffbe93ffd40b602Brian Paul      {
349e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dr, eBot_dr;
3503c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         GLfloat eMaj_dg, eBot_dg;
3513c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         GLfloat eMaj_db, eBot_db;
3523c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_dr = (GLint) vMax->color[0] - (GLint) vMin->color[0];
3533c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eBot_dr = (GLint) vMid->color[0] - (GLint) vMin->color[0];
354e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
3559bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.redStep = SignedFloatToFixed(drdx);
356e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
3573c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_dg = (GLint) vMax->color[1] - (GLint) vMin->color[1];
3583c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul	 eBot_dg = (GLint) vMid->color[1] - (GLint) vMin->color[1];
359e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
3609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.greenStep = SignedFloatToFixed(dgdx);
361e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
3623c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_db = (GLint) vMax->color[2] - (GLint) vMin->color[2];
3633c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eBot_db = (GLint) vMid->color[2] - (GLint) vMin->color[2];
364e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
3659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.blueStep = SignedFloatToFixed(dbdx);
366e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
367e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
368e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
3699bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA
3709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      {
3719bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat eMaj_da, eBot_da;
3729bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         eMaj_da = (GLint) vMax->color[3] - (GLint) vMin->color[3];
3739bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         eBot_da = (GLint) vMid->color[3] - (GLint) vMin->color[3];
3749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
3759bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.alphaStep = SignedFloatToFixed(dadx);
3769bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
3779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      }
3789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
379e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_SPEC
3809bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_SPEC;
381e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
382e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dsr, eBot_dsr;
3833c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_dsr = (GLint) vMax->specular[0] - (GLint) vMin->specular[0];
3843c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eBot_dsr = (GLint) vMid->specular[0] - (GLint) vMin->specular[0];
385e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
3869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.specRedStep = SignedFloatToFixed(dsrdx);
387e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
388e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
389e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
390e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dsg, eBot_dsg;
3913c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_dsg = (GLint) vMax->specular[1] - (GLint) vMin->specular[1];
3923c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul	 eBot_dsg = (GLint) vMid->specular[1] - (GLint) vMin->specular[1];
393e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
3949bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.specGreenStep = SignedFloatToFixed(dsgdx);
395e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
396e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
397e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
398e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dsb, eBot_dsb;
3993c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_dsb = (GLint) vMax->specular[2] - (GLint) vMin->specular[2];
4003c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eBot_dsb = (GLint) vMid->specular[2] - (GLint) vMin->specular[2];
401e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
4029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.specBlueStep = SignedFloatToFixed(dsbdx);
403e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	 dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
404e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
405e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
406e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
4079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_INDEX;
408e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
409e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_di, eBot_di;
4103c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eMaj_di = (GLint) vMax->index - (GLint) vMin->index;
4113c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul         eBot_di = (GLint) vMid->index - (GLint) vMin->index;
412e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di);
4139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.indexStep = SignedFloatToFixed(didx);
414e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
415e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
416e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
417e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
4189bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_INT_TEXTURE;
419e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
420e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_ds, eBot_ds;
421cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
422cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eBot_ds = (vMid->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
423e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
4249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.intTexStep[0] = SignedFloatToFixed(dsdx);
425e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
426e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
427cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell      {
428e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dt, eBot_dt;
429cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eMaj_dt = (vMax->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
430cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eBot_dt = (vMid->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
431e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
4329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.intTexStep[1] = SignedFloatToFixed(dtdx);
433e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
434e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
435e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
436e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
4379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
438e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
4399bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_TEXTURE;
440e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
441cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         GLfloat wMax = vMax->win[3];
442cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         GLfloat wMin = vMin->win[3];
443cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         GLfloat wMid = vMid->win[3];
444e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_ds, eBot_ds;
445e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dt, eBot_dt;
446e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_du, eBot_du;
447e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat eMaj_dv, eBot_dv;
448e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
449cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eMaj_ds = vMax->texcoord[0][0] * wMax - vMin->texcoord[0][0] * wMin;
450cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         eBot_ds = vMid->texcoord[0][0] * wMid - vMin->texcoord[0][0] * wMin;
4519bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.texStep[0][0] = oneOverArea * (eMaj_ds * eBot.dy
4529bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                             - eMaj.dy * eBot_ds);
453e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
454e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
455cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 eMaj_dt = vMax->texcoord[0][1] * wMax - vMin->texcoord[0][1] * wMin;
456cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 eBot_dt = vMid->texcoord[0][1] * wMid - vMin->texcoord[0][1] * wMin;
4579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	 span.texStep[0][1] = oneOverArea * (eMaj_dt * eBot.dy
4589bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                             - eMaj.dy * eBot_dt);
459cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
46022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
461cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 eMaj_du = vMax->texcoord[0][2] * wMax - vMin->texcoord[0][2] * wMin;
462cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 eBot_du = vMid->texcoord[0][2] * wMid - vMin->texcoord[0][2] * wMin;
4639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	 span.texStep[0][2] = oneOverArea * (eMaj_du * eBot.dy
4649bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                             - eMaj.dy * eBot_du);
465cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 dudy = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
466e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
467cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 eMaj_dv = vMax->texcoord[0][3] * wMax - vMin->texcoord[0][3] * wMin;
468cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 eBot_dv = vMid->texcoord[0][3] * wMid - vMin->texcoord[0][3] * wMin;
4699bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	 span.texStep[0][3] = oneOverArea * (eMaj_dv * eBot.dy
4709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                             - eMaj.dy * eBot_dv);
471cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	 dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
472e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
4739bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#  ifdef INTERP_LAMBDA
4749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      {
4759bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat dudx = span.texStep[0][0] * span.texWidth[0];
4769bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat dudy = dsdy * span.texWidth[0];
4779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat dvdx = span.texStep[0][1] * span.texHeight[0];
4789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat dvdy = dtdy * span.texHeight[0];
4799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat r1 = dudx * dudx + dudy * dudy;
4809bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfloat r2 = dvdx * dvdx + dvdy * dvdy;
4819bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.rho[0] = r1 + r2; /* was rho2 = MAX2(r1,r2) */
4829bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         span.activeMask |= SPAN_LAMBDA;
4839bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      }
4849bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#  endif
485e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
4869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
487e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
4889bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_TEXTURE;
4899bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#  ifdef INTERP_LAMBDA
4909bf68ad963ba92b5d1e725f965979042495a5313Brian Paul      span.activeMask |= SPAN_LAMBDA;
4919bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#  endif
492e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
493cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         GLfloat wMax = vMax->win[3];
494cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         GLfloat wMin = vMin->win[3];
495cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell         GLfloat wMid = vMid->win[3];
496e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLuint u;
497e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
498cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell            if (ctx->Texture.Unit[u]._ReallyEnabled) {
499e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               GLfloat eMaj_ds, eBot_ds;
500e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               GLfloat eMaj_dt, eBot_dt;
501e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               GLfloat eMaj_du, eBot_du;
502e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               GLfloat eMaj_dv, eBot_dv;
503cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell               eMaj_ds = vMax->texcoord[u][0] * wMax
504cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                       - vMin->texcoord[u][0] * wMin;
505cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell               eBot_ds = vMid->texcoord[u][0] * wMid
506cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                       - vMin->texcoord[u][0] * wMin;
5079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.texStep[u][0] = oneOverArea * (eMaj_ds * eBot.dy
5089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                                   - eMaj.dy * eBot_ds);
509e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               dsdy[u] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
510e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
511cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       eMaj_dt = vMax->texcoord[u][1] * wMax
512c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul		       - vMin->texcoord[u][1] * wMin;
513cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       eBot_dt = vMid->texcoord[u][1] * wMid
514c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul		       - vMin->texcoord[u][1] * wMin;
5159bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	       span.texStep[u][1] = oneOverArea * (eMaj_dt * eBot.dy
5169bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                                   - eMaj.dy * eBot_dt);
517cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       dtdy[u] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
51822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
519cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       eMaj_du = vMax->texcoord[u][2] * wMax
520c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul                       - vMin->texcoord[u][2] * wMin;
521cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       eBot_du = vMid->texcoord[u][2] * wMid
522c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul                       - vMin->texcoord[u][2] * wMin;
5239bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	       span.texStep[u][2] = oneOverArea * (eMaj_du * eBot.dy
5249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                                   - eMaj.dy * eBot_du);
525cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       dudy[u] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
52622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
527cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       eMaj_dv = vMax->texcoord[u][3] * wMax
528c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul                       - vMin->texcoord[u][3] * wMin;
529cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       eBot_dv = vMid->texcoord[u][3] * wMid
530c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul                       - vMin->texcoord[u][3] * wMin;
5319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	       span.texStep[u][3] = oneOverArea * (eMaj_dv * eBot.dy
5329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                                   - eMaj.dy * eBot_dv);
533cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell	       dvdy[u] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
5349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#  ifdef INTERP_LAMBDA
5359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               {
5369bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfloat dudx = span.texStep[u][0] * span.texWidth[u];
5379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfloat dudy = dsdy[u] * span.texWidth[u];
5389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfloat dvdx = span.texStep[u][1] * span.texHeight[u];
5399bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfloat dvdy = dtdy[u] * span.texHeight[u];
5409bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfloat r1 = dudx * dudx + dudy * dudy;
5419bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfloat r2 = dvdx * dvdx + dvdy * dvdy;
5429bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  span.rho[u] = r1 + r2; /* was rho2 = MAX2(r1,r2) */
5439bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               }
5449bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#  endif
545e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            }
546e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         }
547e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
548e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
549e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
550e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      /*
551e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * We always sample at pixel centers.  However, we avoid
552e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * explicit half-pixel offsets in this code by incorporating
553e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * the proper offset in each of x and y during the
554e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * transformation to window coordinates.
555e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       *
556e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * We also apply the usual rasterization rules to prevent
557e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * cracks and overlaps.  A pixel is considered inside a
558e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * subtriangle if it meets all of four conditions: it is on or
559e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * to the right of the left edge, strictly to the left of the
560e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * right edge, on or below the top edge, and strictly above
561e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * the bottom edge.  (Some edges may be degenerate.)
562e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       *
563e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * The following discussion assumes left-to-right scanning
564e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * (that is, the major edge is on the left); the right-to-left
565e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * case is a straightforward variation.
566e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       *
567e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * We start by finding the half-integral y coordinate that is
568e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * at or below the top of the triangle.  This gives us the
569e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * first scan line that could possibly contain pixels that are
570e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * inside the triangle.
571e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       *
572e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * Next we creep down the major edge until we reach that y,
57322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes       * and compute the corresponding x coordinate on the edge.
574e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * Then we find the half-integral x that lies on or just
575e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * inside the edge.  This is the first pixel that might lie in
576e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * the interior of the triangle.  (We won't know for sure
577e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * until we check the other edges.)
578e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       *
579e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * As we rasterize the triangle, we'll step down the major
580e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * edge.  For each step in y, we'll move an integer number
581e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * of steps in x.  There are two possible x step sizes, which
582e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * we'll call the ``inner'' step (guaranteed to land on the
583e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * edge or inside it) and the ``outer'' step (guaranteed to
584e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * land on the edge or outside it).  The inner and outer steps
585e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * differ by one.  During rasterization we maintain an error
586e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * term that indicates our distance from the true edge, and
587e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * select either the inner step or the outer step, whichever
588e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * gets us to the first pixel that falls inside the triangle.
589e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       *
590e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * All parameters (z, red, etc.) as well as the buffer
591e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * addresses for color and z have inner and outer step values,
592e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * so that we can increment them appropriately.  This method
593e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * eliminates the need to adjust parameters by creeping a
594e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       * sub-pixel amount into the triangle at each scanline.
595e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell       */
596e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
597e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      {
598e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         int subTriangle;
5991b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed fx;
6009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fxLeftEdge, fxRightEdge, fdxLeftEdge, fdxRightEdge;
601e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfixed fdxOuter;
602e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         int idxOuter;
603e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         float dxOuter;
6049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fError, fdError;
605e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         float adjx, adjy;
606e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfixed fy;
607e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS
6089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         PIXEL_TYPE *pRow;
6099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         int dPRowOuter, dPRowInner;  /* offset in bytes */
610e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
611e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
612e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  ifdef DEPTH_TYPE
6139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         DEPTH_TYPE *zRow;
6149bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         int dZRowOuter, dZRowInner;  /* offset in bytes */
615e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  endif
6169bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fz, fdzOuter, fdzInner;
61795e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
61895e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
6191b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfloat fogLeft, dfogOuter, dfogInner;
620e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
621e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
6229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fr, fdrOuter, fdrInner;
6239bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fg, fdgOuter, fdgInner;
6249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fb, fdbOuter, fdbInner;
6259bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
6269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA
6279bf68ad963ba92b5d1e725f965979042495a5313Brian Paul         GLfixed fa=0, fdaOuter=0, fdaInner;
628e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
629e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_SPEC
6301b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed fsr=0, fdsrOuter=0, fdsrInner;
6311b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed fsg=0, fdsgOuter=0, fdsgInner;
6321b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed fsb=0, fdsbOuter=0, fdsbInner;
633e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
634e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
6351b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed fi=0, fdiOuter=0, fdiInner;
636e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
637e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
6381b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed fs=0, fdsOuter=0, fdsInner;
6391b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfixed ft=0, fdtOuter=0, fdtInner;
640e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
641e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
6421b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfloat sLeft=0, dsOuter=0, dsInner;
6431b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfloat tLeft=0, dtOuter=0, dtInner;
6441b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfloat uLeft=0, duOuter=0, duInner;
6451b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul         GLfloat vLeft=0, dvOuter=0, dvInner;
646e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
647e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
648e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat sLeft[MAX_TEXTURE_UNITS];
649e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat tLeft[MAX_TEXTURE_UNITS];
650e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat uLeft[MAX_TEXTURE_UNITS];
651e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat vLeft[MAX_TEXTURE_UNITS];
652e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat dsOuter[MAX_TEXTURE_UNITS], dsInner[MAX_TEXTURE_UNITS];
653e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat dtOuter[MAX_TEXTURE_UNITS], dtInner[MAX_TEXTURE_UNITS];
654e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat duOuter[MAX_TEXTURE_UNITS], duInner[MAX_TEXTURE_UNITS];
655e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         GLfloat dvOuter[MAX_TEXTURE_UNITS], dvInner[MAX_TEXTURE_UNITS];
656e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
657e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
658e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         for (subTriangle=0; subTriangle<=1; subTriangle++) {
659e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            EdgeT *eLeft, *eRight;
660e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            int setupLeft, setupRight;
661e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            int lines;
662e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
663e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            if (subTriangle==0) {
664e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               /* bottom half */
665e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               if (ltor) {
666e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eLeft = &eMaj;
667e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eRight = &eBot;
668e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  lines = eRight->lines;
669e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupLeft = 1;
670e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupRight = 1;
671e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
672e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               else {
673e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eLeft = &eBot;
674e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eRight = &eMaj;
675e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  lines = eLeft->lines;
676e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupLeft = 1;
677e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupRight = 1;
678e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
679e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            }
680e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            else {
681e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               /* top half */
682e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               if (ltor) {
683e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eLeft = &eMaj;
684e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eRight = &eTop;
685e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  lines = eRight->lines;
686e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupLeft = 0;
687e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupRight = 1;
688e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
689e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               else {
690e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eLeft = &eTop;
691e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  eRight = &eMaj;
692e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  lines = eLeft->lines;
693e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupLeft = 1;
694e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  setupRight = 0;
695e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
696e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               if (lines == 0)
697e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  return;
698e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            }
699e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
700e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            if (setupLeft && eLeft->lines > 0) {
701a852378a6289d154364dde440f89a39bbfc33e2dBrian Paul               const SWvertex *vLower;
702e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               GLfixed fsx = eLeft->fsx;
703e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fx = FixedCeil(fsx);
704e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fError = fx - fsx - FIXED_ONE;
705e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fxLeftEdge = fsx - FIXED_EPSILON;
706e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdxLeftEdge = eLeft->fdxdy;
707e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON);
708e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdError = fdxOuter - fdxLeftEdge + FIXED_ONE;
709e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               idxOuter = FixedToInt(fdxOuter);
710e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               dxOuter = (float) idxOuter;
711e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               (void) dxOuter;
712e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
713e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fy = eLeft->fsy;
7149bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.y = FixedToInt(fy);
715e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
716e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               adjx = (float)(fx - eLeft->fx0);  /* SCALED! */
717e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               adjy = eLeft->adjy;		 /* SCALED! */
718e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               (void) adjx;  /* silence compiler warnings */
719e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               (void) adjy;  /* silence compiler warnings */
720e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
721e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               vLower = eLeft->v0;
722e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               (void) vLower;  /* silence compiler warnings */
723e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
724e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS
725e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
7269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  pRow = (PIXEL_TYPE *) PIXEL_ADDRESS(FixedToInt(fxLeftEdge), span.y);
727e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  dPRowOuter = -((int)BYTES_PER_ROW) + idxOuter * sizeof(PIXEL_TYPE);
728e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  /* negative because Y=0 at bottom and increases upward */
729e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
730e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
731e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               /*
732e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * Now we need the set of parameter (z, color, etc.) values at
733e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * the point (fx, fy).  This gives us properly-sampled parameter
734e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * values that we can step from pixel to pixel.  Furthermore,
735e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * although we might have intermediate results that overflow
736e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * the normal parameter range when we step temporarily outside
737e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * the triangle, we shouldn't overflow or underflow for any
738e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * pixel that's actually inside the triangle.
739e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                */
740e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
741e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
742e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
743cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                  GLfloat z0 = vLower->win[2];
744e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  if (depthBits <= 16) {
745e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     /* interpolate fixed-pt values */
746e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     GLfloat tmp = (z0 * FIXED_SCALE +
747e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                                    dzdx * adjx + dzdy * adjy) + FIXED_HALF;
748e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     if (tmp < MAX_GLUINT / 2)
749e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                        fz = (GLfixed) tmp;
750e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     else
751e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                        fz = MAX_GLUINT / 2;
752e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     fdzOuter = SignedFloatToFixed(dzdy + dxOuter * dzdx);
753e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
754e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  else {
755e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     /* interpolate depth values exactly */
7569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     fz = (GLint) (z0 + dzdx * FixedToFloat(adjx)
7579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                   + dzdy * FixedToFloat(adjy));
758e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     fdzOuter = (GLint) (dzdy + dxOuter * dzdx);
759e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
760e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  ifdef DEPTH_TYPE
7619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  zRow = (DEPTH_TYPE *)
7629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                    _mesa_zbuffer_address(ctx, FixedToInt(fxLeftEdge), span.y);
763e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
764e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  endif
765e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
76695e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
76795e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
7689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               fogLeft = vLower->fog + (span.fogStep * adjx + dfogdy * adjy)
7691b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul                                       * (1.0F/FIXED_SCALE);
7709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               dfogOuter = dfogdy + dxOuter * span.fogStep;
771e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
772e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
773f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fr = (GLfixed)(ChanToFixed(vLower->color[0])
774e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                              + drdx * adjx + drdy * adjy) + FIXED_HALF;
775e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx);
776e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
777f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fg = (GLfixed)(ChanToFixed(vLower->color[1])
778e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                              + dgdx * adjx + dgdy * adjy) + FIXED_HALF;
779e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx);
780e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
781f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fb = (GLfixed)(ChanToFixed(vLower->color[2])
782e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                              + dbdx * adjx + dbdy * adjy) + FIXED_HALF;
783e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx);
784e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
7859bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA
786f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fa = (GLfixed)(ChanToFixed(vLower->color[3])
7879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                              + dadx * adjx + dady * adjy) + FIXED_HALF;
7889bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx);
7899bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
790e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_SPEC
791f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fsr = (GLfixed)(ChanToFixed(vLower->specular[0])
792e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                               + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
793e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx);
794e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
795f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fsg = (GLfixed)(ChanToFixed(vLower->specular[1])
796e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                               + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
797e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx);
798e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
799f431a3fb4dc1bf860203d79e54657e3a62bc50dfBrian Paul               fsb = (GLfixed)(ChanToFixed(vLower->specular[2])
800e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                               + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
801e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx);
802e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
803e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
804cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell               fi = (GLfixed)(vLower->index * FIXED_SCALE
805e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                              + didx * adjx + didy * adjy) + FIXED_HALF;
806e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdiOuter = SignedFloatToFixed(didy + dxOuter * didx);
807e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
808e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
809e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
810e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  GLfloat s0, t0;
811cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                  s0 = vLower->texcoord[0][0] * S_SCALE;
8129bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fs = (GLfixed)(s0 * FIXED_SCALE + dsdx * adjx
8139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                 + dsdy * adjy) + FIXED_HALF;
814e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fdsOuter = SignedFloatToFixed(dsdy + dxOuter * dsdx);
815e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
816cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell		  t0 = vLower->texcoord[0][1] * T_SCALE;
8179bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  ft = (GLfixed)(t0 * FIXED_SCALE + dtdx * adjx
8189bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                 + dtdy * adjy) + FIXED_HALF;
819cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell		  fdtOuter = SignedFloatToFixed(dtdy + dxOuter * dtdx);
820e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell	       }
821e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
822e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
823e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
824cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                  GLfloat invW = vLower->win[3];
825e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  GLfloat s0, t0, u0, v0;
826cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                  s0 = vLower->texcoord[0][0] * invW;
8279bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  sLeft = s0 + (span.texStep[0][0] * adjx + dsdy * adjy)
8289bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     * (1.0F/FIXED_SCALE);
8299bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  dsOuter = dsdy + dxOuter * span.texStep[0][0];
830cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell		  t0 = vLower->texcoord[0][1] * invW;
8319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  tLeft = t0 + (span.texStep[0][1] * adjx + dtdy * adjy)
8329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     * (1.0F/FIXED_SCALE);
8339bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  dtOuter = dtdy + dxOuter * span.texStep[0][1];
834cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell		  u0 = vLower->texcoord[0][2] * invW;
8359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  uLeft = u0 + (span.texStep[0][2] * adjx + dudy * adjy)
8369bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     * (1.0F/FIXED_SCALE);
8379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  duOuter = dudy + dxOuter * span.texStep[0][2];
838cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell		  v0 = vLower->texcoord[0][3] * invW;
8399bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  vLeft = v0 + (span.texStep[0][3] * adjx + dvdy * adjy)
8409bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     * (1.0F/FIXED_SCALE);
8419bf68ad963ba92b5d1e725f965979042495a5313Brian Paul		  dvOuter = dvdy + dxOuter * span.texStep[0][3];
842e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
843e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
844e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
845e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
846e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  GLuint u;
847e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
848cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                     if (ctx->Texture.Unit[u]._ReallyEnabled) {
849cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                        GLfloat invW = vLower->win[3];
850e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                        GLfloat s0, t0, u0, v0;
851cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                        s0 = vLower->texcoord[u][0] * invW;
8529bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        sLeft[u] = s0 + (span.texStep[u][0] * adjx + dsdy[u]
8539bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                         * adjy) * (1.0F/FIXED_SCALE);
8549bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        dsOuter[u] = dsdy[u] + dxOuter * span.texStep[u][0];
855cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell			t0 = vLower->texcoord[u][1] * invW;
8569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul			tLeft[u] = t0 + (span.texStep[u][1] * adjx + dtdy[u]
8579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                         * adjy) * (1.0F/FIXED_SCALE);
8589bf68ad963ba92b5d1e725f965979042495a5313Brian Paul			dtOuter[u] = dtdy[u] + dxOuter * span.texStep[u][1];
859cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell			u0 = vLower->texcoord[u][2] * invW;
8609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul			uLeft[u] = u0 + (span.texStep[u][2] * adjx + dudy[u]
8619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                         * adjy) * (1.0F/FIXED_SCALE);
8629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul			duOuter[u] = dudy[u] + dxOuter * span.texStep[u][2];
863cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell			v0 = vLower->texcoord[u][3] * invW;
8649bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        vLeft[u] = v0 + (span.texStep[u][3] * adjx + dvdy[u]
8659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                                         * adjy) * (1.0F/FIXED_SCALE);
8669bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        dvOuter[u] = dvdy[u] + dxOuter * span.texStep[u][3];
867e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     }
868e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
869e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
870e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
871e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
872e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            } /*if setupLeft*/
873e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
874e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
875e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            if (setupRight && eRight->lines>0) {
876e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fxRightEdge = eRight->fsx - FIXED_EPSILON;
877e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fdxRightEdge = eRight->fdxdy;
878e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            }
879e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
880e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            if (lines==0) {
881e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               continue;
882e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            }
883e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
884e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
885e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            /* Rasterize setup */
886e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS
887e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE);
888e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
889e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
890e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  ifdef DEPTH_TYPE
891e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            dZRowInner = dZRowOuter + sizeof(DEPTH_TYPE);
892e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  endif
8939bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdzInner = fdzOuter + span.zStep;
89495e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
89595e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
8969bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            dfogInner = dfogOuter + span.fogStep;
897e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
898e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
8999bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdrInner = fdrOuter + span.redStep;
9009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdgInner = fdgOuter + span.greenStep;
9019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdbInner = fdbOuter + span.blueStep;
902e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
903e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA
9049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdaInner = fdaOuter + span.alphaStep;
9059bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
9069bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC
9079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdsrInner = fdsrOuter + span.specRedStep;
9089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdsgInner = fdsgOuter + span.specGreenStep;
9099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdsbInner = fdsbOuter + span.specBlueStep;
910e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
911e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
9129bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdiInner = fdiOuter + span.indexStep;
913e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
914e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
9159bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdsInner = fdsOuter + span.intTexStep[0];
9169bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            fdtInner = fdtOuter + span.intTexStep[1];
917e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
918e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
9199bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	    dsInner = dsOuter + span.texStep[0][0];
9209bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	    dtInner = dtOuter + span.texStep[0][1];
9219bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	    duInner = duOuter + span.texStep[0][2];
9229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul	    dvInner = dvOuter + span.texStep[0][3];
923e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
924e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
925e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            {
926e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               GLuint u;
927e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
928cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                  if (ctx->Texture.Unit[u]._ReallyEnabled) {
9299bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     dsInner[u] = dsOuter[u] + span.texStep[u][0];
9309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     dtInner[u] = dtOuter[u] + span.texStep[u][1];
9319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     duInner[u] = duOuter[u] + span.texStep[u][2];
9329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     dvInner[u] = dvOuter[u] + span.texStep[u][3];
933e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
934e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
935e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            }
936e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
937e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
9389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul            while (lines > 0) {
939e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               /* initialize the span interpolants to the leftmost value */
940e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               /* ff = fixed-pt fragment */
9419bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               const GLint right = FixedToInt(fxRightEdge);
9429bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.x = FixedToInt(fxLeftEdge);
9439bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               if (right <= span.x)
9449bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  span.count = 0;
9459bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               else
9469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  span.count = right - span.x;
9479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
948e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
9499bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.z = fz;
95095e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
95195e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
9529bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.fog = fogLeft;
953e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
954e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
9559bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.red = fr;
9569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.green = fg;
9579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.blue = fb;
958e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
959e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA
9609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.alpha = fa;
9619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
9629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC
9639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.specRed = fsr;
9649bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.specGreen = fsg;
9659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.specBlue = fsb;
966e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
967e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
9689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.index = fi;
969e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
970e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
9719bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.intTex[0] = fs;
9729bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.intTex[1] = ft;
973e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
9749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
975e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
9769bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.tex[0][0] = sLeft;
9779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.tex[0][1] = tLeft;
9789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.tex[0][2] = uLeft;
9799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.tex[0][3] = vLeft;
980e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
9819bf68ad963ba92b5d1e725f965979042495a5313Brian Paul
982e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
983e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
984e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  GLuint u;
985e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
986cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                     if (ctx->Texture.Unit[u]._ReallyEnabled) {
9879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.tex[u][0] = sLeft[u];
9889bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.tex[u][1] = tLeft[u];
9899bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.tex[u][2] = uLeft[u];
9909bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.tex[u][3] = vLeft[u];
991e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     }
992e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
993e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
994e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
995e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
996e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
997e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
998e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  /* need this to accomodate round-off errors */
9999bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  const GLint len = right - span.x - 1;
10009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffrend = span.red + len * span.redStep;
10019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffgend = span.green + len * span.greenStep;
10029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffbend = span.blue + len * span.blueStep;
10039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffrend < 0) {
10049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.red -= ffrend;
10059bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.red < 0)
10069bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.red = 0;
10079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
10089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffgend < 0) {
10099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.green -= ffgend;
10109bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.green < 0)
10119bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.green = 0;
10129bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
10139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffbend < 0) {
10149bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.blue -= ffbend;
10159bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.blue < 0)
10169bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.blue = 0;
10179bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
1018e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
1019e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
10209bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA
1021e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
10229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  const GLint len = right - span.x - 1;
10239bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffaend = span.alpha + len * span.alphaStep;
10249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffaend < 0) {
10259bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.alpha -= ffaend;
10269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.alpha < 0)
10279bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.alpha = 0;
10289bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
1029e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
1030e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
10319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC
1032e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               {
10339bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  /* need this to accomodate round-off errors */
10349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  const GLint len = right - span.x - 1;
10359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffsrend = span.specRed + len * span.specRedStep;
10369bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffsgend = span.specGreen + len * span.specGreenStep;
10379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  GLfixed ffsbend = span.specBlue + len * span.specBlueStep;
10389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffsrend < 0) {
10399bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.specRed -= ffsrend;
10409bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.specRed < 0)
10419bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.specRed = 0;
10429bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
10439bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffsgend < 0) {
10449bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.specGreen -= ffsgend;
10459bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.specGreen < 0)
10469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.specGreen = 0;
10479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
10489bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  if (ffsbend < 0) {
10499bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     span.specBlue -= ffsbend;
10509bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                     if (span.specBlue < 0)
10519bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                        span.specBlue = 0;
10529bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  }
1053e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
1054e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1055e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
10569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               if (span.index < 0)  span.index = 0;
105719bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul#endif
105819bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul
10599bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               /* This is where we actually generate fragments */
10609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               if (span.count > 0) {
10619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  RENDER_SPAN( span );
10629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               }
1063e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1064e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               /*
1065e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * Advance to the next scan line.  Compute the
1066e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * new edge coordinates, and adjust the
1067e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * pixel-center x coordinate so that it stays
1068e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                * on or inside the major edge.
1069e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                */
10709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul               span.y++;
1071e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               lines--;
1072e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1073e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fxLeftEdge += fdxLeftEdge;
1074e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fxRightEdge += fdxRightEdge;
1075e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1076e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1077e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               fError += fdError;
1078e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               if (fError >= 0) {
1079e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fError -= FIXED_ONE;
1080e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS
10819bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowOuter);
1082e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1083e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
1084e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  ifdef DEPTH_TYPE
10859bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowOuter);
1086e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  endif
1087e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fz += fdzOuter;
108895e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
108995e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
10901b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul                  fogLeft += dfogOuter;
1091e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1092e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
10939bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fr += fdrOuter;
10949bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fg += fdgOuter;
10959bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fb += fdbOuter;
1096e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1097e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA
1098e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fa += fdaOuter;
1099e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
11009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC
11019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fsr += fdsrOuter;
11029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fsg += fdsgOuter;
11039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fsb += fdsbOuter;
11049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
1105e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
1106e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fi += fdiOuter;
1107e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1108e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
11099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fs += fdsOuter;
11109bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  ft += fdtOuter;
1111e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1112e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
1113e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  sLeft += dsOuter;
1114e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  tLeft += dtOuter;
1115e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  uLeft += duOuter;
1116e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  vLeft += dvOuter;
1117e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1118e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
1119e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  {
1120e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     GLuint u;
1121e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
1122cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                        if (ctx->Texture.Unit[u]._ReallyEnabled) {
1123e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           sLeft[u] += dsOuter[u];
1124e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           tLeft[u] += dtOuter[u];
1125e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           uLeft[u] += duOuter[u];
1126e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           vLeft[u] += dvOuter[u];
1127e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                        }
1128e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     }
1129e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
1130e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1131e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
1132e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               else {
1133e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS
11349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowInner);
1135e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1136e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z
1137e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  ifdef DEPTH_TYPE
11389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowInner);
1139e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#  endif
1140e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fz += fdzInner;
114195e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif
114295e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG
11431b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul                  fogLeft += dfogInner;
1144e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1145e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB
11469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fr += fdrInner;
11479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fg += fdgInner;
11489bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fb += fdbInner;
1149e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1150e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA
1151e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fa += fdaInner;
1152e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
11539bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC
11549bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fsr += fdsrInner;
11559bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fsg += fdsgInner;
11569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fsb += fdsbInner;
11579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif
1158e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX
1159e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  fi += fdiInner;
1160e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1161e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX
11629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  fs += fdsInner;
11639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul                  ft += fdtInner;
1164e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1165e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX
1166e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  sLeft += dsInner;
1167e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  tLeft += dtInner;
1168e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  uLeft += duInner;
1169e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell		  vLeft += dvInner;
1170e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1171e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX
1172e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  {
1173e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     GLuint u;
1174e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
1175cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell                        if (ctx->Texture.Unit[u]._ReallyEnabled) {
1176e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           sLeft[u] += dsInner[u];
1177e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           tLeft[u] += dtInner[u];
1178e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           uLeft[u] += duInner[u];
1179e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                           vLeft[u] += dvInner[u];
1180e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                        }
1181e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                     }
1182e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell                  }
1183e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif
1184e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell               }
1185e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell            } /*while lines>0*/
1186e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1187e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell         } /* for subTriangle */
1188e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1189e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell      }
119047cf442c1164b6b406117fccfb8b564602741ee3Brian Paul#ifdef CLEANUP_CODE
119147cf442c1164b6b406117fccfb8b564602741ee3Brian Paul      CLEANUP_CODE
119247cf442c1164b6b406117fccfb8b564602741ee3Brian Paul#endif
1193e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell   }
1194e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell}
1195e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1196e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef SETUP_CODE
119747cf442c1164b6b406117fccfb8b564602741ee3Brian Paul#undef CLEANUP_CODE
11989bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#undef RENDER_SPAN
1199e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1200e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef PIXEL_TYPE
1201e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef BYTES_PER_ROW
1202e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef PIXEL_ADDRESS
1203e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1204e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_Z
120595e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#undef INTERP_FOG
1206e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_RGB
1207e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_ALPHA
12089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#undef INTERP_SPEC
1209e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_INDEX
1210e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_INT_TEX
1211e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_TEX
1212e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_MULTITEX
121319bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul#undef INTERP_LAMBDA
1214e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1215e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef S_SCALE
1216e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef T_SCALE
1217e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1218e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef FixedToDepth
1219e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
1220e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_OCCLUSION_TEST
1221