s_tritemp.h revision a2162e42280f2aa17a5dfd36b18ff4f6026dade5
1a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul/* $Id: s_tritemp.h,v 1.18 2001/06/12 14:18:58 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; 973c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul GLboolean tiny; 98a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul const GLint snapMask = ~((FIXED_ONE / 16) - 1); /* for x/y coord snapping */ 99a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul GLfixed vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy; 100e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul struct triangle_span span; 1029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 1039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_Z 1049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul (void) fixedToDepthShift; 1059bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 1069bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 107a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* Compute fixed point x,y coords w/ half-pixel offsets and snapping. 108a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul * And find the order of the 3 vertices along the Y axis. 109a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul */ 110e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 111a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul const GLfixed fy0 = FloatToFixed(v0->win[1] + 0.5F) & snapMask; 112a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul const GLfixed fy1 = FloatToFixed(v1->win[1] + 0.5F) & snapMask; 113a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul const GLfixed fy2 = FloatToFixed(v2->win[1] + 0.5F) & snapMask; 114a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul 115a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul if (fy0 <= fy1) { 116a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul if (fy1 <= fy2) { 117a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* y0 <= y1 <= y2 */ 118a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin = v0; vMid = v1; vMax = v2; 119a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fy = fy0; vMid_fy = fy1; vMax_fy = fy2; 120e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 121a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul else if (fy2 <= fy0) { 122a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* y2 <= y0 <= y1 */ 123a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin = v2; vMid = v0; vMax = v1; 124a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fy = fy2; vMid_fy = fy0; vMax_fy = fy1; 125e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 126e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 127a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* y0 <= y2 <= y1 */ 128a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin = v0; vMid = v2; vMax = v1; 129a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fy = fy0; vMid_fy = fy2; vMax_fy = fy1; 130a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul bf = -bf; 131e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 132e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 133e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 134a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul if (fy0 <= fy2) { 135a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* y1 <= y0 <= y2 */ 136a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin = v1; vMid = v0; vMax = v2; 137a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fy = fy1; vMid_fy = fy0; vMax_fy = fy2; 138a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul bf = -bf; 139e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 140a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul else if (fy2 <= fy1) { 141a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* y2 <= y1 <= y0 */ 142a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin = v2; vMid = v1; vMax = v0; 143a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fy = fy2; vMid_fy = fy1; vMax_fy = fy0; 144a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul bf = -bf; 145e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 146e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 147a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* y1 <= y2 <= y0 */ 148a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin = v1; vMid = v2; vMax = v0; 149a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fy = fy1; vMid_fy = fy2; vMax_fy = fy0; 150e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 151e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 152a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul 153a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* fixed point X coords */ 154a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMin_fx = FloatToFixed(vMin->win[0] + 0.5F) & snapMask; 155a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMid_fx = FloatToFixed(vMid->win[0] + 0.5F) & snapMask; 156a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul vMax_fx = FloatToFixed(vMax->win[0] + 0.5F) & snapMask; 157e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 158e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 159e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* vertex/edge relationship */ 160e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eMaj.v0 = vMin; eMaj.v1 = vMax; /*TODO: .v1's not needed */ 161e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eTop.v0 = vMid; eTop.v1 = vMax; 162e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eBot.v0 = vMin; eBot.v1 = vMid; 163e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 164a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* compute deltas for each edge: vertex[upper] - vertex[lower] */ 165a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul eMaj.dx = FixedToFloat(vMax_fx - vMin_fx); 166a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul eMaj.dy = FixedToFloat(vMax_fy - vMin_fy); 167a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul eTop.dx = FixedToFloat(vMax_fx - vMid_fx); 168a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul eTop.dy = FixedToFloat(vMax_fy - vMid_fy); 169a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul eBot.dx = FixedToFloat(vMid_fx - vMin_fx); 170a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul eBot.dy = FixedToFloat(vMid_fy - vMin_fy); 171e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 172a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* compute area, oneOverArea and perform backface culling */ 173e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 174e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy; 175e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 176e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* Do backface culling */ 177e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (area * bf < 0.0) 178e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell return; 179e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 180e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (area == 0.0F) 181e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell return; 182e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 183a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul /* This may not be needed anymore. Let's see if anyone reports a problem. */ 184a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul#if 0 185e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* check for very tiny triangle */ 186a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul if (area * area < (0.001F * 0.001F)) { /* square to ensure positive value */ 187a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul oneOverArea = 1.0F / 0.001F; /* a close-enough value */ 1883c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul tiny = GL_TRUE; 1893c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul } 190a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul else 191a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul#endif 192a2162e42280f2aa17a5dfd36b18ff4f6026dade5Brian Paul { 193e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell oneOverArea = 1.0F / area; 1943c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul tiny = GL_FALSE; 1953c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul } 196e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 197e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 198e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifndef DO_OCCLUSION_TEST 199e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ctx->OcclusionResult = GL_TRUE; 200e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 201e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 202e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* Edge setup. For a triangle strip these could be reused... */ 203e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 204e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eMaj.fsy = FixedCeil(vMin_fy); 20526d729581fcf1991fbcc8320f64fa40d73170e95Brian Paul eMaj.lines = FixedToInt(FixedCeil(vMax_fy - eMaj.fsy)); 206e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (eMaj.lines > 0) { 207e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dxdy = eMaj.dx / eMaj.dy; 208e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eMaj.fdxdy = SignedFloatToFixed(dxdy); 209e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eMaj.adjy = (GLfloat) (eMaj.fsy - vMin_fy); /* SCALED! */ 210e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eMaj.fx0 = vMin_fx; 211e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eMaj.fsx = eMaj.fx0 + (GLfixed) (eMaj.adjy * dxdy); 212e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 213e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 214e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell return; /*CULLED*/ 215e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 216e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 217e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eTop.fsy = FixedCeil(vMid_fy); 21826d729581fcf1991fbcc8320f64fa40d73170e95Brian Paul eTop.lines = FixedToInt(FixedCeil(vMax_fy - eTop.fsy)); 219e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (eTop.lines > 0) { 220e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dxdy = eTop.dx / eTop.dy; 221e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eTop.fdxdy = SignedFloatToFixed(dxdy); 222e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eTop.adjy = (GLfloat) (eTop.fsy - vMid_fy); /* SCALED! */ 223e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eTop.fx0 = vMid_fx; 224e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eTop.fsx = eTop.fx0 + (GLfixed) (eTop.adjy * dxdy); 225e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 226e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 227e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eBot.fsy = FixedCeil(vMin_fy); 22826d729581fcf1991fbcc8320f64fa40d73170e95Brian Paul eBot.lines = FixedToInt(FixedCeil(vMid_fy - eBot.fsy)); 229e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (eBot.lines > 0) { 230e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dxdy = eBot.dx / eBot.dy; 231e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eBot.fdxdy = SignedFloatToFixed(dxdy); 232e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eBot.adjy = (GLfloat) (eBot.fsy - vMin_fy); /* SCALED! */ 233e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eBot.fx0 = vMin_fx; 234e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eBot.fsx = eBot.fx0 + (GLfixed) (eBot.adjy * dxdy); 235e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 236e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 237e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 238e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* 239e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Conceptually, we view a triangle as two subtriangles 240e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * separated by a perfectly horizontal line. The edge that is 241e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * intersected by this line is one with maximal absolute dy; we 242e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * call it a ``major'' edge. The other two edges are the 243e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * ``top'' edge (for the upper subtriangle) and the ``bottom'' 244e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * edge (for the lower subtriangle). If either of these two 245e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * edges is horizontal or very close to horizontal, the 246e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * corresponding subtriangle might cover zero sample points; 247e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * we take care to handle such cases, for performance as well 248e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * as correctness. 249e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 250e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * By stepping rasterization parameters along the major edge, 251e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * we can avoid recomputing them at the discontinuity where 252e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the top and bottom edges meet. However, this forces us to 25322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * be able to scan both left-to-right and right-to-left. 254e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Also, we must determine whether the major edge is at the 255e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * left or right side of the triangle. We do this by 256e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * computing the magnitude of the cross-product of the major 257e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * and top edges. Since this magnitude depends on the sine of 258e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the angle between the two edges, its sign tells us whether 259e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * we turn to the left or to the right when travelling along 260e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the major edge to the top edge, and from this we infer 261e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * whether the major edge is on the left or the right. 262e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 263e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Serendipitously, this cross-product magnitude is also a 264e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * value we need to compute the iteration parameter 265e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * derivatives for the triangle, and it can be used to perform 266e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * backface culling because its sign tells us whether the 267e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * triangle is clockwise or counterclockwise. In this code we 268e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * refer to it as ``area'' because it's also proportional to 269e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the pixel area of the triangle. 270e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */ 271e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 272e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 273e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint ltor; /* true if scanning left-to-right */ 274e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 2759bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dzdx, dzdy; 27695e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 27795e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 2789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dfogdy; 279e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 280e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 2819bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat drdx, drdy; 2829bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dgdx, dgdy; 2839bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dbdx, dbdy; 284e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 285e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA 2869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dadx, dady; 2879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 2889bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC 2899bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dsrdx, dsrdy; 2909bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dsgdx, dsgdy; 2919bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dsbdx, dsbdy; 292e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 293e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 2949bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat didx, didy; 295e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 296e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 297e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dsdx, dsdy; 298e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dtdx, dtdy; 2999bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 3009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_TEX 3019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dsdy; 3029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dtdy; 3039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dudy; 3049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dvdy; 305e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 306e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 3079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dsdy[MAX_TEXTURE_UNITS]; 3089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dtdy[MAX_TEXTURE_UNITS]; 3099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dudy[MAX_TEXTURE_UNITS]; 3109bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dvdy[MAX_TEXTURE_UNITS]; 311e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 3124b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul 3139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#if defined(INTERP_LAMBDA) && !defined(INTERP_TEX) && !defined(INTERP_MULTITEX) 3144b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul#error "Mipmapping without texturing doesn't make sense." 3154b90e68ac6d0fe4ffca5e2cd51794bb4350cac28Brian Paul#endif 316e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 317e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* 318e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Execute user-supplied setup code 319e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */ 320e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef SETUP_CODE 321e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell SETUP_CODE 322e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 323e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 324e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ltor = (oneOverArea < 0.0F); 325e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 3269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask = 0; 3279bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 328e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* compute d?/dx and d?/dy derivatives */ 329e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 3309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_Z; 331e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 332e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dz, eBot_dz; 333cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_dz = vMax->win[2] - vMin->win[2]; 334cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_dz = vMid->win[2] - vMin->win[2]; 335e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz); 336e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (dzdx > maxDepth || dzdx < -maxDepth) { 337e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* probably a sliver triangle */ 338e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dzdx = 0.0; 339e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dzdy = 0.0; 340e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 341e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 342e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx); 343e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 344e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (depthBits <= 16) 3459bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.zStep = SignedFloatToFixed(dzdx); 346e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else 3479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.zStep = (GLint) dzdx; 348e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 34995e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 35095e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 3519bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_FOG; 352e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 3531b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul const GLfloat eMaj_dfog = vMax->fog - vMin->fog; 3541b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul const GLfloat eBot_dfog = vMid->fog - vMin->fog; 3559bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.fogStep = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog); 356e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx); 357e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 358e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 359e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 3609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_RGBA; 3613c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul if (tiny) { 3623c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul /* This is kind of a hack to eliminate RGB color over/underflow 3633c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul * problems when rendering very tiny triangles. We're not doing 3643c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul * anything with alpha or specular color at this time. 3653c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul */ 3669bf68ad963ba92b5d1e725f965979042495a5313Brian Paul drdx = drdy = 0.0; span.redStep = 0; 3679bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dgdx = dgdy = 0.0; span.greenStep = 0; 3689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dbdx = dbdy = 0.0; span.blueStep = 0; 3693c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul } 3703c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul else { 371e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dr, eBot_dr; 3723c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul GLfloat eMaj_dg, eBot_dg; 3733c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul GLfloat eMaj_db, eBot_db; 3743c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_dr = (GLint) vMax->color[0] - (GLint) vMin->color[0]; 3753c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_dr = (GLint) vMid->color[0] - (GLint) vMin->color[0]; 376e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr); 3779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.redStep = SignedFloatToFixed(drdx); 378e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx); 3793c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_dg = (GLint) vMax->color[1] - (GLint) vMin->color[1]; 3803c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_dg = (GLint) vMid->color[1] - (GLint) vMin->color[1]; 381e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg); 3829bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.greenStep = SignedFloatToFixed(dgdx); 383e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx); 3843c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_db = (GLint) vMax->color[2] - (GLint) vMin->color[2]; 3853c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_db = (GLint) vMid->color[2] - (GLint) vMin->color[2]; 386e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db); 3879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.blueStep = SignedFloatToFixed(dbdx); 388e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx); 389e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 390e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 3919bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA 3929bf68ad963ba92b5d1e725f965979042495a5313Brian Paul { 3939bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat eMaj_da, eBot_da; 3949bf68ad963ba92b5d1e725f965979042495a5313Brian Paul eMaj_da = (GLint) vMax->color[3] - (GLint) vMin->color[3]; 3959bf68ad963ba92b5d1e725f965979042495a5313Brian Paul eBot_da = (GLint) vMid->color[3] - (GLint) vMin->color[3]; 3969bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da); 3979bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.alphaStep = SignedFloatToFixed(dadx); 3989bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx); 3999bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 4009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 401e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_SPEC 4029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_SPEC; 403e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 404e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dsr, eBot_dsr; 4053c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_dsr = (GLint) vMax->specular[0] - (GLint) vMin->specular[0]; 4063c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_dsr = (GLint) vMid->specular[0] - (GLint) vMin->specular[0]; 407e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr); 4089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specRedStep = SignedFloatToFixed(dsrdx); 409e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx); 410e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 411e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 412e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dsg, eBot_dsg; 4133c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_dsg = (GLint) vMax->specular[1] - (GLint) vMin->specular[1]; 4143c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_dsg = (GLint) vMid->specular[1] - (GLint) vMin->specular[1]; 415e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg); 4169bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specGreenStep = SignedFloatToFixed(dsgdx); 417e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx); 418e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 419e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 420e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dsb, eBot_dsb; 4213c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_dsb = (GLint) vMax->specular[2] - (GLint) vMin->specular[2]; 4223c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_dsb = (GLint) vMid->specular[2] - (GLint) vMin->specular[2]; 423e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb); 4249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specBlueStep = SignedFloatToFixed(dsbdx); 425e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx); 426e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 427e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 428e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 4299bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_INDEX; 430e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 431e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_di, eBot_di; 4323c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eMaj_di = (GLint) vMax->index - (GLint) vMin->index; 4333c84ab90f23df09d3114ae0b78cbc65658d5931cBrian Paul eBot_di = (GLint) vMid->index - (GLint) vMin->index; 434e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di); 4359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.indexStep = SignedFloatToFixed(didx); 436e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx); 437e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 438e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 439e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 4409bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_INT_TEXTURE; 441e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 442e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_ds, eBot_ds; 443cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE; 444cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_ds = (vMid->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE; 445e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds); 4469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.intTexStep[0] = SignedFloatToFixed(dsdx); 447e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); 448e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 449cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell { 450e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dt, eBot_dt; 451cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_dt = (vMax->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE; 452cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_dt = (vMid->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE; 453e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt); 4549bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.intTexStep[1] = SignedFloatToFixed(dtdx); 455e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); 456e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 457e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 458e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 4599bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 460e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 4619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_TEXTURE; 462e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 463cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat wMax = vMax->win[3]; 464cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat wMin = vMin->win[3]; 465cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat wMid = vMid->win[3]; 466e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_ds, eBot_ds; 467e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dt, eBot_dt; 468e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_du, eBot_du; 469e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dv, eBot_dv; 470e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 471cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_ds = vMax->texcoord[0][0] * wMax - vMin->texcoord[0][0] * wMin; 472cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_ds = vMid->texcoord[0][0] * wMid - vMin->texcoord[0][0] * wMin; 4739bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[0][0] = oneOverArea * (eMaj_ds * eBot.dy 4749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_ds); 475e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); 476e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 477cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_dt = vMax->texcoord[0][1] * wMax - vMin->texcoord[0][1] * wMin; 478cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_dt = vMid->texcoord[0][1] * wMid - vMin->texcoord[0][1] * wMin; 4799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[0][1] = oneOverArea * (eMaj_dt * eBot.dy 4809bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_dt); 481cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); 48222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes 483cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_du = vMax->texcoord[0][2] * wMax - vMin->texcoord[0][2] * wMin; 484cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_du = vMid->texcoord[0][2] * wMid - vMin->texcoord[0][2] * wMin; 4859bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[0][2] = oneOverArea * (eMaj_du * eBot.dy 4869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_du); 487cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell dudy = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx); 488e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 489cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_dv = vMax->texcoord[0][3] * wMax - vMin->texcoord[0][3] * wMin; 490cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_dv = vMid->texcoord[0][3] * wMid - vMin->texcoord[0][3] * wMin; 4919bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[0][3] = oneOverArea * (eMaj_dv * eBot.dy 4929bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_dv); 493cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx); 494e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 4959bf68ad963ba92b5d1e725f965979042495a5313Brian Paul# ifdef INTERP_LAMBDA 4969bf68ad963ba92b5d1e725f965979042495a5313Brian Paul { 4979bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dudx = span.texStep[0][0] * span.texWidth[0]; 4989bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dudy = dsdy * span.texWidth[0]; 4999bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dvdx = span.texStep[0][1] * span.texHeight[0]; 5009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dvdy = dtdy * span.texHeight[0]; 5019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat r1 = dudx * dudx + dudy * dudy; 5029bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat r2 = dvdx * dvdx + dvdy * dvdy; 5039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.rho[0] = r1 + r2; /* was rho2 = MAX2(r1,r2) */ 5049bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_LAMBDA; 5059bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 5069bf68ad963ba92b5d1e725f965979042495a5313Brian Paul# endif 507e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 5089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 509e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 5109bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_TEXTURE; 5119bf68ad963ba92b5d1e725f965979042495a5313Brian Paul# ifdef INTERP_LAMBDA 5129bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.activeMask |= SPAN_LAMBDA; 5139bf68ad963ba92b5d1e725f965979042495a5313Brian Paul# endif 514e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 515cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat wMax = vMax->win[3]; 516cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat wMin = vMin->win[3]; 517cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat wMid = vMid->win[3]; 518e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 519e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 520cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 521e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_ds, eBot_ds; 522e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dt, eBot_dt; 523e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_du, eBot_du; 524e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat eMaj_dv, eBot_dv; 525cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_ds = vMax->texcoord[u][0] * wMax 526cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell - vMin->texcoord[u][0] * wMin; 527cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_ds = vMid->texcoord[u][0] * wMid 528cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell - vMin->texcoord[u][0] * wMin; 5299bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[u][0] = oneOverArea * (eMaj_ds * eBot.dy 5309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_ds); 531e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dsdy[u] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); 532e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 533cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_dt = vMax->texcoord[u][1] * wMax 534c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul - vMin->texcoord[u][1] * wMin; 535cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_dt = vMid->texcoord[u][1] * wMid 536c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul - vMin->texcoord[u][1] * wMin; 5379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[u][1] = oneOverArea * (eMaj_dt * eBot.dy 5389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_dt); 539cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell dtdy[u] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); 54022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes 541cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_du = vMax->texcoord[u][2] * wMax 542c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul - vMin->texcoord[u][2] * wMin; 543cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_du = vMid->texcoord[u][2] * wMid 544c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul - vMin->texcoord[u][2] * wMin; 5459bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[u][2] = oneOverArea * (eMaj_du * eBot.dy 5469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_du); 547cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell dudy[u] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx); 54822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes 549cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eMaj_dv = vMax->texcoord[u][3] * wMax 550c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul - vMin->texcoord[u][3] * wMin; 551cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell eBot_dv = vMid->texcoord[u][3] * wMid 552c1b97d91c7e38290be85eb1ff56e6c108e1e47caBrian Paul - vMin->texcoord[u][3] * wMin; 5539bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.texStep[u][3] = oneOverArea * (eMaj_dv * eBot.dy 5549bf68ad963ba92b5d1e725f965979042495a5313Brian Paul - eMaj.dy * eBot_dv); 555cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell dvdy[u] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx); 5569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul# ifdef INTERP_LAMBDA 5579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul { 5589bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dudx = span.texStep[u][0] * span.texWidth[u]; 5599bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dudy = dsdy[u] * span.texWidth[u]; 5609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dvdx = span.texStep[u][1] * span.texHeight[u]; 5619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat dvdy = dtdy[u] * span.texHeight[u]; 5629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat r1 = dudx * dudx + dudy * dudy; 5639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfloat r2 = dvdx * dvdx + dvdy * dvdy; 5649bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.rho[u] = r1 + r2; /* was rho2 = MAX2(r1,r2) */ 5659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 5669bf68ad963ba92b5d1e725f965979042495a5313Brian Paul# endif 567e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 568e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 569e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 570e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 571e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 572e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* 573e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * We always sample at pixel centers. However, we avoid 574e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * explicit half-pixel offsets in this code by incorporating 575e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the proper offset in each of x and y during the 576e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * transformation to window coordinates. 577e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 578e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * We also apply the usual rasterization rules to prevent 579e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * cracks and overlaps. A pixel is considered inside a 580e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * subtriangle if it meets all of four conditions: it is on or 581e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * to the right of the left edge, strictly to the left of the 582e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * right edge, on or below the top edge, and strictly above 583e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the bottom edge. (Some edges may be degenerate.) 584e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 585e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * The following discussion assumes left-to-right scanning 586e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * (that is, the major edge is on the left); the right-to-left 587e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * case is a straightforward variation. 588e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 589e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * We start by finding the half-integral y coordinate that is 590e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * at or below the top of the triangle. This gives us the 591e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * first scan line that could possibly contain pixels that are 592e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * inside the triangle. 593e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 594e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Next we creep down the major edge until we reach that y, 59522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * and compute the corresponding x coordinate on the edge. 596e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Then we find the half-integral x that lies on or just 597e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * inside the edge. This is the first pixel that might lie in 598e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the interior of the triangle. (We won't know for sure 599e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * until we check the other edges.) 600e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 601e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * As we rasterize the triangle, we'll step down the major 602e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * edge. For each step in y, we'll move an integer number 603e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * of steps in x. There are two possible x step sizes, which 604e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * we'll call the ``inner'' step (guaranteed to land on the 605e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * edge or inside it) and the ``outer'' step (guaranteed to 606e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * land on the edge or outside it). The inner and outer steps 607e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * differ by one. During rasterization we maintain an error 608e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * term that indicates our distance from the true edge, and 609e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * select either the inner step or the outer step, whichever 610e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * gets us to the first pixel that falls inside the triangle. 611e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 612e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * All parameters (z, red, etc.) as well as the buffer 613e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * addresses for color and z have inner and outer step values, 614e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * so that we can increment them appropriately. This method 615e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * eliminates the need to adjust parameters by creeping a 616e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * sub-pixel amount into the triangle at each scanline. 617e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */ 618e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 619e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 620e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell int subTriangle; 6211b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed fx; 6229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fxLeftEdge, fxRightEdge, fdxLeftEdge, fdxRightEdge; 623e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfixed fdxOuter; 624e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell int idxOuter; 625e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell float dxOuter; 6269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fError, fdError; 627e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell float adjx, adjy; 628e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfixed fy; 629e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS 6309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul PIXEL_TYPE *pRow; 6319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul int dPRowOuter, dPRowInner; /* offset in bytes */ 632e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 633e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 634e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DEPTH_TYPE 6359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul DEPTH_TYPE *zRow; 6369bf68ad963ba92b5d1e725f965979042495a5313Brian Paul int dZRowOuter, dZRowInner; /* offset in bytes */ 637e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 6389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fz, fdzOuter, fdzInner; 63995e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 64095e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 6411b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfloat fogLeft, dfogOuter, dfogInner; 642e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 643e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 6449bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fr, fdrOuter, fdrInner; 6459bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fg, fdgOuter, fdgInner; 6469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fb, fdbOuter, fdbInner; 6479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 6489bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA 6499bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed fa=0, fdaOuter=0, fdaInner; 650e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 651e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_SPEC 6521b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed fsr=0, fdsrOuter=0, fdsrInner; 6531b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed fsg=0, fdsgOuter=0, fdsgInner; 6541b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed fsb=0, fdsbOuter=0, fdsbInner; 655e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 656e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 6571b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed fi=0, fdiOuter=0, fdiInner; 658e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 659e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 6601b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed fs=0, fdsOuter=0, fdsInner; 6611b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfixed ft=0, fdtOuter=0, fdtInner; 662e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 663e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 6641b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfloat sLeft=0, dsOuter=0, dsInner; 6651b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfloat tLeft=0, dtOuter=0, dtInner; 6661b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfloat uLeft=0, duOuter=0, duInner; 6671b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul GLfloat vLeft=0, dvOuter=0, dvInner; 668e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 669e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 670e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat sLeft[MAX_TEXTURE_UNITS]; 671e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat tLeft[MAX_TEXTURE_UNITS]; 672e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat uLeft[MAX_TEXTURE_UNITS]; 673e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat vLeft[MAX_TEXTURE_UNITS]; 674e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dsOuter[MAX_TEXTURE_UNITS], dsInner[MAX_TEXTURE_UNITS]; 675e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dtOuter[MAX_TEXTURE_UNITS], dtInner[MAX_TEXTURE_UNITS]; 676e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat duOuter[MAX_TEXTURE_UNITS], duInner[MAX_TEXTURE_UNITS]; 677e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat dvOuter[MAX_TEXTURE_UNITS], dvInner[MAX_TEXTURE_UNITS]; 678e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 679e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 680e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (subTriangle=0; subTriangle<=1; subTriangle++) { 681e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell EdgeT *eLeft, *eRight; 682e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell int setupLeft, setupRight; 683e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell int lines; 684e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 685e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (subTriangle==0) { 686e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* bottom half */ 687e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (ltor) { 688e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eLeft = &eMaj; 689e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eRight = &eBot; 690e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lines = eRight->lines; 691e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupLeft = 1; 692e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupRight = 1; 693e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 694e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 695e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eLeft = &eBot; 696e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eRight = &eMaj; 697e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lines = eLeft->lines; 698e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupLeft = 1; 699e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupRight = 1; 700e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 701e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 702e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 703e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* top half */ 704e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (ltor) { 705e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eLeft = &eMaj; 706e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eRight = &eTop; 707e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lines = eRight->lines; 708e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupLeft = 0; 709e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupRight = 1; 710e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 711e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 712e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eLeft = &eTop; 713e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell eRight = &eMaj; 714e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lines = eLeft->lines; 715e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupLeft = 1; 716e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell setupRight = 0; 717e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 718e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (lines == 0) 719e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell return; 720e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 721e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 722e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (setupLeft && eLeft->lines > 0) { 723a852378a6289d154364dde440f89a39bbfc33e2dBrian Paul const SWvertex *vLower; 724e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfixed fsx = eLeft->fsx; 725e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fx = FixedCeil(fsx); 726e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fError = fx - fsx - FIXED_ONE; 727e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fxLeftEdge = fsx - FIXED_EPSILON; 728e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdxLeftEdge = eLeft->fdxdy; 729e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON); 730e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdError = fdxOuter - fdxLeftEdge + FIXED_ONE; 731e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell idxOuter = FixedToInt(fdxOuter); 732e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dxOuter = (float) idxOuter; 733e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (void) dxOuter; 734e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 735e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fy = eLeft->fsy; 7369bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.y = FixedToInt(fy); 737e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 738e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell adjx = (float)(fx - eLeft->fx0); /* SCALED! */ 739e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell adjy = eLeft->adjy; /* SCALED! */ 740e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (void) adjx; /* silence compiler warnings */ 741e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (void) adjy; /* silence compiler warnings */ 742e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 743e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vLower = eLeft->v0; 744e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (void) vLower; /* silence compiler warnings */ 745e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 746e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS 747e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 7489bf68ad963ba92b5d1e725f965979042495a5313Brian Paul pRow = (PIXEL_TYPE *) PIXEL_ADDRESS(FixedToInt(fxLeftEdge), span.y); 749e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dPRowOuter = -((int)BYTES_PER_ROW) + idxOuter * sizeof(PIXEL_TYPE); 750e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* negative because Y=0 at bottom and increases upward */ 751e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 752e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 753e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* 754e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Now we need the set of parameter (z, color, etc.) values at 755e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the point (fx, fy). This gives us properly-sampled parameter 756e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * values that we can step from pixel to pixel. Furthermore, 757e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * although we might have intermediate results that overflow 758e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the normal parameter range when we step temporarily outside 759e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the triangle, we shouldn't overflow or underflow for any 760e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * pixel that's actually inside the triangle. 761e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */ 762e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 763e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 764e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 765cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat z0 = vLower->win[2]; 766e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (depthBits <= 16) { 767e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* interpolate fixed-pt values */ 768e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat tmp = (z0 * FIXED_SCALE + 769e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dzdx * adjx + dzdy * adjy) + FIXED_HALF; 770e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (tmp < MAX_GLUINT / 2) 771e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fz = (GLfixed) tmp; 772e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else 773e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fz = MAX_GLUINT / 2; 774e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdzOuter = SignedFloatToFixed(dzdy + dxOuter * dzdx); 775e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 776e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 777e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* interpolate depth values exactly */ 7789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fz = (GLint) (z0 + dzdx * FixedToFloat(adjx) 7799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul + dzdy * FixedToFloat(adjy)); 780e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdzOuter = (GLint) (dzdy + dxOuter * dzdx); 781e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 782e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DEPTH_TYPE 7839bf68ad963ba92b5d1e725f965979042495a5313Brian Paul zRow = (DEPTH_TYPE *) 7849bf68ad963ba92b5d1e725f965979042495a5313Brian Paul _mesa_zbuffer_address(ctx, FixedToInt(fxLeftEdge), span.y); 785e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE); 786e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 787e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 78895e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 78995e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 7909bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fogLeft = vLower->fog + (span.fogStep * adjx + dfogdy * adjy) 7911b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul * (1.0F/FIXED_SCALE); 7929bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dfogOuter = dfogdy + dxOuter * span.fogStep; 793e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 794e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 795cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fr = (GLfixed)(IntToFixed(vLower->color[0]) 796e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + drdx * adjx + drdy * adjy) + FIXED_HALF; 797e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx); 798e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 799cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fg = (GLfixed)(IntToFixed(vLower->color[1]) 800e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + dgdx * adjx + dgdy * adjy) + FIXED_HALF; 801e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx); 802e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 803cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fb = (GLfixed)(IntToFixed(vLower->color[2]) 804e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + dbdx * adjx + dbdy * adjy) + FIXED_HALF; 805e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx); 806e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 8079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA 8089bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fa = (GLfixed)(IntToFixed(vLower->color[3]) 8099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul + dadx * adjx + dady * adjy) + FIXED_HALF; 8109bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx); 8119bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 812e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_SPEC 813cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fsr = (GLfixed)(IntToFixed(vLower->specular[0]) 814e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF; 815e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx); 816e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 817cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fsg = (GLfixed)(IntToFixed(vLower->specular[1]) 818e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF; 819e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx); 820e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 821cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fsb = (GLfixed)(IntToFixed(vLower->specular[2]) 822e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF; 823e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx); 824e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 825e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 826cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fi = (GLfixed)(vLower->index * FIXED_SCALE 827e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell + didx * adjx + didy * adjy) + FIXED_HALF; 828e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdiOuter = SignedFloatToFixed(didy + dxOuter * didx); 829e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 830e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 831e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 832e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat s0, t0; 833cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell s0 = vLower->texcoord[0][0] * S_SCALE; 8349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fs = (GLfixed)(s0 * FIXED_SCALE + dsdx * adjx 8359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul + dsdy * adjy) + FIXED_HALF; 836e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdsOuter = SignedFloatToFixed(dsdy + dxOuter * dsdx); 837e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 838cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell t0 = vLower->texcoord[0][1] * T_SCALE; 8399bf68ad963ba92b5d1e725f965979042495a5313Brian Paul ft = (GLfixed)(t0 * FIXED_SCALE + dtdx * adjx 8409bf68ad963ba92b5d1e725f965979042495a5313Brian Paul + dtdy * adjy) + FIXED_HALF; 841cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell fdtOuter = SignedFloatToFixed(dtdy + dxOuter * dtdx); 842e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 843e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 844e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 845e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 846cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat invW = vLower->win[3]; 847e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat s0, t0, u0, v0; 848cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell s0 = vLower->texcoord[0][0] * invW; 8499bf68ad963ba92b5d1e725f965979042495a5313Brian Paul sLeft = s0 + (span.texStep[0][0] * adjx + dsdy * adjy) 8509bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * (1.0F/FIXED_SCALE); 8519bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dsOuter = dsdy + dxOuter * span.texStep[0][0]; 852cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell t0 = vLower->texcoord[0][1] * invW; 8539bf68ad963ba92b5d1e725f965979042495a5313Brian Paul tLeft = t0 + (span.texStep[0][1] * adjx + dtdy * adjy) 8549bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * (1.0F/FIXED_SCALE); 8559bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dtOuter = dtdy + dxOuter * span.texStep[0][1]; 856cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell u0 = vLower->texcoord[0][2] * invW; 8579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul uLeft = u0 + (span.texStep[0][2] * adjx + dudy * adjy) 8589bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * (1.0F/FIXED_SCALE); 8599bf68ad963ba92b5d1e725f965979042495a5313Brian Paul duOuter = dudy + dxOuter * span.texStep[0][2]; 860cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell v0 = vLower->texcoord[0][3] * invW; 8619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul vLeft = v0 + (span.texStep[0][3] * adjx + dvdy * adjy) 8629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * (1.0F/FIXED_SCALE); 8639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dvOuter = dvdy + dxOuter * span.texStep[0][3]; 864e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 865e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 866e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 867e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 868e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 869e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 870cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 871cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat invW = vLower->win[3]; 872e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat s0, t0, u0, v0; 873cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell s0 = vLower->texcoord[u][0] * invW; 8749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul sLeft[u] = s0 + (span.texStep[u][0] * adjx + dsdy[u] 8759bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * adjy) * (1.0F/FIXED_SCALE); 8769bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dsOuter[u] = dsdy[u] + dxOuter * span.texStep[u][0]; 877cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell t0 = vLower->texcoord[u][1] * invW; 8789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul tLeft[u] = t0 + (span.texStep[u][1] * adjx + dtdy[u] 8799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * adjy) * (1.0F/FIXED_SCALE); 8809bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dtOuter[u] = dtdy[u] + dxOuter * span.texStep[u][1]; 881cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell u0 = vLower->texcoord[u][2] * invW; 8829bf68ad963ba92b5d1e725f965979042495a5313Brian Paul uLeft[u] = u0 + (span.texStep[u][2] * adjx + dudy[u] 8839bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * adjy) * (1.0F/FIXED_SCALE); 8849bf68ad963ba92b5d1e725f965979042495a5313Brian Paul duOuter[u] = dudy[u] + dxOuter * span.texStep[u][2]; 885cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell v0 = vLower->texcoord[u][3] * invW; 8869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul vLeft[u] = v0 + (span.texStep[u][3] * adjx + dvdy[u] 8879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul * adjy) * (1.0F/FIXED_SCALE); 8889bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dvOuter[u] = dvdy[u] + dxOuter * span.texStep[u][3]; 889e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 890e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 891e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 892e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 893e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 894e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } /*if setupLeft*/ 895e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 896e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 897e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (setupRight && eRight->lines>0) { 898e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fxRightEdge = eRight->fsx - FIXED_EPSILON; 899e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fdxRightEdge = eRight->fdxdy; 900e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 901e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 902e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (lines==0) { 903e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell continue; 904e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 905e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 906e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 907e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* Rasterize setup */ 908e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS 909e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE); 910e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 911e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 912e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DEPTH_TYPE 913e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell dZRowInner = dZRowOuter + sizeof(DEPTH_TYPE); 914e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 9159bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdzInner = fdzOuter + span.zStep; 91695e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 91795e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 9189bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dfogInner = dfogOuter + span.fogStep; 919e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 920e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 9219bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdrInner = fdrOuter + span.redStep; 9229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdgInner = fdgOuter + span.greenStep; 9239bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdbInner = fdbOuter + span.blueStep; 924e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 925e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA 9269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdaInner = fdaOuter + span.alphaStep; 9279bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 9289bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC 9299bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdsrInner = fdsrOuter + span.specRedStep; 9309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdsgInner = fdsgOuter + span.specGreenStep; 9319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdsbInner = fdsbOuter + span.specBlueStep; 932e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 933e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 9349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdiInner = fdiOuter + span.indexStep; 935e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 936e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 9379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdsInner = fdsOuter + span.intTexStep[0]; 9389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fdtInner = fdtOuter + span.intTexStep[1]; 939e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 940e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 9419bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dsInner = dsOuter + span.texStep[0][0]; 9429bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dtInner = dtOuter + span.texStep[0][1]; 9439bf68ad963ba92b5d1e725f965979042495a5313Brian Paul duInner = duOuter + span.texStep[0][2]; 9449bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dvInner = dvOuter + span.texStep[0][3]; 945e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 946e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 947e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 948e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 949e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 950cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 9519bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dsInner[u] = dsOuter[u] + span.texStep[u][0]; 9529bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dtInner[u] = dtOuter[u] + span.texStep[u][1]; 9539bf68ad963ba92b5d1e725f965979042495a5313Brian Paul duInner[u] = duOuter[u] + span.texStep[u][2]; 9549bf68ad963ba92b5d1e725f965979042495a5313Brian Paul dvInner[u] = dvOuter[u] + span.texStep[u][3]; 955e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 956e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 957e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 958e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 959e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 9609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul while (lines > 0) { 961e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* initialize the span interpolants to the leftmost value */ 962e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* ff = fixed-pt fragment */ 9639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul const GLint right = FixedToInt(fxRightEdge); 9649bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.x = FixedToInt(fxLeftEdge); 9659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (right <= span.x) 9669bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.count = 0; 9679bf68ad963ba92b5d1e725f965979042495a5313Brian Paul else 9689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.count = right - span.x; 9699bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 970e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 9719bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.z = fz; 97295e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 97395e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 9749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.fog = fogLeft; 975e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 976e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 9779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.red = fr; 9789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.green = fg; 9799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.blue = fb; 980e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 981e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA 9829bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.alpha = fa; 9839bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 9849bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC 9859bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specRed = fsr; 9869bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specGreen = fsg; 9879bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specBlue = fsb; 988e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 989e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 9909bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.index = fi; 991e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 992e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 9939bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.intTex[0] = fs; 9949bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.intTex[1] = ft; 995e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 9969bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 997e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 9989bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[0][0] = sLeft; 9999bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[0][1] = tLeft; 10009bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[0][2] = uLeft; 10019bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[0][3] = vLeft; 1002e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 10039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul 1004e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 1005e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 1006e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 1007e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 1008cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 10099bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[u][0] = sLeft[u]; 10109bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[u][1] = tLeft[u]; 10119bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[u][2] = uLeft[u]; 10129bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.tex[u][3] = vLeft[u]; 1013e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1014e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1015e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1016e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1017e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1018e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 1019e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 1020e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* need this to accomodate round-off errors */ 10219bf68ad963ba92b5d1e725f965979042495a5313Brian Paul const GLint len = right - span.x - 1; 10229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffrend = span.red + len * span.redStep; 10239bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffgend = span.green + len * span.greenStep; 10249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffbend = span.blue + len * span.blueStep; 10259bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffrend < 0) { 10269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.red -= ffrend; 10279bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.red < 0) 10289bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.red = 0; 10299bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 10309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffgend < 0) { 10319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.green -= ffgend; 10329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.green < 0) 10339bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.green = 0; 10349bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 10359bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffbend < 0) { 10369bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.blue -= ffbend; 10379bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.blue < 0) 10389bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.blue = 0; 10399bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 1040e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1041e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 10429bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_ALPHA 1043e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 10449bf68ad963ba92b5d1e725f965979042495a5313Brian Paul const GLint len = right - span.x - 1; 10459bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffaend = span.alpha + len * span.alphaStep; 10469bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffaend < 0) { 10479bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.alpha -= ffaend; 10489bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.alpha < 0) 10499bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.alpha = 0; 10509bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 1051e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1052e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 10539bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC 1054e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 10559bf68ad963ba92b5d1e725f965979042495a5313Brian Paul /* need this to accomodate round-off errors */ 10569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul const GLint len = right - span.x - 1; 10579bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffsrend = span.specRed + len * span.specRedStep; 10589bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffsgend = span.specGreen + len * span.specGreenStep; 10599bf68ad963ba92b5d1e725f965979042495a5313Brian Paul GLfixed ffsbend = span.specBlue + len * span.specBlueStep; 10609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffsrend < 0) { 10619bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specRed -= ffsrend; 10629bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.specRed < 0) 10639bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specRed = 0; 10649bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 10659bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffsgend < 0) { 10669bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specGreen -= ffsgend; 10679bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.specGreen < 0) 10689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specGreen = 0; 10699bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 10709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (ffsbend < 0) { 10719bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specBlue -= ffsbend; 10729bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.specBlue < 0) 10739bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.specBlue = 0; 10749bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 1075e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1076e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1077e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 10789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.index < 0) span.index = 0; 107919bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul#endif 108019bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul 10819bf68ad963ba92b5d1e725f965979042495a5313Brian Paul /* This is where we actually generate fragments */ 10829bf68ad963ba92b5d1e725f965979042495a5313Brian Paul if (span.count > 0) { 10839bf68ad963ba92b5d1e725f965979042495a5313Brian Paul RENDER_SPAN( span ); 10849bf68ad963ba92b5d1e725f965979042495a5313Brian Paul } 1085e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1086e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* 1087e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Advance to the next scan line. Compute the 1088e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * new edge coordinates, and adjust the 1089e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * pixel-center x coordinate so that it stays 1090e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * on or inside the major edge. 1091e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */ 10929bf68ad963ba92b5d1e725f965979042495a5313Brian Paul span.y++; 1093e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lines--; 1094e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1095e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fxLeftEdge += fdxLeftEdge; 1096e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fxRightEdge += fdxRightEdge; 1097e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1098e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1099e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fError += fdError; 1100e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (fError >= 0) { 1101e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fError -= FIXED_ONE; 1102e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS 11039bf68ad963ba92b5d1e725f965979042495a5313Brian Paul pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowOuter); 1104e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1105e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 1106e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DEPTH_TYPE 11079bf68ad963ba92b5d1e725f965979042495a5313Brian Paul zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowOuter); 1108e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 1109e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fz += fdzOuter; 111095e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 111195e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 11121b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul fogLeft += dfogOuter; 1113e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1114e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 11159bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fr += fdrOuter; 11169bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fg += fdgOuter; 11179bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fb += fdbOuter; 1118e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1119e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA 1120e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fa += fdaOuter; 1121e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 11229bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC 11239bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fsr += fdsrOuter; 11249bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fsg += fdsgOuter; 11259bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fsb += fdsbOuter; 11269bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 1127e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 1128e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fi += fdiOuter; 1129e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1130e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 11319bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fs += fdsOuter; 11329bf68ad963ba92b5d1e725f965979042495a5313Brian Paul ft += fdtOuter; 1133e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1134e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 1135e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell sLeft += dsOuter; 1136e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell tLeft += dtOuter; 1137e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell uLeft += duOuter; 1138e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vLeft += dvOuter; 1139e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1140e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 1141e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 1142e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 1143e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 1144cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 1145e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell sLeft[u] += dsOuter[u]; 1146e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell tLeft[u] += dtOuter[u]; 1147e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell uLeft[u] += duOuter[u]; 1148e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vLeft[u] += dvOuter[u]; 1149e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1150e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1151e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1152e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1153e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1154e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 1155e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef PIXEL_ADDRESS 11569bf68ad963ba92b5d1e725f965979042495a5313Brian Paul pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowInner); 1157e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1158e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_Z 1159e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DEPTH_TYPE 11609bf68ad963ba92b5d1e725f965979042495a5313Brian Paul zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowInner); 1161e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 1162e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fz += fdzInner; 116395e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#endif 116495e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#ifdef INTERP_FOG 11651b3528fe635242f782fbcdde3ba74b5b7359a362Brian Paul fogLeft += dfogInner; 1166e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1167e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_RGB 11689bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fr += fdrInner; 11699bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fg += fdgInner; 11709bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fb += fdbInner; 1171e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1172e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_ALPHA 1173e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fa += fdaInner; 1174e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 11759bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#ifdef INTERP_SPEC 11769bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fsr += fdsrInner; 11779bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fsg += fdsgInner; 11789bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fsb += fdsbInner; 11799bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#endif 1180e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INDEX 1181e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fi += fdiInner; 1182e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1183e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_INT_TEX 11849bf68ad963ba92b5d1e725f965979042495a5313Brian Paul fs += fdsInner; 11859bf68ad963ba92b5d1e725f965979042495a5313Brian Paul ft += fdtInner; 1186e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1187e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_TEX 1188e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell sLeft += dsInner; 1189e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell tLeft += dtInner; 1190e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell uLeft += duInner; 1191e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vLeft += dvInner; 1192e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1193e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef INTERP_MULTITEX 1194e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 1195e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 1196e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 1197cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 1198e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell sLeft[u] += dsInner[u]; 1199e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell tLeft[u] += dtInner[u]; 1200e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell uLeft[u] += duInner[u]; 1201e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vLeft[u] += dvInner[u]; 1202e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1203e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1204e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1205e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 1206e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1207e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } /*while lines>0*/ 1208e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1209e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } /* for subTriangle */ 1210e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1211e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 121247cf442c1164b6b406117fccfb8b564602741ee3Brian Paul#ifdef CLEANUP_CODE 121347cf442c1164b6b406117fccfb8b564602741ee3Brian Paul CLEANUP_CODE 121447cf442c1164b6b406117fccfb8b564602741ee3Brian Paul#endif 1215e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 1216e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell} 1217e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1218e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef SETUP_CODE 121947cf442c1164b6b406117fccfb8b564602741ee3Brian Paul#undef CLEANUP_CODE 12209bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#undef RENDER_SPAN 1221e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1222e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef PIXEL_TYPE 1223e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef BYTES_PER_ROW 1224e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef PIXEL_ADDRESS 1225e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1226e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_Z 122795e02a210ed339ad20b0c16284dcdcf9af2dc755Brian Paul#undef INTERP_FOG 1228e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_RGB 1229e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_ALPHA 12309bf68ad963ba92b5d1e725f965979042495a5313Brian Paul#undef INTERP_SPEC 1231e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_INDEX 1232e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_INT_TEX 1233e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_TEX 1234e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef INTERP_MULTITEX 123519bbfc62638b60dd1a41e84686f24483adea5b03Brian Paul#undef INTERP_LAMBDA 1236e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1237e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef S_SCALE 1238e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef T_SCALE 1239e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1240e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef FixedToDepth 1241e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 1242e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_OCCLUSION_TEST 1243