s_aatritemp.h revision 22144ab7552f0799bcfca506bf4ffa7f70a06649
122144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes/* $Id: s_aatritemp.h,v 1.8 2001/03/12 00:48:41 gareth Exp $ */ 2e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 3e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell/* 4e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Mesa 3-D graphics library 5e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Version: 3.5 622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 722144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 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 * Antialiased Triangle Rasterizer Template 30e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 31e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * This file is #include'd to generate custom AA triangle rasterizers. 32e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * NOTE: this code hasn't been optimized yet. That'll come after it 33e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * works correctly. 34e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * 35e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * The following macros may be defined to indicate what auxillary information 36e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * must be copmuted across the triangle: 37e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * DO_Z - if defined, compute Z values 38e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * DO_RGBA - if defined, compute RGBA values 39e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * DO_INDEX - if defined, compute color index values 40e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * DO_SPEC - if defined, compute specular RGB values 41e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * DO_TEX - if defined, compute unit 0 STRQ texcoords 42e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * DO_MULTITEX - if defined, compute all unit's STRQ texcoords 43e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */ 44e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 45e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ 46e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell{ 47cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat *p0 = v0->win; 48cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat *p1 = v1->win; 49cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat *p2 = v2->win; 50a852378a6289d154364dde440f89a39bbfc33e2dBrian Paul const SWvertex *vMin, *vMid, *vMax; 51e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint iyMin, iyMax; 52e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat yMin, yMax; 53e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLboolean ltor; 54e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat majDx, majDy; 55e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_Z 56e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat zPlane[4]; /* Z (depth) */ 57e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLdepth z[MAX_WIDTH]; 58e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat fogPlane[4]; 59e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfixed fog[MAX_WIDTH]; 60e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 61e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_RGBA 62e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; /* color */ 63e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLchan rgba[MAX_WIDTH][4]; 64e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 65e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_INDEX 66e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat iPlane[4]; /* color index */ 67e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint index[MAX_WIDTH]; 68e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 69e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_SPEC 70e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat srPlane[4], sgPlane[4], sbPlane[4]; /* spec color */ 71e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLchan spec[MAX_WIDTH][4]; 72e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 73e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_TEX 74e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4]; 75e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat texWidth, texHeight; 76e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH]; 77e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat lambda[MAX_WIDTH]; 78e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_MULTITEX) 79e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat sPlane[MAX_TEXTURE_UNITS][4]; 80e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat tPlane[MAX_TEXTURE_UNITS][4]; 81e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat uPlane[MAX_TEXTURE_UNITS][4]; 82e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat vPlane[MAX_TEXTURE_UNITS][4]; 83e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS]; 84e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH]; 85e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH]; 86e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH]; 87e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH]; 88e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 891e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign; 90e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 91e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* determine bottom to top order of vertices */ 92e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 93cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat y0 = v0->win[1]; 94cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat y1 = v1->win[1]; 95cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat y2 = v2->win[1]; 96e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (y0 <= y1) { 97e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (y1 <= y2) { 98e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */ 99e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 100e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else if (y2 <= y0) { 101e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */ 102e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 103e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 104e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vMin = v0; vMid = v2; vMax = v1; bf = -bf; /* y0<=y2<=y1 */ 105e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 106e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 107e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 108e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (y0 <= y2) { 109e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vMin = v1; vMid = v0; vMax = v2; bf = -bf; /* y1<=y0<=y2 */ 110e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 111e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else if (y2 <= y1) { 112e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vMin = v2; vMid = v1; vMax = v0; bf = -bf; /* y2<=y1<=y0 */ 113e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 114e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 115e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */ 116e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 117e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 118e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 119e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 120cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell majDx = vMax->win[0] - vMin->win[0]; 121cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell majDy = vMax->win[1] - vMin->win[1]; 122e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 123e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 124cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat botDx = vMid->win[0] - vMin->win[0]; 125cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat botDy = vMid->win[1] - vMin->win[1]; 126e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const GLfloat area = majDx * botDy - botDx * majDy; 127e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ltor = (GLboolean) (area < 0.0F); 128e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* Do backface culling */ 129e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (area * bf < 0 || area * area < .0025) 130e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell return; 131e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 132e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 133e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifndef DO_OCCLUSION_TEST 134e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ctx->OcclusionResult = GL_TRUE; 135e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 136e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 137e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* plane setup */ 138e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_Z 139e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); 14022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes compute_plane(p0, p1, p2, 14122144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes v0->fog, 14222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes v1->fog, 14322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes v2->fog, 144e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fogPlane); 145e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 146e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_RGBA 147e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (ctx->Light.ShadeModel == GL_SMOOTH) { 148cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->color[0], v1->color[0], v2->color[0], rPlane); 149cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->color[1], v1->color[1], v2->color[1], gPlane); 150cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->color[2], v1->color[2], v2->color[2], bPlane); 151cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->color[3], v1->color[3], v2->color[3], aPlane); 152e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 153e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 15458e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->color[RCOMP], rPlane); 15558e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->color[GCOMP], gPlane); 15658e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->color[BCOMP], bPlane); 15758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->color[ACOMP], aPlane); 158e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 159e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 160e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_INDEX 161e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (ctx->Light.ShadeModel == GL_SMOOTH) { 162cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->index, 163cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell v1->index, v2->index, iPlane); 164e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 165e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 16658e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->index, iPlane); 167e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 168e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 169e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_SPEC 17058e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell if (ctx->Light.ShadeModel == GL_SMOOTH) { 171cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->specular[0], v1->specular[0], v2->specular[0],srPlane); 172cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->specular[1], v1->specular[1], v2->specular[1],sgPlane); 173cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell compute_plane(p0, p1, p2, v0->specular[2], v1->specular[2], v2->specular[2],sbPlane); 174e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 17558e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell else { 17658e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell /* KW: added this */ 17758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->specular[RCOMP], srPlane); 17858e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->specular[GCOMP], sgPlane); 17958e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v2->specular[BCOMP], sbPlane); 18058e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell } 181e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 182e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_TEX 183e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 184cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; 185e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; 186cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat invW0 = v0->win[3]; 187cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat invW1 = v1->win[3]; 188cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat invW2 = v2->win[3]; 189cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat s0 = v0->texcoord[0][0] * invW0; 190cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat s1 = v1->texcoord[0][0] * invW1; 191cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat s2 = v2->texcoord[0][0] * invW2; 192cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat t0 = v0->texcoord[0][1] * invW0; 193cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat t1 = v1->texcoord[0][1] * invW1; 194cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat t2 = v2->texcoord[0][1] * invW2; 195cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat r0 = v0->texcoord[0][2] * invW0; 196cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat r1 = v1->texcoord[0][2] * invW1; 197cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat r2 = v2->texcoord[0][2] * invW2; 198cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat q0 = v0->texcoord[0][3] * invW0; 199cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat q1 = v1->texcoord[0][3] * invW1; 200cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat q2 = v2->texcoord[0][3] * invW2; 201e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, s0, s1, s2, sPlane); 202e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, t0, t1, t2, tPlane); 203e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, r0, r1, r2, uPlane); 204e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, q0, q1, q2, vPlane); 205e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell texWidth = (GLfloat) texImage->Width; 206e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell texHeight = (GLfloat) texImage->Height; 207e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 208e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_MULTITEX) 209e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 210e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint u; 211e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 212cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[u]._ReallyEnabled) { 213cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; 214e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; 215cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat invW0 = v0->win[3]; 216cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat invW1 = v1->win[3]; 217cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat invW2 = v2->win[3]; 218cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat s0 = v0->texcoord[u][0] * invW0; 219cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat s1 = v1->texcoord[u][0] * invW1; 220cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat s2 = v2->texcoord[u][0] * invW2; 221cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat t0 = v0->texcoord[u][1] * invW0; 222cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat t1 = v1->texcoord[u][1] * invW1; 223cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat t2 = v2->texcoord[u][1] * invW2; 224cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat r0 = v0->texcoord[u][2] * invW0; 225cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat r1 = v1->texcoord[u][2] * invW1; 226cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat r2 = v2->texcoord[u][2] * invW2; 227cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat q0 = v0->texcoord[u][3] * invW0; 228cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat q1 = v1->texcoord[u][3] * invW1; 229cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat q2 = v2->texcoord[u][3] * invW2; 230e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, s0, s1, s2, sPlane[u]); 231e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, t0, t1, t2, tPlane[u]); 232e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, r0, r1, r2, uPlane[u]); 233e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell compute_plane(p0, p1, p2, q0, q1, q2, vPlane[u]); 234e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell texWidth[u] = (GLfloat) texImage->Width; 235e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell texHeight[u] = (GLfloat) texImage->Height; 236e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 237e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 238e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 239e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 240e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 241cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell yMin = vMin->win[1]; 242cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell yMax = vMax->win[1]; 243e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell iyMin = (int) yMin; 244e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell iyMax = (int) yMax + 1; 245e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 246e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (ltor) { 247e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* scan left to right */ 248cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const float *pMin = vMin->win; 249cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const float *pMid = vMid->win; 250cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const float *pMax = vMax->win; 251e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const float dxdy = majDx / majDy; 252e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const float xAdj = dxdy < 0.0F ? -dxdy : 0.0F; 253cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell float x = vMin->win[0] - (yMin - iyMin) * dxdy; 254e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell int iy; 255e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { 256e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint ix, startX = (GLint) (x - xAdj); 257e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint count, n; 258e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat coverage = 0.0F; 259e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* skip over fragments with zero coverage */ 260e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell while (startX < MAX_WIDTH) { 261e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell coverage = compute_coveragef(pMin, pMid, pMax, startX, iy); 262e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (coverage > 0.0F) 263e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell break; 264e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell startX++; 265e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 266e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 267e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* enter interior of triangle */ 268e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ix = startX; 269e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell count = 0; 270e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell while (coverage > 0.0F) { 271e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_Z 272e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell z[count] = (GLdepth) solve_plane(ix, iy, zPlane); 273e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fog[count] = FloatToFixed(solve_plane(ix, iy, fogPlane)); 274e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 275e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_RGBA 276e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[count][RCOMP] = solve_plane_chan(ix, iy, rPlane); 277e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[count][GCOMP] = solve_plane_chan(ix, iy, gPlane); 278e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[count][BCOMP] = solve_plane_chan(ix, iy, bPlane); 279e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[count][ACOMP] = (GLchan) (solve_plane_chan(ix, iy, aPlane) * coverage); 280e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 281e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_INDEX 282e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 283e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint frac = compute_coveragei(pMin, pMid, pMax, ix, iy); 284e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint indx = (GLint) solve_plane(ix, iy, iPlane); 285e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell index[count] = (indx & ~0xf) | frac; 286e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 287e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 288e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_SPEC 289e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell spec[count][RCOMP] = solve_plane_chan(ix, iy, srPlane); 290e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell spec[count][GCOMP] = solve_plane_chan(ix, iy, sgPlane); 291e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell spec[count][BCOMP] = solve_plane_chan(ix, iy, sbPlane); 292e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 293e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_TEX 294e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 295e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat invQ = solve_plane_recip(ix, iy, vPlane); 296e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s[count] = solve_plane(ix, iy, sPlane) * invQ; 297e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell t[count] = solve_plane(ix, iy, tPlane) * invQ; 298e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell u[count] = solve_plane(ix, iy, uPlane) * invQ; 299e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda[count] = compute_lambda(sPlane, tPlane, invQ, 300e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell texWidth, texHeight); 301e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 302e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_MULTITEX) 303e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 304e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint unit; 305e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { 306cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[unit]._ReallyEnabled) { 307e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat invQ = solve_plane_recip(ix, iy, vPlane[unit]); 308e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s[unit][count] = solve_plane(ix, iy, sPlane[unit]) * invQ; 309e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell t[unit][count] = solve_plane(ix, iy, tPlane[unit]) * invQ; 310e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell u[unit][count] = solve_plane(ix, iy, uPlane[unit]) * invQ; 311e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda[unit][count] = compute_lambda(sPlane[unit], 312e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell tPlane[unit], invQ, texWidth[unit], texHeight[unit]); 313e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 314e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 315e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 316e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 317e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ix++; 318e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell count++; 319e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell coverage = compute_coveragef(pMin, pMid, pMax, ix, iy); 320e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 321e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 322e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell n = (GLuint) ix - (GLuint) startX; 323e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_MULTITEX 324e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DO_SPEC 32508836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_multitexture_span(ctx, n, startX, iy, z, fog, 326e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) s, 327e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) t, 328e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) u, 329e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (GLfloat (*)[MAX_WIDTH]) lambda, 330e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba, (const GLchan (*)[4]) spec, 331e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GL_POLYGON); 332e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# else 33308836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_multitexture_span(ctx, n, startX, iy, z, fog, 334e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) s, 335e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) t, 336e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) u, 337e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda, rgba, NULL, GL_POLYGON); 338e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 339e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_TEX) 340e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DO_SPEC 34108836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_texture_span(ctx, n, startX, iy, z, fog, 342e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s, t, u, lambda, rgba, 343e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLchan (*)[4]) spec, GL_POLYGON); 344e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# else 34508836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_texture_span(ctx, n, startX, iy, z, fog, 346e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s, t, u, lambda, 347e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba, NULL, GL_POLYGON); 348e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 349e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_RGBA) 35008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_rgba_span(ctx, n, startX, iy, z, fog, rgba, GL_POLYGON); 351e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_INDEX) 35208836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_index_span(ctx, n, startX, iy, z, fog, index, GL_POLYGON); 353e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 354e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 355e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 356e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell else { 357e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* scan right to left */ 358cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat *pMin = vMin->win; 359cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat *pMid = vMid->win; 360cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell const GLfloat *pMax = vMax->win; 361e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const GLfloat dxdy = majDx / majDy; 362e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F; 363cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell GLfloat x = vMin->win[0] - (yMin - iyMin) * dxdy; 364e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint iy; 365e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { 366e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint ix, left, startX = (GLint) (x + xAdj); 367e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint count, n; 368e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat coverage = 0.0F; 369e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* skip fragments with zero coverage */ 370e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell while (startX >= 0) { 371e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell coverage = compute_coveragef(pMin, pMax, pMid, startX, iy); 372e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell if (coverage > 0.0F) 373e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell break; 374e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell startX--; 375e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 376e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 377e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell /* enter interior of triangle */ 378e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ix = startX; 379e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell count = 0; 380e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell while (coverage > 0.0F) { 381e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_Z 382e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell z[ix] = (GLdepth) solve_plane(ix, iy, zPlane); 383e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell fog[ix] = FloatToFixed(solve_plane(ix, iy, fogPlane)); 384e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 385e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_RGBA 386e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[ix][RCOMP] = solve_plane_chan(ix, iy, rPlane); 387e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[ix][GCOMP] = solve_plane_chan(ix, iy, gPlane); 388e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[ix][BCOMP] = solve_plane_chan(ix, iy, bPlane); 389e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba[ix][ACOMP] = (GLchan) (solve_plane_chan(ix, iy, aPlane) * coverage); 390e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 391e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_INDEX 392e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 393e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint frac = compute_coveragei(pMin, pMax, pMid, ix, iy); 394e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint indx = (GLint) solve_plane(ix, iy, iPlane); 395e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell index[ix] = (indx & ~0xf) | frac; 396e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 397e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 398e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_SPEC 399e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell spec[ix][RCOMP] = solve_plane_chan(ix, iy, srPlane); 400e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell spec[ix][GCOMP] = solve_plane_chan(ix, iy, sgPlane); 401e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell spec[ix][BCOMP] = solve_plane_chan(ix, iy, sbPlane); 402e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 403e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_TEX 404e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 405e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat invQ = solve_plane_recip(ix, iy, vPlane); 406e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s[ix] = solve_plane(ix, iy, sPlane) * invQ; 407e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell t[ix] = solve_plane(ix, iy, tPlane) * invQ; 408e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell u[ix] = solve_plane(ix, iy, uPlane) * invQ; 409e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda[ix] = compute_lambda(sPlane, tPlane, invQ, 410e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell texWidth, texHeight); 411e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 412e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_MULTITEX) 413e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 414e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint unit; 415e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { 416cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[unit]._ReallyEnabled) { 417e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLfloat invQ = solve_plane_recip(ix, iy, vPlane[unit]); 418e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s[unit][ix] = solve_plane(ix, iy, sPlane[unit]) * invQ; 419e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell t[unit][ix] = solve_plane(ix, iy, tPlane[unit]) * invQ; 420e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell u[unit][ix] = solve_plane(ix, iy, uPlane[unit]) * invQ; 421e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda[unit][ix] = compute_lambda(sPlane[unit], 422e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell tPlane[unit], invQ, texWidth[unit], texHeight[unit]); 423e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 424e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 425e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 426e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 427e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell ix--; 428e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell count++; 429e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell coverage = compute_coveragef(pMin, pMax, pMid, ix, iy); 430e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 431e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 432e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell n = (GLuint) startX - (GLuint) ix; 433e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell left = ix + 1; 434e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_MULTITEX 435e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell { 436e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLuint unit; 437e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { 438cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0Keith Whitwell if (ctx->Texture.Unit[unit]._ReallyEnabled) { 439e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GLint j; 440b51b0a847d7e7daaea69f77ab569086ef81c24a2Brian Paul for (j = 0; j < (GLint) n; j++) { 441e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s[unit][j] = s[unit][j + left]; 442e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell t[unit][j] = t[unit][j + left]; 443e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell u[unit][j] = u[unit][j + left]; 444e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda[unit][j] = lambda[unit][j + left]; 445e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 446e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 447e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 448e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 449e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DO_SPEC 45008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left, 451e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) s, 452e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) t, 453e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) u, 454e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda, rgba + left, 455e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLchan (*)[4]) (spec + left), 456e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GL_POLYGON); 457e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# else 45808836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left, 459e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) s, 460e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) t, 461e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLfloat (*)[MAX_WIDTH]) u, 462e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda, 463e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba + left, NULL, GL_POLYGON); 464e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 465e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_TEX) 466e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# ifdef DO_SPEC 46708836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left, 468e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s + left, t + left, u + left, 469e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell lambda + left, rgba + left, 470e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell (const GLchan (*)[4]) (spec + left), 471e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell GL_POLYGON); 472e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# else 47322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes _mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left, 474e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell s + left, t + left, 475e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell u + left, lambda + left, 476e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba + left, NULL, GL_POLYGON); 477e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell# endif 478e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_RGBA) 47922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes _mesa_write_rgba_span(ctx, n, left, iy, z + left, fog + left, 480e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell rgba + left, GL_POLYGON); 481e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#elif defined(DO_INDEX) 48222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes _mesa_write_index_span(ctx, n, left, iy, z + left, fog + left, 483e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell index + left, GL_POLYGON); 484e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 485e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 486e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell } 487e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell} 488e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 489e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 490e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_Z 491e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_Z 492e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 493e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 494e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_RGBA 495e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_RGBA 496e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 497e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 498e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_INDEX 499e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_INDEX 500e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 501e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 502e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_SPEC 503e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_SPEC 504e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 505e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 506e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_TEX 507e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_TEX 508e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 509e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 510e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_MULTITEX 511e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_MULTITEX 512e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 513e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell 514e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#ifdef DO_OCCLUSION_TEST 515e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#undef DO_OCCLUSION_TEST 516e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#endif 517