| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 6.3 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved. |
| 6 |
* |
| 7 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
* copy of this software and associated documentation files (the "Software"), |
| 9 |
* to deal in the Software without restriction, including without limitation |
| 10 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
* Software is furnished to do so, subject to the following conditions: |
| 13 |
* |
| 14 |
* The above copyright notice and this permission notice shall be included |
| 15 |
* in all copies or substantial portions of the Software. |
| 16 |
* |
| 17 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 |
*/ |
| 24 |
|
| 25 |
|
| 26 |
/* |
| 27 |
* Antialiased Triangle Rasterizer Template |
| 28 |
* |
| 29 |
* This file is #include'd to generate custom AA triangle rasterizers. |
| 30 |
* NOTE: this code hasn't been optimized yet. That'll come after it |
| 31 |
* works correctly. |
| 32 |
* |
| 33 |
* The following macros may be defined to indicate what auxillary information |
| 34 |
* must be copmuted across the triangle: |
| 35 |
* DO_Z - if defined, compute Z values |
| 36 |
* DO_RGBA - if defined, compute RGBA values |
| 37 |
* DO_INDEX - if defined, compute color index values |
| 38 |
* DO_SPEC - if defined, compute specular RGB values |
| 39 |
* DO_TEX - if defined, compute unit 0 STRQ texcoords |
| 40 |
* DO_MULTITEX - if defined, compute all unit's STRQ texcoords |
| 41 |
*/ |
| 42 |
|
| 43 |
/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ |
| 44 |
{ |
| 45 |
const GLfloat *p0 = v0->win; |
| 46 |
const GLfloat *p1 = v1->win; |
| 47 |
const GLfloat *p2 = v2->win; |
| 48 |
const SWvertex *vMin, *vMid, *vMax; |
| 49 |
GLint iyMin, iyMax; |
| 50 |
GLfloat yMin, yMax; |
| 51 |
GLboolean ltor; |
| 52 |
GLfloat majDx, majDy; /* major (i.e. long) edge dx and dy */ |
| 53 |
|
| 54 |
struct sw_span span; |
| 55 |
|
| 56 |
#ifdef DO_Z |
| 57 |
GLfloat zPlane[4]; |
| 58 |
#endif |
| 59 |
#ifdef DO_FOG |
| 60 |
GLfloat fogPlane[4]; |
| 61 |
#else |
| 62 |
GLfloat *fog = NULL; |
| 63 |
#endif |
| 64 |
#ifdef DO_RGBA |
| 65 |
GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; |
| 66 |
#endif |
| 67 |
#ifdef DO_INDEX |
| 68 |
GLfloat iPlane[4]; |
| 69 |
#endif |
| 70 |
#ifdef DO_SPEC |
| 71 |
GLfloat srPlane[4], sgPlane[4], sbPlane[4]; |
| 72 |
#endif |
| 73 |
#ifdef DO_TEX |
| 74 |
GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4]; |
| 75 |
GLfloat texWidth, texHeight; |
| 76 |
#elif defined(DO_MULTITEX) |
| 77 |
GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture S */ |
| 78 |
GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture T */ |
| 79 |
GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture R */ |
| 80 |
GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture Q */ |
| 81 |
GLfloat texWidth[MAX_TEXTURE_COORD_UNITS]; |
| 82 |
GLfloat texHeight[MAX_TEXTURE_COORD_UNITS]; |
| 83 |
#endif |
| 84 |
GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign; |
| 85 |
|
| 86 |
|
| 87 |
INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE); |
| 88 |
|
| 89 |
/* determine bottom to top order of vertices */ |
| 90 |
{ |
| 91 |
GLfloat y0 = v0->win[1]; |
| 92 |
GLfloat y1 = v1->win[1]; |
| 93 |
GLfloat y2 = v2->win[1]; |
| 94 |
if (y0 <= y1) { |
| 95 |
if (y1 <= y2) { |
| 96 |
vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */ |
| 97 |
} |
| 98 |
else if (y2 <= y0) { |
| 99 |
vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */ |
| 100 |
} |
| 101 |
else { |
| 102 |
vMin = v0; vMid = v2; vMax = v1; bf = -bf; /* y0<=y2<=y1 */ |
| 103 |
} |
| 104 |
} |
| 105 |
else { |
| 106 |
if (y0 <= y2) { |
| 107 |
vMin = v1; vMid = v0; vMax = v2; bf = -bf; /* y1<=y0<=y2 */ |
| 108 |
} |
| 109 |
else if (y2 <= y1) { |
| 110 |
vMin = v2; vMid = v1; vMax = v0; bf = -bf; /* y2<=y1<=y0 */ |
| 111 |
} |
| 112 |
else { |
| 113 |
vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */ |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
majDx = vMax->win[0] - vMin->win[0]; |
| 119 |
majDy = vMax->win[1] - vMin->win[1]; |
| 120 |
|
| 121 |
{ |
| 122 |
const GLfloat botDx = vMid->win[0] - vMin->win[0]; |
| 123 |
const GLfloat botDy = vMid->win[1] - vMin->win[1]; |
| 124 |
const GLfloat area = majDx * botDy - botDx * majDy; |
| 125 |
/* Do backface culling */ |
| 126 |
if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area)) |
| 127 |
return; |
| 128 |
ltor = (GLboolean) (area < 0.0F); |
| 129 |
} |
| 130 |
|
| 131 |
#ifndef DO_OCCLUSION_TEST |
| 132 |
ctx->OcclusionResult = GL_TRUE; |
| 133 |
#endif |
| 134 |
|
| 135 |
/* Plane equation setup: |
| 136 |
* We evaluate plane equations at window (x,y) coordinates in order |
| 137 |
* to compute color, Z, fog, texcoords, etc. This isn't terribly |
| 138 |
* efficient but it's easy and reliable. |
| 139 |
*/ |
| 140 |
#ifdef DO_Z |
| 141 |
compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); |
| 142 |
span.arrayMask |= SPAN_Z; |
| 143 |
#endif |
| 144 |
#ifdef DO_FOG |
| 145 |
compute_plane(p0, p1, p2, v0->fog, v1->fog, v2->fog, fogPlane); |
| 146 |
span.arrayMask |= SPAN_FOG; |
| 147 |
#endif |
| 148 |
#ifdef DO_RGBA |
| 149 |
if (ctx->Light.ShadeModel == GL_SMOOTH) { |
| 150 |
compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane); |
| 151 |
compute_plane(p0, p1, p2, v0->color[GCOMP], v1->color[GCOMP], v2->color[GCOMP], gPlane); |
| 152 |
compute_plane(p0, p1, p2, v0->color[BCOMP], v1->color[BCOMP], v2->color[BCOMP], bPlane); |
| 153 |
compute_plane(p0, p1, p2, v0->color[ACOMP], v1->color[ACOMP], v2->color[ACOMP], aPlane); |
| 154 |
} |
| 155 |
else { |
| 156 |
constant_plane(v2->color[RCOMP], rPlane); |
| 157 |
constant_plane(v2->color[GCOMP], gPlane); |
| 158 |
constant_plane(v2->color[BCOMP], bPlane); |
| 159 |
constant_plane(v2->color[ACOMP], aPlane); |
| 160 |
} |
| 161 |
span.arrayMask |= SPAN_RGBA; |
| 162 |
#endif |
| 163 |
#ifdef DO_INDEX |
| 164 |
if (ctx->Light.ShadeModel == GL_SMOOTH) { |
| 165 |
compute_plane(p0, p1, p2, (GLfloat) v0->index, |
| 166 |
v1->index, v2->index, iPlane); |
| 167 |
} |
| 168 |
else { |
| 169 |
constant_plane(v2->index, iPlane); |
| 170 |
} |
| 171 |
span.arrayMask |= SPAN_INDEX; |
| 172 |
#endif |
| 173 |
#ifdef DO_SPEC |
| 174 |
if (ctx->Light.ShadeModel == GL_SMOOTH) { |
| 175 |
compute_plane(p0, p1, p2, v0->specular[RCOMP], v1->specular[RCOMP], v2->specular[RCOMP], srPlane); |
| 176 |
compute_plane(p0, p1, p2, v0->specular[GCOMP], v1->specular[GCOMP], v2->specular[GCOMP], sgPlane); |
| 177 |
compute_plane(p0, p1, p2, v0->specular[BCOMP], v1->specular[BCOMP], v2->specular[BCOMP], sbPlane); |
| 178 |
} |
| 179 |
else { |
| 180 |
constant_plane(v2->specular[RCOMP], srPlane); |
| 181 |
constant_plane(v2->specular[GCOMP], sgPlane); |
| 182 |
constant_plane(v2->specular[BCOMP], sbPlane); |
| 183 |
} |
| 184 |
span.arrayMask |= SPAN_SPEC; |
| 185 |
#endif |
| 186 |
#ifdef DO_TEX |
| 187 |
{ |
| 188 |
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; |
| 189 |
const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; |
| 190 |
const GLfloat invW0 = v0->win[3]; |
| 191 |
const GLfloat invW1 = v1->win[3]; |
| 192 |
const GLfloat invW2 = v2->win[3]; |
| 193 |
const GLfloat s0 = v0->texcoord[0][0] * invW0; |
| 194 |
const GLfloat s1 = v1->texcoord[0][0] * invW1; |
| 195 |
const GLfloat s2 = v2->texcoord[0][0] * invW2; |
| 196 |
const GLfloat t0 = v0->texcoord[0][1] * invW0; |
| 197 |
const GLfloat t1 = v1->texcoord[0][1] * invW1; |
| 198 |
const GLfloat t2 = v2->texcoord[0][1] * invW2; |
| 199 |
const GLfloat r0 = v0->texcoord[0][2] * invW0; |
| 200 |
const GLfloat r1 = v1->texcoord[0][2] * invW1; |
| 201 |
const GLfloat r2 = v2->texcoord[0][2] * invW2; |
| 202 |
const GLfloat q0 = v0->texcoord[0][3] * invW0; |
| 203 |
const GLfloat q1 = v1->texcoord[0][3] * invW1; |
| 204 |
const GLfloat q2 = v2->texcoord[0][3] * invW2; |
| 205 |
compute_plane(p0, p1, p2, s0, s1, s2, sPlane); |
| 206 |
compute_plane(p0, p1, p2, t0, t1, t2, tPlane); |
| 207 |
compute_plane(p0, p1, p2, r0, r1, r2, uPlane); |
| 208 |
compute_plane(p0, p1, p2, q0, q1, q2, vPlane); |
| 209 |
texWidth = (GLfloat) texImage->Width; |
| 210 |
texHeight = (GLfloat) texImage->Height; |
| 211 |
} |
| 212 |
span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); |
| 213 |
#elif defined(DO_MULTITEX) |
| 214 |
{ |
| 215 |
GLuint u; |
| 216 |
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
| 217 |
if (ctx->Texture.Unit[u]._ReallyEnabled) { |
| 218 |
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; |
| 219 |
const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; |
| 220 |
const GLfloat invW0 = v0->win[3]; |
| 221 |
const GLfloat invW1 = v1->win[3]; |
| 222 |
const GLfloat invW2 = v2->win[3]; |
| 223 |
const GLfloat s0 = v0->texcoord[u][0] * invW0; |
| 224 |
const GLfloat s1 = v1->texcoord[u][0] * invW1; |
| 225 |
const GLfloat s2 = v2->texcoord[u][0] * invW2; |
| 226 |
const GLfloat t0 = v0->texcoord[u][1] * invW0; |
| 227 |
const GLfloat t1 = v1->texcoord[u][1] * invW1; |
| 228 |
const GLfloat t2 = v2->texcoord[u][1] * invW2; |
| 229 |
const GLfloat r0 = v0->texcoord[u][2] * invW0; |
| 230 |
const GLfloat r1 = v1->texcoord[u][2] * invW1; |
| 231 |
const GLfloat r2 = v2->texcoord[u][2] * invW2; |
| 232 |
const GLfloat q0 = v0->texcoord[u][3] * invW0; |
| 233 |
const GLfloat q1 = v1->texcoord[u][3] * invW1; |
| 234 |
const GLfloat q2 = v2->texcoord[u][3] * invW2; |
| 235 |
compute_plane(p0, p1, p2, s0, s1, s2, sPlane[u]); |
| 236 |
compute_plane(p0, p1, p2, t0, t1, t2, tPlane[u]); |
| 237 |
compute_plane(p0, p1, p2, r0, r1, r2, uPlane[u]); |
| 238 |
compute_plane(p0, p1, p2, q0, q1, q2, vPlane[u]); |
| 239 |
texWidth[u] = (GLfloat) texImage->Width; |
| 240 |
texHeight[u] = (GLfloat) texImage->Height; |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); |
| 245 |
#endif |
| 246 |
|
| 247 |
/* Begin bottom-to-top scan over the triangle. |
| 248 |
* The long edge will either be on the left or right side of the |
| 249 |
* triangle. We always scan from the long edge toward the shorter |
| 250 |
* edges, stopping when we find that coverage = 0. If the long edge |
| 251 |
* is on the left we scan left-to-right. Else, we scan right-to-left. |
| 252 |
*/ |
| 253 |
yMin = vMin->win[1]; |
| 254 |
yMax = vMax->win[1]; |
| 255 |
iyMin = (GLint) yMin; |
| 256 |
iyMax = (GLint) yMax + 1; |
| 257 |
|
| 258 |
if (ltor) { |
| 259 |
/* scan left to right */ |
| 260 |
const GLfloat *pMin = vMin->win; |
| 261 |
const GLfloat *pMid = vMid->win; |
| 262 |
const GLfloat *pMax = vMax->win; |
| 263 |
const GLfloat dxdy = majDx / majDy; |
| 264 |
const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F; |
| 265 |
GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; |
| 266 |
GLint iy; |
| 267 |
for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { |
| 268 |
GLint ix, startX = (GLint) (x - xAdj); |
| 269 |
GLuint count; |
| 270 |
GLfloat coverage = 0.0F; |
| 271 |
|
| 272 |
/* skip over fragments with zero coverage */ |
| 273 |
while (startX < MAX_WIDTH) { |
| 274 |
coverage = compute_coveragef(pMin, pMid, pMax, startX, iy); |
| 275 |
if (coverage > 0.0F) |
| 276 |
break; |
| 277 |
startX++; |
| 278 |
} |
| 279 |
|
| 280 |
/* enter interior of triangle */ |
| 281 |
ix = startX; |
| 282 |
count = 0; |
| 283 |
while (coverage > 0.0F) { |
| 284 |
/* (cx,cy) = center of fragment */ |
| 285 |
const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; |
| 286 |
struct span_arrays *array = span.array; |
| 287 |
#ifdef DO_INDEX |
| 288 |
array->coverage[count] = (GLfloat) compute_coveragei(pMin, pMid, pMax, ix, iy); |
| 289 |
#else |
| 290 |
array->coverage[count] = coverage; |
| 291 |
#endif |
| 292 |
#ifdef DO_Z |
| 293 |
array->z[count] = (GLdepth) IROUND(solve_plane(cx, cy, zPlane)); |
| 294 |
#endif |
| 295 |
#ifdef DO_FOG |
| 296 |
array->fog[count] = solve_plane(cx, cy, fogPlane); |
| 297 |
#endif |
| 298 |
#ifdef DO_RGBA |
| 299 |
array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane); |
| 300 |
array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane); |
| 301 |
array->rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane); |
| 302 |
array->rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane); |
| 303 |
#endif |
| 304 |
#ifdef DO_INDEX |
| 305 |
array->index[count] = (GLint) solve_plane(cx, cy, iPlane); |
| 306 |
#endif |
| 307 |
#ifdef DO_SPEC |
| 308 |
array->spec[count][RCOMP] = solve_plane_chan(cx, cy, srPlane); |
| 309 |
array->spec[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane); |
| 310 |
array->spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane); |
| 311 |
#endif |
| 312 |
#ifdef DO_TEX |
| 313 |
{ |
| 314 |
const GLfloat invQ = solve_plane_recip(cx, cy, vPlane); |
| 315 |
array->texcoords[0][count][0] = solve_plane(cx, cy, sPlane) * invQ; |
| 316 |
array->texcoords[0][count][1] = solve_plane(cx, cy, tPlane) * invQ; |
| 317 |
array->texcoords[0][count][2] = solve_plane(cx, cy, uPlane) * invQ; |
| 318 |
array->lambda[0][count] = compute_lambda(sPlane, tPlane, vPlane, |
| 319 |
cx, cy, invQ, |
| 320 |
texWidth, texHeight); |
| 321 |
} |
| 322 |
#elif defined(DO_MULTITEX) |
| 323 |
{ |
| 324 |
GLuint unit; |
| 325 |
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { |
| 326 |
if (ctx->Texture.Unit[unit]._ReallyEnabled) { |
| 327 |
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); |
| 328 |
array->texcoords[unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ; |
| 329 |
array->texcoords[unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ; |
| 330 |
array->texcoords[unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ; |
| 331 |
array->lambda[unit][count] = compute_lambda(sPlane[unit], |
| 332 |
tPlane[unit], vPlane[unit], cx, cy, invQ, |
| 333 |
texWidth[unit], texHeight[unit]); |
| 334 |
} |
| 335 |
} |
| 336 |
} |
| 337 |
#endif |
| 338 |
ix++; |
| 339 |
count++; |
| 340 |
coverage = compute_coveragef(pMin, pMid, pMax, ix, iy); |
| 341 |
} |
| 342 |
|
| 343 |
if (ix <= startX) |
| 344 |
continue; |
| 345 |
|
| 346 |
span.x = startX; |
| 347 |
span.y = iy; |
| 348 |
span.end = (GLuint) ix - (GLuint) startX; |
| 349 |
ASSERT(span.interpMask == 0); |
| 350 |
#if defined(DO_RGBA) |
| 351 |
_swrast_write_rgba_span(ctx, &span); |
| 352 |
#else |
| 353 |
_swrast_write_index_span(ctx, &span); |
| 354 |
#endif |
| 355 |
} |
| 356 |
} |
| 357 |
else { |
| 358 |
/* scan right to left */ |
| 359 |
const GLfloat *pMin = vMin->win; |
| 360 |
const GLfloat *pMid = vMid->win; |
| 361 |
const GLfloat *pMax = vMax->win; |
| 362 |
const GLfloat dxdy = majDx / majDy; |
| 363 |
const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F; |
| 364 |
GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; |
| 365 |
GLint iy; |
| 366 |
for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { |
| 367 |
GLint ix, left, startX = (GLint) (x + xAdj); |
| 368 |
GLuint count, n; |
| 369 |
GLfloat coverage = 0.0F; |
| 370 |
|
| 371 |
/* make sure we're not past the window edge */ |
| 372 |
if (startX >= ctx->DrawBuffer->_Xmax) { |
| 373 |
startX = ctx->DrawBuffer->_Xmax - 1; |
| 374 |
} |
| 375 |
|
| 376 |
/* skip fragments with zero coverage */ |
| 377 |
while (startX >= 0) { |
| 378 |
coverage = compute_coveragef(pMin, pMax, pMid, startX, iy); |
| 379 |
if (coverage > 0.0F) |
| 380 |
break; |
| 381 |
startX--; |
| 382 |
} |
| 383 |
|
| 384 |
/* enter interior of triangle */ |
| 385 |
ix = startX; |
| 386 |
count = 0; |
| 387 |
while (coverage > 0.0F) { |
| 388 |
/* (cx,cy) = center of fragment */ |
| 389 |
const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; |
| 390 |
struct span_arrays *array = span.array; |
| 391 |
#ifdef DO_INDEX |
| 392 |
array->coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy); |
| 393 |
#else |
| 394 |
array->coverage[ix] = coverage; |
| 395 |
#endif |
| 396 |
#ifdef DO_Z |
| 397 |
array->z[ix] = (GLdepth) IROUND(solve_plane(cx, cy, zPlane)); |
| 398 |
#endif |
| 399 |
#ifdef DO_FOG |
| 400 |
array->fog[ix] = solve_plane(cx, cy, fogPlane); |
| 401 |
#endif |
| 402 |
#ifdef DO_RGBA |
| 403 |
array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane); |
| 404 |
array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane); |
| 405 |
array->rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane); |
| 406 |
array->rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane); |
| 407 |
#endif |
| 408 |
#ifdef DO_INDEX |
| 409 |
array->index[ix] = (GLint) solve_plane(cx, cy, iPlane); |
| 410 |
#endif |
| 411 |
#ifdef DO_SPEC |
| 412 |
array->spec[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane); |
| 413 |
array->spec[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane); |
| 414 |
array->spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane); |
| 415 |
#endif |
| 416 |
#ifdef DO_TEX |
| 417 |
{ |
| 418 |
const GLfloat invQ = solve_plane_recip(cx, cy, vPlane); |
| 419 |
array->texcoords[0][ix][0] = solve_plane(cx, cy, sPlane) * invQ; |
| 420 |
array->texcoords[0][ix][1] = solve_plane(cx, cy, tPlane) * invQ; |
| 421 |
array->texcoords[0][ix][2] = solve_plane(cx, cy, uPlane) * invQ; |
| 422 |
array->lambda[0][ix] = compute_lambda(sPlane, tPlane, vPlane, |
| 423 |
cx, cy, invQ, texWidth, texHeight); |
| 424 |
} |
| 425 |
#elif defined(DO_MULTITEX) |
| 426 |
{ |
| 427 |
GLuint unit; |
| 428 |
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { |
| 429 |
if (ctx->Texture.Unit[unit]._ReallyEnabled) { |
| 430 |
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); |
| 431 |
array->texcoords[unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ; |
| 432 |
array->texcoords[unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ; |
| 433 |
array->texcoords[unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ; |
| 434 |
array->lambda[unit][ix] = compute_lambda(sPlane[unit], |
| 435 |
tPlane[unit], |
| 436 |
vPlane[unit], |
| 437 |
cx, cy, invQ, |
| 438 |
texWidth[unit], |
| 439 |
texHeight[unit]); |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
#endif |
| 444 |
ix--; |
| 445 |
count++; |
| 446 |
coverage = compute_coveragef(pMin, pMax, pMid, ix, iy); |
| 447 |
} |
| 448 |
|
| 449 |
if (startX <= ix) |
| 450 |
continue; |
| 451 |
|
| 452 |
n = (GLuint) startX - (GLuint) ix; |
| 453 |
|
| 454 |
left = ix + 1; |
| 455 |
|
| 456 |
/* shift all values to the left */ |
| 457 |
/* XXX this is temporary */ |
| 458 |
{ |
| 459 |
struct span_arrays *array = span.array; |
| 460 |
GLint j; |
| 461 |
for (j = 0; j < (GLint) n; j++) { |
| 462 |
#ifdef DO_RGBA |
| 463 |
COPY_CHAN4(array->rgba[j], array->rgba[j + left]); |
| 464 |
#endif |
| 465 |
#ifdef DO_SPEC |
| 466 |
COPY_CHAN4(array->spec[j], array->spec[j + left]); |
| 467 |
#endif |
| 468 |
#ifdef DO_INDEX |
| 469 |
array->index[j] = array->index[j + left]; |
| 470 |
#endif |
| 471 |
#ifdef DO_Z |
| 472 |
array->z[j] = array->z[j + left]; |
| 473 |
#endif |
| 474 |
#ifdef DO_FOG |
| 475 |
array->fog[j] = array->fog[j + left]; |
| 476 |
#endif |
| 477 |
#ifdef DO_TEX |
| 478 |
COPY_4V(array->texcoords[0][j], array->texcoords[0][j + left]); |
| 479 |
#endif |
| 480 |
#if defined(DO_MULTITEX) || defined(DO_TEX) |
| 481 |
array->lambda[0][j] = array->lambda[0][j + left]; |
| 482 |
#endif |
| 483 |
array->coverage[j] = array->coverage[j + left]; |
| 484 |
} |
| 485 |
} |
| 486 |
#ifdef DO_MULTITEX |
| 487 |
/* shift texcoords */ |
| 488 |
{ |
| 489 |
struct span_arrays *array = span.array; |
| 490 |
GLuint unit; |
| 491 |
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { |
| 492 |
if (ctx->Texture.Unit[unit]._ReallyEnabled) { |
| 493 |
GLint j; |
| 494 |
for (j = 0; j < (GLint) n; j++) { |
| 495 |
array->texcoords[unit][j][0] = array->texcoords[unit][j + left][0]; |
| 496 |
array->texcoords[unit][j][1] = array->texcoords[unit][j + left][1]; |
| 497 |
array->texcoords[unit][j][2] = array->texcoords[unit][j + left][2]; |
| 498 |
array->lambda[unit][j] = array->lambda[unit][j + left]; |
| 499 |
} |
| 500 |
} |
| 501 |
} |
| 502 |
} |
| 503 |
#endif |
| 504 |
|
| 505 |
span.x = left; |
| 506 |
span.y = iy; |
| 507 |
span.end = n; |
| 508 |
ASSERT(span.interpMask == 0); |
| 509 |
#if defined(DO_RGBA) |
| 510 |
_swrast_write_rgba_span(ctx, &span); |
| 511 |
#else |
| 512 |
_swrast_write_index_span(ctx, &span); |
| 513 |
#endif |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
#ifdef DO_Z |
| 520 |
#undef DO_Z |
| 521 |
#endif |
| 522 |
|
| 523 |
#ifdef DO_FOG |
| 524 |
#undef DO_FOG |
| 525 |
#endif |
| 526 |
|
| 527 |
#ifdef DO_RGBA |
| 528 |
#undef DO_RGBA |
| 529 |
#endif |
| 530 |
|
| 531 |
#ifdef DO_INDEX |
| 532 |
#undef DO_INDEX |
| 533 |
#endif |
| 534 |
|
| 535 |
#ifdef DO_SPEC |
| 536 |
#undef DO_SPEC |
| 537 |
#endif |
| 538 |
|
| 539 |
#ifdef DO_TEX |
| 540 |
#undef DO_TEX |
| 541 |
#endif |
| 542 |
|
| 543 |
#ifdef DO_MULTITEX |
| 544 |
#undef DO_MULTITEX |
| 545 |
#endif |
| 546 |
|
| 547 |
#ifdef DO_OCCLUSION_TEST |
| 548 |
#undef DO_OCCLUSION_TEST |
| 549 |
#endif |