Cleanup of derived state calculation prior to seperating software T&L
[mesa.git] / src / mesa / swrast / s_tritemp.h
1 /* $Id: s_tritemp.h,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 /*
29 * Triangle Rasterizer Template
30 *
31 * This file is #include'd to generate custom triangle rasterizers.
32 *
33 * The following macros may be defined to indicate what auxillary information
34 * must be interplated across the triangle:
35 * INTERP_Z - if defined, interpolate Z values
36 * INTERP_RGB - if defined, interpolate RGB values
37 * INTERP_SPEC - if defined, interpolate specular RGB values
38 * INTERP_ALPHA - if defined, interpolate Alpha values
39 * INTERP_INDEX - if defined, interpolate color index values
40 * INTERP_INT_TEX - if defined, interpolate integer ST texcoords
41 * (fast, simple 2-D texture mapping)
42 * INTERP_TEX - if defined, interpolate set 0 float STRQ texcoords
43 * NOTE: OpenGL STRQ = Mesa STUV (R was taken for red)
44 * INTERP_MULTITEX - if defined, interpolate N units of STRQ texcoords
45 *
46 * When one can directly address pixels in the color buffer the following
47 * macros can be defined and used to compute pixel addresses during
48 * rasterization (see pRow):
49 * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint)
50 * BYTES_PER_ROW - number of bytes per row in the color buffer
51 * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
52 * Y==0 at bottom of screen and increases upward.
53 *
54 * Similarly, for direct depth buffer access, this type is used for depth
55 * buffer addressing:
56 * DEPTH_TYPE - either GLushort or GLuint
57 *
58 * Optionally, one may provide one-time setup code per triangle:
59 * SETUP_CODE - code which is to be executed once per triangle
60 *
61 * The following macro MUST be defined:
62 * INNER_LOOP(LEFT,RIGHT,Y) - code to write a span of pixels.
63 * Something like:
64 *
65 * for (x=LEFT; x<RIGHT;x++) {
66 * put_pixel(x,Y);
67 * // increment fixed point interpolants
68 * }
69 *
70 * This code was designed for the origin to be in the lower-left corner.
71 *
72 * Inspired by triangle rasterizer code written by Allen Akin. Thanks Allen!
73 */
74
75
76 /*void triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 )*/
77 {
78 typedef struct {
79 SWvertex *v0, *v1; /* Y(v0) < Y(v1) */
80 GLfloat dx; /* X(v1) - X(v0) */
81 GLfloat dy; /* Y(v1) - Y(v0) */
82 GLfixed fdxdy; /* dx/dy in fixed-point */
83 GLfixed fsx; /* first sample point x coord */
84 GLfixed fsy;
85 GLfloat adjy; /* adjust from v[0]->fy to fsy, scaled */
86 GLint lines; /* number of lines to be sampled on this edge */
87 GLfixed fx0; /* fixed pt X of lower endpoint */
88 } EdgeT;
89
90 #ifdef INTERP_Z
91 const GLint depthBits = ctx->Visual.DepthBits;
92 const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
93 const GLfloat maxDepth = ctx->Visual.DepthMaxF;
94 #define FixedToDepth(F) ((F) >> fixedToDepthShift)
95 #endif
96 EdgeT eMaj, eTop, eBot;
97 GLfloat oneOverArea;
98 SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
99 float bf = SWRAST_CONTEXT(ctx)->_backface_sign;
100
101 /* find the order of the 3 vertices along the Y axis */
102 {
103 GLfloat y0 = v0->win[1];
104 GLfloat y1 = v1->win[1];
105 GLfloat y2 = v2->win[1];
106
107 if (y0<=y1) {
108 if (y1<=y2) {
109 vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */
110 }
111 else if (y2<=y0) {
112 vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */
113 }
114 else {
115 vMin = v0; vMid = v2; vMax = v1; bf = -bf; /* y0<=y2<=y1 */
116 }
117 }
118 else {
119 if (y0<=y2) {
120 vMin = v1; vMid = v0; vMax = v2; bf = -bf; /* y1<=y0<=y2 */
121 }
122 else if (y2<=y1) {
123 vMin = v2; vMid = v1; vMax = v0; bf = -bf; /* y2<=y1<=y0 */
124 }
125 else {
126 vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */
127 }
128 }
129 }
130
131 /* vertex/edge relationship */
132 eMaj.v0 = vMin; eMaj.v1 = vMax; /*TODO: .v1's not needed */
133 eTop.v0 = vMid; eTop.v1 = vMax;
134 eBot.v0 = vMin; eBot.v1 = vMid;
135
136 /* compute deltas for each edge: vertex[v1] - vertex[v0] */
137 eMaj.dx = vMax->win[0] - vMin->win[0];
138 eMaj.dy = vMax->win[1] - vMin->win[1];
139 eTop.dx = vMax->win[0] - vMid->win[0];
140 eTop.dy = vMax->win[1] - vMid->win[1];
141 eBot.dx = vMid->win[0] - vMin->win[0];
142 eBot.dy = vMid->win[1] - vMin->win[1];
143
144 /* compute oneOverArea */
145 {
146 const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
147
148 /* Do backface culling */
149 if (area * bf < 0.0)
150 return;
151
152 if (area == 0.0F)
153 return;
154
155 /* check for very tiny triangle */
156 if (area * area < 0.0025F) /* square it to ensure positive value */
157 oneOverArea = 1.0F / 0.0025F; /* a close-enough value */
158 else
159 oneOverArea = 1.0F / area;
160 }
161
162 #ifndef DO_OCCLUSION_TEST
163 ctx->OcclusionResult = GL_TRUE;
164 #endif
165
166 /* Edge setup. For a triangle strip these could be reused... */
167 {
168 /* fixed point Y coordinates */
169 GLfixed vMin_fx = FloatToFixed(vMin->win[0] + 0.5F);
170 GLfixed vMin_fy = FloatToFixed(vMin->win[1] - 0.5F);
171 GLfixed vMid_fx = FloatToFixed(vMid->win[0] + 0.5F);
172 GLfixed vMid_fy = FloatToFixed(vMid->win[1] - 0.5F);
173 GLfixed vMax_fy = FloatToFixed(vMax->win[1] - 0.5F);
174
175 eMaj.fsy = FixedCeil(vMin_fy);
176 eMaj.lines = FixedToInt(vMax_fy + FIXED_ONE - FIXED_EPSILON - eMaj.fsy);
177 if (eMaj.lines > 0) {
178 GLfloat dxdy = eMaj.dx / eMaj.dy;
179 eMaj.fdxdy = SignedFloatToFixed(dxdy);
180 eMaj.adjy = (GLfloat) (eMaj.fsy - vMin_fy); /* SCALED! */
181 eMaj.fx0 = vMin_fx;
182 eMaj.fsx = eMaj.fx0 + (GLfixed) (eMaj.adjy * dxdy);
183 }
184 else {
185 return; /*CULLED*/
186 }
187
188 eTop.fsy = FixedCeil(vMid_fy);
189 eTop.lines = FixedToInt(vMax_fy + FIXED_ONE - FIXED_EPSILON - eTop.fsy);
190 if (eTop.lines > 0) {
191 GLfloat dxdy = eTop.dx / eTop.dy;
192 eTop.fdxdy = SignedFloatToFixed(dxdy);
193 eTop.adjy = (GLfloat) (eTop.fsy - vMid_fy); /* SCALED! */
194 eTop.fx0 = vMid_fx;
195 eTop.fsx = eTop.fx0 + (GLfixed) (eTop.adjy * dxdy);
196 }
197
198 eBot.fsy = FixedCeil(vMin_fy);
199 eBot.lines = FixedToInt(vMid_fy + FIXED_ONE - FIXED_EPSILON - eBot.fsy);
200 if (eBot.lines > 0) {
201 GLfloat dxdy = eBot.dx / eBot.dy;
202 eBot.fdxdy = SignedFloatToFixed(dxdy);
203 eBot.adjy = (GLfloat) (eBot.fsy - vMin_fy); /* SCALED! */
204 eBot.fx0 = vMin_fx;
205 eBot.fsx = eBot.fx0 + (GLfixed) (eBot.adjy * dxdy);
206 }
207 }
208
209 /*
210 * Conceptually, we view a triangle as two subtriangles
211 * separated by a perfectly horizontal line. The edge that is
212 * intersected by this line is one with maximal absolute dy; we
213 * call it a ``major'' edge. The other two edges are the
214 * ``top'' edge (for the upper subtriangle) and the ``bottom''
215 * edge (for the lower subtriangle). If either of these two
216 * edges is horizontal or very close to horizontal, the
217 * corresponding subtriangle might cover zero sample points;
218 * we take care to handle such cases, for performance as well
219 * as correctness.
220 *
221 * By stepping rasterization parameters along the major edge,
222 * we can avoid recomputing them at the discontinuity where
223 * the top and bottom edges meet. However, this forces us to
224 * be able to scan both left-to-right and right-to-left.
225 * Also, we must determine whether the major edge is at the
226 * left or right side of the triangle. We do this by
227 * computing the magnitude of the cross-product of the major
228 * and top edges. Since this magnitude depends on the sine of
229 * the angle between the two edges, its sign tells us whether
230 * we turn to the left or to the right when travelling along
231 * the major edge to the top edge, and from this we infer
232 * whether the major edge is on the left or the right.
233 *
234 * Serendipitously, this cross-product magnitude is also a
235 * value we need to compute the iteration parameter
236 * derivatives for the triangle, and it can be used to perform
237 * backface culling because its sign tells us whether the
238 * triangle is clockwise or counterclockwise. In this code we
239 * refer to it as ``area'' because it's also proportional to
240 * the pixel area of the triangle.
241 */
242
243 {
244 GLint ltor; /* true if scanning left-to-right */
245 #ifdef INTERP_Z
246 GLfloat dzdx, dzdy; GLfixed fdzdx;
247 GLfloat dfogdx, dfogdy; GLfixed fdfogdx;
248 #endif
249 #ifdef INTERP_RGB
250 GLfloat drdx, drdy; GLfixed fdrdx;
251 GLfloat dgdx, dgdy; GLfixed fdgdx;
252 GLfloat dbdx, dbdy; GLfixed fdbdx;
253 #endif
254 #ifdef INTERP_SPEC
255 GLfloat dsrdx, dsrdy; GLfixed fdsrdx;
256 GLfloat dsgdx, dsgdy; GLfixed fdsgdx;
257 GLfloat dsbdx, dsbdy; GLfixed fdsbdx;
258 #endif
259 #ifdef INTERP_ALPHA
260 GLfloat dadx, dady; GLfixed fdadx;
261 #endif
262 #ifdef INTERP_INDEX
263 GLfloat didx, didy; GLfixed fdidx;
264 #endif
265 #ifdef INTERP_INT_TEX
266 GLfloat dsdx, dsdy; GLfixed fdsdx;
267 GLfloat dtdx, dtdy; GLfixed fdtdx;
268 #endif
269 #ifdef INTERP_TEX
270 GLfloat dsdx, dsdy;
271 GLfloat dtdx, dtdy;
272 GLfloat dudx, dudy;
273 GLfloat dvdx, dvdy;
274 #endif
275 #ifdef INTERP_MULTITEX
276 GLfloat dsdx[MAX_TEXTURE_UNITS], dsdy[MAX_TEXTURE_UNITS];
277 GLfloat dtdx[MAX_TEXTURE_UNITS], dtdy[MAX_TEXTURE_UNITS];
278 GLfloat dudx[MAX_TEXTURE_UNITS], dudy[MAX_TEXTURE_UNITS];
279 GLfloat dvdx[MAX_TEXTURE_UNITS], dvdy[MAX_TEXTURE_UNITS];
280 #endif
281
282 /*
283 * Execute user-supplied setup code
284 */
285 #ifdef SETUP_CODE
286 SETUP_CODE
287 #endif
288
289 ltor = (oneOverArea < 0.0F);
290
291 /* compute d?/dx and d?/dy derivatives */
292 #ifdef INTERP_Z
293 {
294 GLfloat eMaj_dz, eBot_dz;
295 eMaj_dz = vMax->win[2] - vMin->win[2];
296 eBot_dz = vMid->win[2] - vMin->win[2];
297 dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
298 if (dzdx > maxDepth || dzdx < -maxDepth) {
299 /* probably a sliver triangle */
300 dzdx = 0.0;
301 dzdy = 0.0;
302 }
303 else {
304 dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx);
305 }
306 if (depthBits <= 16)
307 fdzdx = SignedFloatToFixed(dzdx);
308 else
309 fdzdx = (GLint) dzdx;
310 }
311 {
312 GLfloat eMaj_dfog, eBot_dfog;
313 eMaj_dfog = (vMax->fog - vMin->fog) * 256;
314 eBot_dfog = (vMid->fog - vMin->fog) * 256;
315 dfogdx = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog);
316 fdfogdx = SignedFloatToFixed(dfogdx);
317 dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx);
318 }
319 #endif
320 #ifdef INTERP_RGB
321 {
322 GLfloat eMaj_dr, eBot_dr;
323 eMaj_dr = (GLint) vMax->color[0]
324 - (GLint) vMin->color[0];
325 eBot_dr = (GLint) vMid->color[0]
326 - (GLint) vMin->color[0];
327 drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
328 fdrdx = SignedFloatToFixed(drdx);
329 drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
330 }
331 {
332 GLfloat eMaj_dg, eBot_dg;
333 eMaj_dg = (GLint) vMax->color[1]
334 - (GLint) vMin->color[1];
335 eBot_dg = (GLint) vMid->color[1]
336 - (GLint) vMin->color[1];
337 dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
338 fdgdx = SignedFloatToFixed(dgdx);
339 dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
340 }
341 {
342 GLfloat eMaj_db, eBot_db;
343 eMaj_db = (GLint) vMax->color[2]
344 - (GLint) vMin->color[2];
345 eBot_db = (GLint) vMid->color[2]
346 - (GLint) vMin->color[2];
347 dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
348 fdbdx = SignedFloatToFixed(dbdx);
349 dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
350 }
351 #endif
352 #ifdef INTERP_SPEC
353 {
354 GLfloat eMaj_dsr, eBot_dsr;
355 eMaj_dsr = (GLint) vMax->specular[0]
356 - (GLint) vMin->specular[0];
357 eBot_dsr = (GLint) vMid->specular[0]
358 - (GLint) vMin->specular[0];
359 dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
360 fdsrdx = SignedFloatToFixed(dsrdx);
361 dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
362 }
363 {
364 GLfloat eMaj_dsg, eBot_dsg;
365 eMaj_dsg = (GLint) vMax->specular[1]
366 - (GLint) vMin->specular[1];
367 eBot_dsg = (GLint) vMid->specular[1]
368 - (GLint) vMin->specular[1];
369 dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
370 fdsgdx = SignedFloatToFixed(dsgdx);
371 dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
372 }
373 {
374 GLfloat eMaj_dsb, eBot_dsb;
375 eMaj_dsb = (GLint) vMax->specular[2]
376 - (GLint) vMin->specular[2];
377 eBot_dsb = (GLint) vMid->specular[2]
378 - (GLint) vMin->specular[2];
379 dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
380 fdsbdx = SignedFloatToFixed(dsbdx);
381 dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
382 }
383 #endif
384 #ifdef INTERP_ALPHA
385 {
386 GLfloat eMaj_da, eBot_da;
387 eMaj_da = (GLint) vMax->color[3]
388 - (GLint) vMin->color[3];
389 eBot_da = (GLint) vMid->color[3]
390 - (GLint) vMin->color[3];
391 dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
392 fdadx = SignedFloatToFixed(dadx);
393 dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
394 }
395 #endif
396 #ifdef INTERP_INDEX
397 {
398 GLfloat eMaj_di, eBot_di;
399 eMaj_di = (GLint) vMax->index
400 - (GLint) vMin->index;
401 eBot_di = (GLint) vMid->index
402 - (GLint) vMin->index;
403 didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di);
404 fdidx = SignedFloatToFixed(didx);
405 didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
406 }
407 #endif
408 #ifdef INTERP_INT_TEX
409 {
410 GLfloat eMaj_ds, eBot_ds;
411 eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
412 eBot_ds = (vMid->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
413 dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
414 fdsdx = SignedFloatToFixed(dsdx);
415 dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
416 }
417 {
418 GLfloat eMaj_dt, eBot_dt;
419 eMaj_dt = (vMax->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
420 eBot_dt = (vMid->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
421 dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
422 fdtdx = SignedFloatToFixed(dtdx);
423 dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
424 }
425
426 #endif
427 #ifdef INTERP_TEX
428 {
429 GLfloat wMax = vMax->win[3];
430 GLfloat wMin = vMin->win[3];
431 GLfloat wMid = vMid->win[3];
432 GLfloat eMaj_ds, eBot_ds;
433 GLfloat eMaj_dt, eBot_dt;
434 GLfloat eMaj_du, eBot_du;
435 GLfloat eMaj_dv, eBot_dv;
436
437 eMaj_ds = vMax->texcoord[0][0] * wMax - vMin->texcoord[0][0] * wMin;
438 eBot_ds = vMid->texcoord[0][0] * wMid - vMin->texcoord[0][0] * wMin;
439 dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
440 dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
441
442
443 eMaj_dt = vMax->texcoord[0][1] * wMax - vMin->texcoord[0][1] * wMin;
444 eBot_dt = vMid->texcoord[0][1] * wMid - vMin->texcoord[0][1] * wMin;
445 dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
446 dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
447
448 eMaj_du = vMax->texcoord[0][2] * wMax - vMin->texcoord[0][2] * wMin;
449 eBot_du = vMid->texcoord[0][2] * wMid - vMin->texcoord[0][2] * wMin;
450 dudx = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
451 dudy = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
452
453
454 eMaj_dv = vMax->texcoord[0][3] * wMax - vMin->texcoord[0][3] * wMin;
455 eBot_dv = vMid->texcoord[0][3] * wMid - vMin->texcoord[0][3] * wMin;
456 dvdx = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
457 dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
458 }
459 #endif
460 #ifdef INTERP_MULTITEX
461 {
462 GLfloat wMax = vMax->win[3];
463 GLfloat wMin = vMin->win[3];
464 GLfloat wMid = vMid->win[3];
465 GLuint u;
466 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
467 if (ctx->Texture.Unit[u]._ReallyEnabled) {
468 GLfloat eMaj_ds, eBot_ds;
469 GLfloat eMaj_dt, eBot_dt;
470 GLfloat eMaj_du, eBot_du;
471 GLfloat eMaj_dv, eBot_dv;
472 eMaj_ds = vMax->texcoord[u][0] * wMax
473 - vMin->texcoord[u][0] * wMin;
474 eBot_ds = vMid->texcoord[u][0] * wMid
475 - vMin->texcoord[u][0] * wMin;
476 dsdx[u] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
477 dsdy[u] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
478
479 eMaj_dt = vMax->texcoord[u][1] * wMax
480 - vMin->texcoord[u][1] * wMin;
481 eBot_dt = vMid->texcoord[u][1] * wMid
482 - vMin->texcoord[u][1] * wMin;
483 dtdx[u] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
484 dtdy[u] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
485
486 eMaj_du = vMax->texcoord[u][2] * wMax
487 - vMin->texcoord[u][2] * wMin;
488 eBot_du = vMid->texcoord[u][2] * wMid
489 - vMin->texcoord[u][2] * wMin;
490 dudx[u] = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
491 dudy[u] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
492
493 eMaj_dv = vMax->texcoord[u][3] * wMax
494 - vMin->texcoord[u][3] * wMin;
495 eBot_dv = vMid->texcoord[u][3] * wMid
496 - vMin->texcoord[u][3] * wMin;
497 dvdx[u] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
498 dvdy[u] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
499 }
500 }
501 }
502 #endif
503
504 /*
505 * We always sample at pixel centers. However, we avoid
506 * explicit half-pixel offsets in this code by incorporating
507 * the proper offset in each of x and y during the
508 * transformation to window coordinates.
509 *
510 * We also apply the usual rasterization rules to prevent
511 * cracks and overlaps. A pixel is considered inside a
512 * subtriangle if it meets all of four conditions: it is on or
513 * to the right of the left edge, strictly to the left of the
514 * right edge, on or below the top edge, and strictly above
515 * the bottom edge. (Some edges may be degenerate.)
516 *
517 * The following discussion assumes left-to-right scanning
518 * (that is, the major edge is on the left); the right-to-left
519 * case is a straightforward variation.
520 *
521 * We start by finding the half-integral y coordinate that is
522 * at or below the top of the triangle. This gives us the
523 * first scan line that could possibly contain pixels that are
524 * inside the triangle.
525 *
526 * Next we creep down the major edge until we reach that y,
527 * and compute the corresponding x coordinate on the edge.
528 * Then we find the half-integral x that lies on or just
529 * inside the edge. This is the first pixel that might lie in
530 * the interior of the triangle. (We won't know for sure
531 * until we check the other edges.)
532 *
533 * As we rasterize the triangle, we'll step down the major
534 * edge. For each step in y, we'll move an integer number
535 * of steps in x. There are two possible x step sizes, which
536 * we'll call the ``inner'' step (guaranteed to land on the
537 * edge or inside it) and the ``outer'' step (guaranteed to
538 * land on the edge or outside it). The inner and outer steps
539 * differ by one. During rasterization we maintain an error
540 * term that indicates our distance from the true edge, and
541 * select either the inner step or the outer step, whichever
542 * gets us to the first pixel that falls inside the triangle.
543 *
544 * All parameters (z, red, etc.) as well as the buffer
545 * addresses for color and z have inner and outer step values,
546 * so that we can increment them appropriately. This method
547 * eliminates the need to adjust parameters by creeping a
548 * sub-pixel amount into the triangle at each scanline.
549 */
550
551 {
552 int subTriangle;
553 GLfixed fx, fxLeftEdge, fxRightEdge, fdxLeftEdge, fdxRightEdge;
554 GLfixed fdxOuter;
555 int idxOuter;
556 float dxOuter;
557 GLfixed fError, fdError;
558 float adjx, adjy;
559 GLfixed fy;
560 int iy;
561 #ifdef PIXEL_ADDRESS
562 PIXEL_TYPE *pRow;
563 int dPRowOuter, dPRowInner; /* offset in bytes */
564 #endif
565 #ifdef INTERP_Z
566 # ifdef DEPTH_TYPE
567 DEPTH_TYPE *zRow;
568 int dZRowOuter, dZRowInner; /* offset in bytes */
569 # endif
570 GLfixed fz, fdzOuter, fdzInner;
571 GLfixed ffog, fdfogOuter, fdfogInner;
572 #endif
573 #ifdef INTERP_RGB
574 GLfixed fr, fdrOuter, fdrInner;
575 GLfixed fg, fdgOuter, fdgInner;
576 GLfixed fb, fdbOuter, fdbInner;
577 #endif
578 #ifdef INTERP_SPEC
579 GLfixed fsr, fdsrOuter, fdsrInner;
580 GLfixed fsg, fdsgOuter, fdsgInner;
581 GLfixed fsb, fdsbOuter, fdsbInner;
582 #endif
583 #ifdef INTERP_ALPHA
584 GLfixed fa, fdaOuter, fdaInner;
585 #endif
586 #ifdef INTERP_INDEX
587 GLfixed fi, fdiOuter, fdiInner;
588 #endif
589 #ifdef INTERP_INT_TEX
590 GLfixed fs, fdsOuter, fdsInner;
591 GLfixed ft, fdtOuter, fdtInner;
592 #endif
593 #ifdef INTERP_TEX
594 GLfloat sLeft, dsOuter, dsInner;
595 GLfloat tLeft, dtOuter, dtInner;
596 GLfloat uLeft, duOuter, duInner;
597 GLfloat vLeft, dvOuter, dvInner;
598 #endif
599 #ifdef INTERP_MULTITEX
600 GLfloat sLeft[MAX_TEXTURE_UNITS];
601 GLfloat tLeft[MAX_TEXTURE_UNITS];
602 GLfloat uLeft[MAX_TEXTURE_UNITS];
603 GLfloat vLeft[MAX_TEXTURE_UNITS];
604 GLfloat dsOuter[MAX_TEXTURE_UNITS], dsInner[MAX_TEXTURE_UNITS];
605 GLfloat dtOuter[MAX_TEXTURE_UNITS], dtInner[MAX_TEXTURE_UNITS];
606 GLfloat duOuter[MAX_TEXTURE_UNITS], duInner[MAX_TEXTURE_UNITS];
607 GLfloat dvOuter[MAX_TEXTURE_UNITS], dvInner[MAX_TEXTURE_UNITS];
608 #endif
609
610 for (subTriangle=0; subTriangle<=1; subTriangle++) {
611 EdgeT *eLeft, *eRight;
612 int setupLeft, setupRight;
613 int lines;
614
615 if (subTriangle==0) {
616 /* bottom half */
617 if (ltor) {
618 eLeft = &eMaj;
619 eRight = &eBot;
620 lines = eRight->lines;
621 setupLeft = 1;
622 setupRight = 1;
623 }
624 else {
625 eLeft = &eBot;
626 eRight = &eMaj;
627 lines = eLeft->lines;
628 setupLeft = 1;
629 setupRight = 1;
630 }
631 }
632 else {
633 /* top half */
634 if (ltor) {
635 eLeft = &eMaj;
636 eRight = &eTop;
637 lines = eRight->lines;
638 setupLeft = 0;
639 setupRight = 1;
640 }
641 else {
642 eLeft = &eTop;
643 eRight = &eMaj;
644 lines = eLeft->lines;
645 setupLeft = 1;
646 setupRight = 0;
647 }
648 if (lines == 0)
649 return;
650 }
651
652 if (setupLeft && eLeft->lines > 0) {
653 SWvertex *vLower;
654 GLfixed fsx = eLeft->fsx;
655 fx = FixedCeil(fsx);
656 fError = fx - fsx - FIXED_ONE;
657 fxLeftEdge = fsx - FIXED_EPSILON;
658 fdxLeftEdge = eLeft->fdxdy;
659 fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON);
660 fdError = fdxOuter - fdxLeftEdge + FIXED_ONE;
661 idxOuter = FixedToInt(fdxOuter);
662 dxOuter = (float) idxOuter;
663 (void) dxOuter;
664
665 fy = eLeft->fsy;
666 iy = FixedToInt(fy);
667
668 adjx = (float)(fx - eLeft->fx0); /* SCALED! */
669 adjy = eLeft->adjy; /* SCALED! */
670 (void) adjx; /* silence compiler warnings */
671 (void) adjy; /* silence compiler warnings */
672
673 vLower = eLeft->v0;
674 (void) vLower; /* silence compiler warnings */
675
676 #ifdef PIXEL_ADDRESS
677 {
678 pRow = PIXEL_ADDRESS( FixedToInt(fxLeftEdge), iy );
679 dPRowOuter = -((int)BYTES_PER_ROW) + idxOuter * sizeof(PIXEL_TYPE);
680 /* negative because Y=0 at bottom and increases upward */
681 }
682 #endif
683 /*
684 * Now we need the set of parameter (z, color, etc.) values at
685 * the point (fx, fy). This gives us properly-sampled parameter
686 * values that we can step from pixel to pixel. Furthermore,
687 * although we might have intermediate results that overflow
688 * the normal parameter range when we step temporarily outside
689 * the triangle, we shouldn't overflow or underflow for any
690 * pixel that's actually inside the triangle.
691 */
692
693 #ifdef INTERP_Z
694 {
695 GLfloat z0 = vLower->win[2];
696 if (depthBits <= 16) {
697 /* interpolate fixed-pt values */
698 GLfloat tmp = (z0 * FIXED_SCALE +
699 dzdx * adjx + dzdy * adjy) + FIXED_HALF;
700 if (tmp < MAX_GLUINT / 2)
701 fz = (GLfixed) tmp;
702 else
703 fz = MAX_GLUINT / 2;
704 fdzOuter = SignedFloatToFixed(dzdy + dxOuter * dzdx);
705 }
706 else {
707 /* interpolate depth values exactly */
708 fz = (GLint) (z0 + dzdx*FixedToFloat(adjx) + dzdy*FixedToFloat(adjy));
709 fdzOuter = (GLint) (dzdy + dxOuter * dzdx);
710 }
711 # ifdef DEPTH_TYPE
712 zRow = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, FixedToInt(fxLeftEdge), iy);
713 dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
714 # endif
715 }
716 {
717 ffog = FloatToFixed(vLower->fog) * 256 + dfogdx * adjx + dfogdy * adjy + FIXED_HALF;
718 fdfogOuter = SignedFloatToFixed(dfogdy + dxOuter * dfogdx);
719 }
720 #endif
721 #ifdef INTERP_RGB
722 fr = (GLfixed)(IntToFixed(vLower->color[0])
723 + drdx * adjx + drdy * adjy) + FIXED_HALF;
724 fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx);
725
726 fg = (GLfixed)(IntToFixed(vLower->color[1])
727 + dgdx * adjx + dgdy * adjy) + FIXED_HALF;
728 fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx);
729
730 fb = (GLfixed)(IntToFixed(vLower->color[2])
731 + dbdx * adjx + dbdy * adjy) + FIXED_HALF;
732 fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx);
733 #endif
734 #ifdef INTERP_SPEC
735 fsr = (GLfixed)(IntToFixed(vLower->specular[0])
736 + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
737 fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx);
738
739 fsg = (GLfixed)(IntToFixed(vLower->specular[1])
740 + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
741 fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx);
742
743 fsb = (GLfixed)(IntToFixed(vLower->specular[2])
744 + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
745 fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx);
746 #endif
747 #ifdef INTERP_ALPHA
748 fa = (GLfixed)(IntToFixed(vLower->color[3])
749 + dadx * adjx + dady * adjy) + FIXED_HALF;
750 fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx);
751 #endif
752 #ifdef INTERP_INDEX
753 fi = (GLfixed)(vLower->index * FIXED_SCALE
754 + didx * adjx + didy * adjy) + FIXED_HALF;
755 fdiOuter = SignedFloatToFixed(didy + dxOuter * didx);
756 #endif
757 #ifdef INTERP_INT_TEX
758 {
759 GLfloat s0, t0;
760 s0 = vLower->texcoord[0][0] * S_SCALE;
761 fs = (GLfixed)(s0 * FIXED_SCALE + dsdx * adjx + dsdy * adjy) + FIXED_HALF;
762 fdsOuter = SignedFloatToFixed(dsdy + dxOuter * dsdx);
763
764 t0 = vLower->texcoord[0][1] * T_SCALE;
765 ft = (GLfixed)(t0 * FIXED_SCALE + dtdx * adjx + dtdy * adjy) + FIXED_HALF;
766 fdtOuter = SignedFloatToFixed(dtdy + dxOuter * dtdx);
767 }
768 #endif
769 #ifdef INTERP_TEX
770 {
771 GLfloat invW = vLower->win[3];
772 GLfloat s0, t0, u0, v0;
773 s0 = vLower->texcoord[0][0] * invW;
774 sLeft = s0 + (dsdx * adjx + dsdy * adjy) * (1.0F/FIXED_SCALE);
775 dsOuter = dsdy + dxOuter * dsdx;
776 t0 = vLower->texcoord[0][1] * invW;
777 tLeft = t0 + (dtdx * adjx + dtdy * adjy) * (1.0F/FIXED_SCALE);
778 dtOuter = dtdy + dxOuter * dtdx;
779 u0 = vLower->texcoord[0][2] * invW;
780 uLeft = u0 + (dudx * adjx + dudy * adjy) * (1.0F/FIXED_SCALE);
781 duOuter = dudy + dxOuter * dudx;
782 v0 = vLower->texcoord[0][3] * invW;
783 vLeft = v0 + (dvdx * adjx + dvdy * adjy) * (1.0F/FIXED_SCALE);
784 dvOuter = dvdy + dxOuter * dvdx;
785 }
786 #endif
787 #ifdef INTERP_MULTITEX
788 {
789 GLuint u;
790 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
791 if (ctx->Texture.Unit[u]._ReallyEnabled) {
792 GLfloat invW = vLower->win[3];
793 GLfloat s0, t0, u0, v0;
794 s0 = vLower->texcoord[u][0] * invW;
795 sLeft[u] = s0 + (dsdx[u] * adjx + dsdy[u] * adjy) * (1.0F/FIXED_SCALE);
796 dsOuter[u] = dsdy[u] + dxOuter * dsdx[u];
797 t0 = vLower->texcoord[u][1] * invW;
798 tLeft[u] = t0 + (dtdx[u] * adjx + dtdy[u] * adjy) * (1.0F/FIXED_SCALE);
799 dtOuter[u] = dtdy[u] + dxOuter * dtdx[u];
800 u0 = vLower->texcoord[u][2] * invW;
801 uLeft[u] = u0 + (dudx[u] * adjx + dudy[u] * adjy) * (1.0F/FIXED_SCALE);
802 duOuter[u] = dudy[u] + dxOuter * dudx[u];
803 v0 = vLower->texcoord[u][3] * invW;
804 vLeft[u] = v0 + (dvdx[u] * adjx + dvdy[u] * adjy) * (1.0F/FIXED_SCALE);
805 dvOuter[u] = dvdy[u] + dxOuter * dvdx[u];
806 }
807 }
808 }
809 #endif
810
811 } /*if setupLeft*/
812
813
814 if (setupRight && eRight->lines>0) {
815 fxRightEdge = eRight->fsx - FIXED_EPSILON;
816 fdxRightEdge = eRight->fdxdy;
817 }
818
819 if (lines==0) {
820 continue;
821 }
822
823
824 /* Rasterize setup */
825 #ifdef PIXEL_ADDRESS
826 dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE);
827 #endif
828 #ifdef INTERP_Z
829 # ifdef DEPTH_TYPE
830 dZRowInner = dZRowOuter + sizeof(DEPTH_TYPE);
831 # endif
832 fdzInner = fdzOuter + fdzdx;
833 fdfogInner = fdfogOuter + fdfogdx;
834 #endif
835 #ifdef INTERP_RGB
836 fdrInner = fdrOuter + fdrdx;
837 fdgInner = fdgOuter + fdgdx;
838 fdbInner = fdbOuter + fdbdx;
839 #endif
840 #ifdef INTERP_SPEC
841 fdsrInner = fdsrOuter + fdsrdx;
842 fdsgInner = fdsgOuter + fdsgdx;
843 fdsbInner = fdsbOuter + fdsbdx;
844 #endif
845 #ifdef INTERP_ALPHA
846 fdaInner = fdaOuter + fdadx;
847 #endif
848 #ifdef INTERP_INDEX
849 fdiInner = fdiOuter + fdidx;
850 #endif
851 #ifdef INTERP_INT_TEX
852 fdsInner = fdsOuter + fdsdx;
853 fdtInner = fdtOuter + fdtdx;
854 #endif
855 #ifdef INTERP_TEX
856 dsInner = dsOuter + dsdx;
857 dtInner = dtOuter + dtdx;
858 duInner = duOuter + dudx;
859 dvInner = dvOuter + dvdx;
860 #endif
861 #ifdef INTERP_MULTITEX
862 {
863 GLuint u;
864 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
865 if (ctx->Texture.Unit[u]._ReallyEnabled) {
866 dsInner[u] = dsOuter[u] + dsdx[u];
867 dtInner[u] = dtOuter[u] + dtdx[u];
868 duInner[u] = duOuter[u] + dudx[u];
869 dvInner[u] = dvOuter[u] + dvdx[u];
870 }
871 }
872 }
873 #endif
874
875 while (lines>0) {
876 /* initialize the span interpolants to the leftmost value */
877 /* ff = fixed-pt fragment */
878 GLint left = FixedToInt(fxLeftEdge);
879 GLint right = FixedToInt(fxRightEdge);
880 #ifdef INTERP_Z
881 GLfixed ffz = fz;
882 GLfixed fffog = ffog;
883 #endif
884 #ifdef INTERP_RGB
885 GLfixed ffr = fr, ffg = fg, ffb = fb;
886 #endif
887 #ifdef INTERP_SPEC
888 GLfixed ffsr = fsr, ffsg = fsg, ffsb = fsb;
889 #endif
890 #ifdef INTERP_ALPHA
891 GLfixed ffa = fa;
892 #endif
893 #ifdef INTERP_INDEX
894 GLfixed ffi = fi;
895 #endif
896 #ifdef INTERP_INT_TEX
897 GLfixed ffs = fs, fft = ft;
898 #endif
899 #ifdef INTERP_TEX
900 GLfloat ss = sLeft, tt = tLeft, uu = uLeft, vv = vLeft;
901 #endif
902 #ifdef INTERP_MULTITEX
903 GLfloat ss[MAX_TEXTURE_UNITS];
904 GLfloat tt[MAX_TEXTURE_UNITS];
905 GLfloat uu[MAX_TEXTURE_UNITS];
906 GLfloat vv[MAX_TEXTURE_UNITS];
907 {
908 GLuint u;
909 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
910 if (ctx->Texture.Unit[u]._ReallyEnabled) {
911 ss[u] = sLeft[u];
912 tt[u] = tLeft[u];
913 uu[u] = uLeft[u];
914 vv[u] = vLeft[u];
915 }
916 }
917 }
918 #endif
919
920 #ifdef INTERP_RGB
921 {
922 /* need this to accomodate round-off errors */
923 GLfixed ffrend = ffr+(right-left-1)*fdrdx;
924 GLfixed ffgend = ffg+(right-left-1)*fdgdx;
925 GLfixed ffbend = ffb+(right-left-1)*fdbdx;
926 if (ffrend<0) ffr -= ffrend;
927 if (ffgend<0) ffg -= ffgend;
928 if (ffbend<0) ffb -= ffbend;
929 if (ffr<0) ffr = 0;
930 if (ffg<0) ffg = 0;
931 if (ffb<0) ffb = 0;
932 }
933 #endif
934 #ifdef INTERP_SPEC
935 {
936 /* need this to accomodate round-off errors */
937 GLfixed ffsrend = ffsr+(right-left-1)*fdsrdx;
938 GLfixed ffsgend = ffsg+(right-left-1)*fdsgdx;
939 GLfixed ffsbend = ffsb+(right-left-1)*fdsbdx;
940 if (ffsrend<0) ffsr -= ffsrend;
941 if (ffsgend<0) ffsg -= ffsgend;
942 if (ffsbend<0) ffsb -= ffsbend;
943 if (ffsr<0) ffsr = 0;
944 if (ffsg<0) ffsg = 0;
945 if (ffsb<0) ffsb = 0;
946 }
947 #endif
948 #ifdef INTERP_ALPHA
949 {
950 GLfixed ffaend = ffa+(right-left-1)*fdadx;
951 if (ffaend<0) ffa -= ffaend;
952 if (ffa<0) ffa = 0;
953 }
954 #endif
955 #ifdef INTERP_INDEX
956 if (ffi<0) ffi = 0;
957 #endif
958
959 INNER_LOOP( left, right, iy );
960
961 /*
962 * Advance to the next scan line. Compute the
963 * new edge coordinates, and adjust the
964 * pixel-center x coordinate so that it stays
965 * on or inside the major edge.
966 */
967 iy++;
968 lines--;
969
970 fxLeftEdge += fdxLeftEdge;
971 fxRightEdge += fdxRightEdge;
972
973
974 fError += fdError;
975 if (fError >= 0) {
976 fError -= FIXED_ONE;
977 #ifdef PIXEL_ADDRESS
978 pRow = (PIXEL_TYPE *) ((GLubyte*)pRow + dPRowOuter);
979 #endif
980 #ifdef INTERP_Z
981 # ifdef DEPTH_TYPE
982 zRow = (DEPTH_TYPE *) ((GLubyte*)zRow + dZRowOuter);
983 # endif
984 fz += fdzOuter;
985 ffog += fdfogOuter;
986 #endif
987 #ifdef INTERP_RGB
988 fr += fdrOuter; fg += fdgOuter; fb += fdbOuter;
989 #endif
990 #ifdef INTERP_SPEC
991 fsr += fdsrOuter; fsg += fdsgOuter; fsb += fdsbOuter;
992 #endif
993 #ifdef INTERP_ALPHA
994 fa += fdaOuter;
995 #endif
996 #ifdef INTERP_INDEX
997 fi += fdiOuter;
998 #endif
999 #ifdef INTERP_INT_TEX
1000 fs += fdsOuter; ft += fdtOuter;
1001 #endif
1002 #ifdef INTERP_TEX
1003 sLeft += dsOuter;
1004 tLeft += dtOuter;
1005 uLeft += duOuter;
1006 vLeft += dvOuter;
1007 #endif
1008 #ifdef INTERP_MULTITEX
1009 {
1010 GLuint u;
1011 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
1012 if (ctx->Texture.Unit[u]._ReallyEnabled) {
1013 sLeft[u] += dsOuter[u];
1014 tLeft[u] += dtOuter[u];
1015 uLeft[u] += duOuter[u];
1016 vLeft[u] += dvOuter[u];
1017 }
1018 }
1019 }
1020 #endif
1021 }
1022 else {
1023 #ifdef PIXEL_ADDRESS
1024 pRow = (PIXEL_TYPE *) ((GLubyte*)pRow + dPRowInner);
1025 #endif
1026 #ifdef INTERP_Z
1027 # ifdef DEPTH_TYPE
1028 zRow = (DEPTH_TYPE *) ((GLubyte*)zRow + dZRowInner);
1029 # endif
1030 fz += fdzInner;
1031 ffog += fdfogInner;
1032 #endif
1033 #ifdef INTERP_RGB
1034 fr += fdrInner; fg += fdgInner; fb += fdbInner;
1035 #endif
1036 #ifdef INTERP_SPEC
1037 fsr += fdsrInner; fsg += fdsgInner; fsb += fdsbInner;
1038 #endif
1039 #ifdef INTERP_ALPHA
1040 fa += fdaInner;
1041 #endif
1042 #ifdef INTERP_INDEX
1043 fi += fdiInner;
1044 #endif
1045 #ifdef INTERP_INT_TEX
1046 fs += fdsInner; ft += fdtInner;
1047 #endif
1048 #ifdef INTERP_TEX
1049 sLeft += dsInner;
1050 tLeft += dtInner;
1051 uLeft += duInner;
1052 vLeft += dvInner;
1053 #endif
1054 #ifdef INTERP_MULTITEX
1055 {
1056 GLuint u;
1057 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
1058 if (ctx->Texture.Unit[u]._ReallyEnabled) {
1059 sLeft[u] += dsInner[u];
1060 tLeft[u] += dtInner[u];
1061 uLeft[u] += duInner[u];
1062 vLeft[u] += dvInner[u];
1063 }
1064 }
1065 }
1066 #endif
1067 }
1068 } /*while lines>0*/
1069
1070 } /* for subTriangle */
1071
1072 }
1073 }
1074 }
1075
1076 #undef SETUP_CODE
1077 #undef INNER_LOOP
1078
1079 #undef PIXEL_TYPE
1080 #undef BYTES_PER_ROW
1081 #undef PIXEL_ADDRESS
1082
1083 #undef INTERP_Z
1084 #undef INTERP_RGB
1085 #undef INTERP_SPEC
1086 #undef INTERP_ALPHA
1087 #undef INTERP_INDEX
1088 #undef INTERP_INT_TEX
1089 #undef INTERP_TEX
1090 #undef INTERP_MULTITEX
1091
1092 #undef S_SCALE
1093 #undef T_SCALE
1094
1095 #undef FixedToDepth
1096
1097 #undef DO_OCCLUSION_TEST