1 /* $Id: s_tritemp.h,v 1.48 2003/03/25 02:23:48 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
26 /* $XFree86: xc/extras/Mesa/src/swrast/s_tritemp.h,v 1.2 2002/02/27 21:07:54 tsi Exp $ */
29 * Triangle Rasterizer Template
31 * This file is #include'd to generate custom triangle rasterizers.
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_FOG - if defined, interpolate fog values
37 * INTERP_RGB - if defined, interpolate RGB values
38 * INTERP_ALPHA - if defined, interpolate Alpha values (req's INTERP_RGB)
39 * INTERP_SPEC - if defined, interpolate specular RGB values
40 * INTERP_INDEX - if defined, interpolate color index values
41 * INTERP_INT_TEX - if defined, interpolate integer ST texcoords
42 * (fast, simple 2-D texture mapping)
43 * INTERP_TEX - if defined, interpolate set 0 float STRQ texcoords
44 * NOTE: OpenGL STRQ = Mesa STUV (R was taken for red)
45 * INTERP_MULTITEX - if defined, interpolate N units of STRQ texcoords
47 * When one can directly address pixels in the color buffer the following
48 * macros can be defined and used to compute pixel addresses during
49 * rasterization (see pRow):
50 * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint)
51 * BYTES_PER_ROW - number of bytes per row in the color buffer
52 * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
53 * Y==0 at bottom of screen and increases upward.
55 * Similarly, for direct depth buffer access, this type is used for depth
57 * DEPTH_TYPE - either GLushort or GLuint
59 * Optionally, one may provide one-time setup code per triangle:
60 * SETUP_CODE - code which is to be executed once per triangle
61 * CLEANUP_CODE - code to execute at end of triangle
63 * The following macro MUST be defined:
64 * RENDER_SPAN(span) - code to write a span of pixels.
66 * This code was designed for the origin to be in the lower-left corner.
68 * Inspired by triangle rasterizer code written by Allen Akin. Thanks Allen!
73 * ColorTemp is used for intermediate color values.
75 #if CHAN_TYPE == GL_FLOAT
76 #define ColorTemp GLfloat
78 #define ColorTemp GLint /* same as GLfixed */
82 * Either loop over all texture units, or just use unit zero.
84 #ifdef INTERP_MULTITEX
85 #define TEX_UNIT_LOOP(CODE) \
88 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
89 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
95 #elif defined(INTERP_TEX)
96 #define TEX_UNIT_LOOP(CODE) \
104 static void NAME(GLcontext
*ctx
, const SWvertex
*v0
,
109 const SWvertex
*v0
, *v1
; /* Y(v0) < Y(v1) */
110 GLfloat dx
; /* X(v1) - X(v0) */
111 GLfloat dy
; /* Y(v1) - Y(v0) */
112 GLfixed fdxdy
; /* dx/dy in fixed-point */
113 GLfixed fsx
; /* first sample point x coord */
115 GLfloat adjy
; /* adjust from v[0]->fy to fsy, scaled */
116 GLint lines
; /* number of lines to be sampled on this edge */
117 GLfixed fx0
; /* fixed pt X of lower endpoint */
121 const GLint depthBits
= ctx
->Visual
.depthBits
;
122 const GLint fixedToDepthShift
= depthBits
<= 16 ? FIXED_SHIFT
: 0;
123 const GLfloat maxDepth
= ctx
->DepthMaxF
;
124 #define FixedToDepth(F) ((F) >> fixedToDepthShift)
126 EdgeT eMaj
, eTop
, eBot
;
128 const SWvertex
*vMin
, *vMid
, *vMax
; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
129 float bf
= SWRAST_CONTEXT(ctx
)->_backface_sign
;
130 const GLint snapMask
= ~((FIXED_ONE
/ (1 << SUB_PIXEL_BITS
)) - 1); /* for x/y coord snapping */
131 GLfixed vMin_fx
, vMin_fy
, vMid_fx
, vMid_fy
, vMax_fx
, vMax_fy
;
135 INIT_SPAN(span
, GL_POLYGON
, 0, 0, 0);
138 (void) fixedToDepthShift
;
142 printf("%s()\n", __FUNCTION__);
143 printf(" %g, %g, %g\n", v0->win[0], v0->win[1], v0->win[2]);
144 printf(" %g, %g, %g\n", v1->win[0], v1->win[1], v1->win[2]);
145 printf(" %g, %g, %g\n", v2->win[0], v2->win[1], v2->win[2]);
148 /* Compute fixed point x,y coords w/ half-pixel offsets and snapping.
149 * And find the order of the 3 vertices along the Y axis.
152 const GLfixed fy0
= FloatToFixed(v0
->win
[1] - 0.5F
) & snapMask
;
153 const GLfixed fy1
= FloatToFixed(v1
->win
[1] - 0.5F
) & snapMask
;
154 const GLfixed fy2
= FloatToFixed(v2
->win
[1] - 0.5F
) & snapMask
;
159 vMin
= v0
; vMid
= v1
; vMax
= v2
;
160 vMin_fy
= fy0
; vMid_fy
= fy1
; vMax_fy
= fy2
;
162 else if (fy2
<= fy0
) {
164 vMin
= v2
; vMid
= v0
; vMax
= v1
;
165 vMin_fy
= fy2
; vMid_fy
= fy0
; vMax_fy
= fy1
;
169 vMin
= v0
; vMid
= v2
; vMax
= v1
;
170 vMin_fy
= fy0
; vMid_fy
= fy2
; vMax_fy
= fy1
;
177 vMin
= v1
; vMid
= v0
; vMax
= v2
;
178 vMin_fy
= fy1
; vMid_fy
= fy0
; vMax_fy
= fy2
;
181 else if (fy2
<= fy1
) {
183 vMin
= v2
; vMid
= v1
; vMax
= v0
;
184 vMin_fy
= fy2
; vMid_fy
= fy1
; vMax_fy
= fy0
;
189 vMin
= v1
; vMid
= v2
; vMax
= v0
;
190 vMin_fy
= fy1
; vMid_fy
= fy2
; vMax_fy
= fy0
;
194 /* fixed point X coords */
195 vMin_fx
= FloatToFixed(vMin
->win
[0] + 0.5F
) & snapMask
;
196 vMid_fx
= FloatToFixed(vMid
->win
[0] + 0.5F
) & snapMask
;
197 vMax_fx
= FloatToFixed(vMax
->win
[0] + 0.5F
) & snapMask
;
200 /* vertex/edge relationship */
201 eMaj
.v0
= vMin
; eMaj
.v1
= vMax
; /*TODO: .v1's not needed */
202 eTop
.v0
= vMid
; eTop
.v1
= vMax
;
203 eBot
.v0
= vMin
; eBot
.v1
= vMid
;
205 /* compute deltas for each edge: vertex[upper] - vertex[lower] */
206 eMaj
.dx
= FixedToFloat(vMax_fx
- vMin_fx
);
207 eMaj
.dy
= FixedToFloat(vMax_fy
- vMin_fy
);
208 eTop
.dx
= FixedToFloat(vMax_fx
- vMid_fx
);
209 eTop
.dy
= FixedToFloat(vMax_fy
- vMid_fy
);
210 eBot
.dx
= FixedToFloat(vMid_fx
- vMin_fx
);
211 eBot
.dy
= FixedToFloat(vMid_fy
- vMin_fy
);
213 /* compute area, oneOverArea and perform backface culling */
215 const GLfloat area
= eMaj
.dx
* eBot
.dy
- eBot
.dx
* eMaj
.dy
;
217 /* Do backface culling */
221 if (IS_INF_OR_NAN(area
) || area
== 0.0F
)
224 oneOverArea
= 1.0F
/ area
;
227 #ifndef DO_OCCLUSION_TEST
228 ctx
->OcclusionResult
= GL_TRUE
;
230 span
.facing
= ctx
->_Facing
; /* for 2-sided stencil test */
232 /* Edge setup. For a triangle strip these could be reused... */
234 eMaj
.fsy
= FixedCeil(vMin_fy
);
235 eMaj
.lines
= FixedToInt(FixedCeil(vMax_fy
- eMaj
.fsy
));
236 if (eMaj
.lines
> 0) {
237 GLfloat dxdy
= eMaj
.dx
/ eMaj
.dy
;
238 eMaj
.fdxdy
= SignedFloatToFixed(dxdy
);
239 eMaj
.adjy
= (GLfloat
) (eMaj
.fsy
- vMin_fy
); /* SCALED! */
241 eMaj
.fsx
= eMaj
.fx0
+ (GLfixed
) (eMaj
.adjy
* dxdy
);
247 eTop
.fsy
= FixedCeil(vMid_fy
);
248 eTop
.lines
= FixedToInt(FixedCeil(vMax_fy
- eTop
.fsy
));
249 if (eTop
.lines
> 0) {
250 GLfloat dxdy
= eTop
.dx
/ eTop
.dy
;
251 eTop
.fdxdy
= SignedFloatToFixed(dxdy
);
252 eTop
.adjy
= (GLfloat
) (eTop
.fsy
- vMid_fy
); /* SCALED! */
254 eTop
.fsx
= eTop
.fx0
+ (GLfixed
) (eTop
.adjy
* dxdy
);
257 eBot
.fsy
= FixedCeil(vMin_fy
);
258 eBot
.lines
= FixedToInt(FixedCeil(vMid_fy
- eBot
.fsy
));
259 if (eBot
.lines
> 0) {
260 GLfloat dxdy
= eBot
.dx
/ eBot
.dy
;
261 eBot
.fdxdy
= SignedFloatToFixed(dxdy
);
262 eBot
.adjy
= (GLfloat
) (eBot
.fsy
- vMin_fy
); /* SCALED! */
264 eBot
.fsx
= eBot
.fx0
+ (GLfixed
) (eBot
.adjy
* dxdy
);
269 * Conceptually, we view a triangle as two subtriangles
270 * separated by a perfectly horizontal line. The edge that is
271 * intersected by this line is one with maximal absolute dy; we
272 * call it a ``major'' edge. The other two edges are the
273 * ``top'' edge (for the upper subtriangle) and the ``bottom''
274 * edge (for the lower subtriangle). If either of these two
275 * edges is horizontal or very close to horizontal, the
276 * corresponding subtriangle might cover zero sample points;
277 * we take care to handle such cases, for performance as well
280 * By stepping rasterization parameters along the major edge,
281 * we can avoid recomputing them at the discontinuity where
282 * the top and bottom edges meet. However, this forces us to
283 * be able to scan both left-to-right and right-to-left.
284 * Also, we must determine whether the major edge is at the
285 * left or right side of the triangle. We do this by
286 * computing the magnitude of the cross-product of the major
287 * and top edges. Since this magnitude depends on the sine of
288 * the angle between the two edges, its sign tells us whether
289 * we turn to the left or to the right when travelling along
290 * the major edge to the top edge, and from this we infer
291 * whether the major edge is on the left or the right.
293 * Serendipitously, this cross-product magnitude is also a
294 * value we need to compute the iteration parameter
295 * derivatives for the triangle, and it can be used to perform
296 * backface culling because its sign tells us whether the
297 * triangle is clockwise or counterclockwise. In this code we
298 * refer to it as ``area'' because it's also proportional to
299 * the pixel area of the triangle.
303 GLint scan_from_left_to_right
; /* true if scanning left-to-right */
309 * Execute user-supplied setup code
315 scan_from_left_to_right
= (oneOverArea
< 0.0F
);
318 /* compute d?/dx and d?/dy derivatives */
320 span
.interpMask
|= SPAN_Z
;
322 GLfloat eMaj_dz
= vMax
->win
[2] - vMin
->win
[2];
323 GLfloat eBot_dz
= vMid
->win
[2] - vMin
->win
[2];
324 span
.dzdx
= oneOverArea
* (eMaj_dz
* eBot
.dy
- eMaj
.dy
* eBot_dz
);
325 if (span
.dzdx
> maxDepth
|| span
.dzdx
< -maxDepth
) {
326 /* probably a sliver triangle */
331 span
.dzdy
= oneOverArea
* (eMaj
.dx
* eBot_dz
- eMaj_dz
* eBot
.dx
);
334 span
.zStep
= SignedFloatToFixed(span
.dzdx
);
336 span
.zStep
= (GLint
) span
.dzdx
;
341 const GLfloat eMaj_dw
= vMax
->win
[3] - vMin
->win
[3];
342 const GLfloat eBot_dw
= vMid
->win
[3] - vMin
->win
[3];
343 span
.dwdx
= oneOverArea
* (eMaj_dw
* eBot
.dy
- eMaj
.dy
* eBot_dw
);
344 span
.dwdy
= oneOverArea
* (eMaj
.dx
* eBot_dw
- eMaj_dw
* eBot
.dx
);
348 span
.interpMask
|= SPAN_FOG
;
350 const GLfloat eMaj_dfog
= vMax
->fog
- vMin
->fog
;
351 const GLfloat eBot_dfog
= vMid
->fog
- vMin
->fog
;
352 span
.dfogdx
= oneOverArea
* (eMaj_dfog
* eBot
.dy
- eMaj
.dy
* eBot_dfog
);
353 span
.dfogdy
= oneOverArea
* (eMaj
.dx
* eBot_dfog
- eMaj_dfog
* eBot
.dx
);
354 span
.fogStep
= span
.dfogdx
;
358 span
.interpMask
|= SPAN_RGBA
;
359 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
360 GLfloat eMaj_dr
= (GLfloat
) ((ColorTemp
) vMax
->color
[RCOMP
] - vMin
->color
[RCOMP
]);
361 GLfloat eBot_dr
= (GLfloat
) ((ColorTemp
) vMid
->color
[RCOMP
] - vMin
->color
[RCOMP
]);
362 GLfloat eMaj_dg
= (GLfloat
) ((ColorTemp
) vMax
->color
[GCOMP
] - vMin
->color
[GCOMP
]);
363 GLfloat eBot_dg
= (GLfloat
) ((ColorTemp
) vMid
->color
[GCOMP
] - vMin
->color
[GCOMP
]);
364 GLfloat eMaj_db
= (GLfloat
) ((ColorTemp
) vMax
->color
[BCOMP
] - vMin
->color
[BCOMP
]);
365 GLfloat eBot_db
= (GLfloat
) ((ColorTemp
) vMid
->color
[BCOMP
] - vMin
->color
[BCOMP
]);
367 GLfloat eMaj_da
= (GLfloat
) ((ColorTemp
) vMax
->color
[ACOMP
] - vMin
->color
[ACOMP
]);
368 GLfloat eBot_da
= (GLfloat
) ((ColorTemp
) vMid
->color
[ACOMP
] - vMin
->color
[ACOMP
]);
370 span
.drdx
= oneOverArea
* (eMaj_dr
* eBot
.dy
- eMaj
.dy
* eBot_dr
);
371 span
.drdy
= oneOverArea
* (eMaj
.dx
* eBot_dr
- eMaj_dr
* eBot
.dx
);
372 span
.dgdx
= oneOverArea
* (eMaj_dg
* eBot
.dy
- eMaj
.dy
* eBot_dg
);
373 span
.dgdy
= oneOverArea
* (eMaj
.dx
* eBot_dg
- eMaj_dg
* eBot
.dx
);
374 span
.dbdx
= oneOverArea
* (eMaj_db
* eBot
.dy
- eMaj
.dy
* eBot_db
);
375 span
.dbdy
= oneOverArea
* (eMaj
.dx
* eBot_db
- eMaj_db
* eBot
.dx
);
376 # if CHAN_TYPE == GL_FLOAT
377 span
.redStep
= span
.drdx
;
378 span
.greenStep
= span
.dgdx
;
379 span
.blueStep
= span
.dbdx
;
381 span
.redStep
= SignedFloatToFixed(span
.drdx
);
382 span
.greenStep
= SignedFloatToFixed(span
.dgdx
);
383 span
.blueStep
= SignedFloatToFixed(span
.dbdx
);
384 # endif /* GL_FLOAT */
386 span
.dadx
= oneOverArea
* (eMaj_da
* eBot
.dy
- eMaj
.dy
* eBot_da
);
387 span
.dady
= oneOverArea
* (eMaj
.dx
* eBot_da
- eMaj_da
* eBot
.dx
);
388 # if CHAN_TYPE == GL_FLOAT
389 span
.alphaStep
= span
.dadx
;
391 span
.alphaStep
= SignedFloatToFixed(span
.dadx
);
392 # endif /* GL_FLOAT */
393 # endif /* INTERP_ALPHA */
396 ASSERT (ctx
->Light
.ShadeModel
== GL_FLAT
);
397 span
.interpMask
|= SPAN_FLAT
;
398 span
.drdx
= span
.drdy
= span
.redStep
= 0;
399 span
.dgdx
= span
.dgdy
= span
.greenStep
= 0;
400 span
.dbdx
= span
.dbdy
= span
.blueStep
= 0;
402 span
.dadx
= span
.dady
= span
.alphaStep
= 0;
405 #endif /* INTERP_RGB */
407 span
.interpMask
|= SPAN_SPEC
;
408 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
409 GLfloat eMaj_dsr
= (GLfloat
) ((ColorTemp
) vMax
->specular
[RCOMP
] - vMin
->specular
[RCOMP
]);
410 GLfloat eBot_dsr
= (GLfloat
) ((ColorTemp
) vMid
->specular
[RCOMP
] - vMin
->specular
[RCOMP
]);
411 GLfloat eMaj_dsg
= (GLfloat
) ((ColorTemp
) vMax
->specular
[GCOMP
] - vMin
->specular
[GCOMP
]);
412 GLfloat eBot_dsg
= (GLfloat
) ((ColorTemp
) vMid
->specular
[GCOMP
] - vMin
->specular
[GCOMP
]);
413 GLfloat eMaj_dsb
= (GLfloat
) ((ColorTemp
) vMax
->specular
[BCOMP
] - vMin
->specular
[BCOMP
]);
414 GLfloat eBot_dsb
= (GLfloat
) ((ColorTemp
) vMid
->specular
[BCOMP
] - vMin
->specular
[BCOMP
]);
415 span
.dsrdx
= oneOverArea
* (eMaj_dsr
* eBot
.dy
- eMaj
.dy
* eBot_dsr
);
416 span
.dsrdy
= oneOverArea
* (eMaj
.dx
* eBot_dsr
- eMaj_dsr
* eBot
.dx
);
417 span
.dsgdx
= oneOverArea
* (eMaj_dsg
* eBot
.dy
- eMaj
.dy
* eBot_dsg
);
418 span
.dsgdy
= oneOverArea
* (eMaj
.dx
* eBot_dsg
- eMaj_dsg
* eBot
.dx
);
419 span
.dsbdx
= oneOverArea
* (eMaj_dsb
* eBot
.dy
- eMaj
.dy
* eBot_dsb
);
420 span
.dsbdy
= oneOverArea
* (eMaj
.dx
* eBot_dsb
- eMaj_dsb
* eBot
.dx
);
421 # if CHAN_TYPE == GL_FLOAT
422 span
.specRedStep
= span
.dsrdx
;
423 span
.specGreenStep
= span
.dsgdx
;
424 span
.specBlueStep
= span
.dsbdx
;
426 span
.specRedStep
= SignedFloatToFixed(span
.dsrdx
);
427 span
.specGreenStep
= SignedFloatToFixed(span
.dsgdx
);
428 span
.specBlueStep
= SignedFloatToFixed(span
.dsbdx
);
432 span
.dsrdx
= span
.dsrdy
= span
.specRedStep
= 0;
433 span
.dsgdx
= span
.dsgdy
= span
.specGreenStep
= 0;
434 span
.dsbdx
= span
.dsbdy
= span
.specBlueStep
= 0;
436 #endif /* INTERP_SPEC */
438 span
.interpMask
|= SPAN_INDEX
;
439 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
440 GLfloat eMaj_di
= (GLfloat
) ((GLint
) vMax
->index
- (GLint
) vMin
->index
);
441 GLfloat eBot_di
= (GLfloat
) ((GLint
) vMid
->index
- (GLint
) vMin
->index
);
442 didx
= oneOverArea
* (eMaj_di
* eBot
.dy
- eMaj
.dy
* eBot_di
);
443 didy
= oneOverArea
* (eMaj
.dx
* eBot_di
- eMaj_di
* eBot
.dx
);
444 span
.indexStep
= SignedFloatToFixed(didx
);
447 span
.interpMask
|= SPAN_FLAT
;
452 #ifdef INTERP_INT_TEX
453 span
.interpMask
|= SPAN_INT_TEXTURE
;
455 GLfloat eMaj_ds
= (vMax
->texcoord
[0][0] - vMin
->texcoord
[0][0]) * S_SCALE
;
456 GLfloat eBot_ds
= (vMid
->texcoord
[0][0] - vMin
->texcoord
[0][0]) * S_SCALE
;
457 GLfloat eMaj_dt
= (vMax
->texcoord
[0][1] - vMin
->texcoord
[0][1]) * T_SCALE
;
458 GLfloat eBot_dt
= (vMid
->texcoord
[0][1] - vMin
->texcoord
[0][1]) * T_SCALE
;
459 span
.texStepX
[0][0] = oneOverArea
* (eMaj_ds
* eBot
.dy
- eMaj
.dy
* eBot_ds
);
460 span
.texStepY
[0][0] = oneOverArea
* (eMaj
.dx
* eBot_ds
- eMaj_ds
* eBot
.dx
);
461 span
.texStepX
[0][1] = oneOverArea
* (eMaj_dt
* eBot
.dy
- eMaj
.dy
* eBot_dt
);
462 span
.texStepY
[0][1] = oneOverArea
* (eMaj
.dx
* eBot_dt
- eMaj_dt
* eBot
.dx
);
463 span
.intTexStep
[0] = SignedFloatToFixed(span
.texStepX
[0][0]);
464 span
.intTexStep
[1] = SignedFloatToFixed(span
.texStepX
[0][1]);
468 span
.interpMask
|= SPAN_TEXTURE
;
471 const GLfloat wMax
= vMax
->win
[3], wMin
= vMin
->win
[3], wMid
= vMid
->win
[3];
473 GLfloat eMaj_ds
= vMax
->texcoord
[u
][0] * wMax
- vMin
->texcoord
[u
][0] * wMin
;
474 GLfloat eBot_ds
= vMid
->texcoord
[u
][0] * wMid
- vMin
->texcoord
[u
][0] * wMin
;
475 GLfloat eMaj_dt
= vMax
->texcoord
[u
][1] * wMax
- vMin
->texcoord
[u
][1] * wMin
;
476 GLfloat eBot_dt
= vMid
->texcoord
[u
][1] * wMid
- vMin
->texcoord
[u
][1] * wMin
;
477 GLfloat eMaj_du
= vMax
->texcoord
[u
][2] * wMax
- vMin
->texcoord
[u
][2] * wMin
;
478 GLfloat eBot_du
= vMid
->texcoord
[u
][2] * wMid
- vMin
->texcoord
[u
][2] * wMin
;
479 GLfloat eMaj_dv
= vMax
->texcoord
[u
][3] * wMax
- vMin
->texcoord
[u
][3] * wMin
;
480 GLfloat eBot_dv
= vMid
->texcoord
[u
][3] * wMid
- vMin
->texcoord
[u
][3] * wMin
;
481 span
.texStepX
[u
][0] = oneOverArea
* (eMaj_ds
* eBot
.dy
- eMaj
.dy
* eBot_ds
);
482 span
.texStepY
[u
][0] = oneOverArea
* (eMaj
.dx
* eBot_ds
- eMaj_ds
* eBot
.dx
);
483 span
.texStepX
[u
][1] = oneOverArea
* (eMaj_dt
* eBot
.dy
- eMaj
.dy
* eBot_dt
);
484 span
.texStepY
[u
][1] = oneOverArea
* (eMaj
.dx
* eBot_dt
- eMaj_dt
* eBot
.dx
);
485 span
.texStepX
[u
][2] = oneOverArea
* (eMaj_du
* eBot
.dy
- eMaj
.dy
* eBot_du
);
486 span
.texStepY
[u
][2] = oneOverArea
* (eMaj
.dx
* eBot_du
- eMaj_du
* eBot
.dx
);
487 span
.texStepX
[u
][3] = oneOverArea
* (eMaj_dv
* eBot
.dy
- eMaj
.dy
* eBot_dv
);
488 span
.texStepY
[u
][3] = oneOverArea
* (eMaj
.dx
* eBot_dv
- eMaj_dv
* eBot
.dx
);
494 * We always sample at pixel centers. However, we avoid
495 * explicit half-pixel offsets in this code by incorporating
496 * the proper offset in each of x and y during the
497 * transformation to window coordinates.
499 * We also apply the usual rasterization rules to prevent
500 * cracks and overlaps. A pixel is considered inside a
501 * subtriangle if it meets all of four conditions: it is on or
502 * to the right of the left edge, strictly to the left of the
503 * right edge, on or below the top edge, and strictly above
504 * the bottom edge. (Some edges may be degenerate.)
506 * The following discussion assumes left-to-right scanning
507 * (that is, the major edge is on the left); the right-to-left
508 * case is a straightforward variation.
510 * We start by finding the half-integral y coordinate that is
511 * at or below the top of the triangle. This gives us the
512 * first scan line that could possibly contain pixels that are
513 * inside the triangle.
515 * Next we creep down the major edge until we reach that y,
516 * and compute the corresponding x coordinate on the edge.
517 * Then we find the half-integral x that lies on or just
518 * inside the edge. This is the first pixel that might lie in
519 * the interior of the triangle. (We won't know for sure
520 * until we check the other edges.)
522 * As we rasterize the triangle, we'll step down the major
523 * edge. For each step in y, we'll move an integer number
524 * of steps in x. There are two possible x step sizes, which
525 * we'll call the ``inner'' step (guaranteed to land on the
526 * edge or inside it) and the ``outer'' step (guaranteed to
527 * land on the edge or outside it). The inner and outer steps
528 * differ by one. During rasterization we maintain an error
529 * term that indicates our distance from the true edge, and
530 * select either the inner step or the outer step, whichever
531 * gets us to the first pixel that falls inside the triangle.
533 * All parameters (z, red, etc.) as well as the buffer
534 * addresses for color and z have inner and outer step values,
535 * so that we can increment them appropriately. This method
536 * eliminates the need to adjust parameters by creeping a
537 * sub-pixel amount into the triangle at each scanline.
543 GLfixed fxLeftEdge
= 0, fxRightEdge
= 0;
544 GLfixed fdxLeftEdge
= 0, fdxRightEdge
= 0;
548 GLfixed fError
= 0, fdError
= 0;
552 PIXEL_TYPE
*pRow
= NULL
;
553 int dPRowOuter
= 0, dPRowInner
; /* offset in bytes */
557 DEPTH_TYPE
*zRow
= NULL
;
558 int dZRowOuter
= 0, dZRowInner
; /* offset in bytes */
560 GLfixed zLeft
= 0, fdzOuter
= 0, fdzInner
;
563 GLfloat wLeft
, dwOuter
, dwInner
;
566 GLfloat fogLeft
= 0, dfogOuter
= 0, dfogInner
;
569 ColorTemp rLeft
= 0, fdrOuter
= 0, fdrInner
;
570 ColorTemp gLeft
= 0, fdgOuter
= 0, fdgInner
;
571 ColorTemp bLeft
= 0, fdbOuter
= 0, fdbInner
;
574 ColorTemp aLeft
= 0, fdaOuter
= 0, fdaInner
;
577 ColorTemp srLeft
=0, dsrOuter
=0, dsrInner
;
578 ColorTemp sgLeft
=0, dsgOuter
=0, dsgInner
;
579 ColorTemp sbLeft
=0, dsbOuter
=0, dsbInner
;
582 GLfixed iLeft
=0, diOuter
=0, diInner
;
584 #ifdef INTERP_INT_TEX
585 GLfixed sLeft
=0, dsOuter
=0, dsInner
;
586 GLfixed tLeft
=0, dtOuter
=0, dtInner
;
589 GLfloat sLeft
[MAX_TEXTURE_COORD_UNITS
];
590 GLfloat tLeft
[MAX_TEXTURE_COORD_UNITS
];
591 GLfloat uLeft
[MAX_TEXTURE_COORD_UNITS
];
592 GLfloat vLeft
[MAX_TEXTURE_COORD_UNITS
];
593 GLfloat dsOuter
[MAX_TEXTURE_COORD_UNITS
], dsInner
[MAX_TEXTURE_COORD_UNITS
];
594 GLfloat dtOuter
[MAX_TEXTURE_COORD_UNITS
], dtInner
[MAX_TEXTURE_COORD_UNITS
];
595 GLfloat duOuter
[MAX_TEXTURE_COORD_UNITS
], duInner
[MAX_TEXTURE_COORD_UNITS
];
596 GLfloat dvOuter
[MAX_TEXTURE_COORD_UNITS
], dvInner
[MAX_TEXTURE_COORD_UNITS
];
599 for (subTriangle
=0; subTriangle
<=1; subTriangle
++) {
600 EdgeT
*eLeft
, *eRight
;
601 int setupLeft
, setupRight
;
604 if (subTriangle
==0) {
606 if (scan_from_left_to_right
) {
609 lines
= eRight
->lines
;
616 lines
= eLeft
->lines
;
623 if (scan_from_left_to_right
) {
626 lines
= eRight
->lines
;
633 lines
= eLeft
->lines
;
641 if (setupLeft
&& eLeft
->lines
> 0) {
642 const SWvertex
*vLower
;
643 GLfixed fsx
= eLeft
->fsx
;
645 fError
= fx
- fsx
- FIXED_ONE
;
646 fxLeftEdge
= fsx
- FIXED_EPSILON
;
647 fdxLeftEdge
= eLeft
->fdxdy
;
648 fdxOuter
= FixedFloor(fdxLeftEdge
- FIXED_EPSILON
);
649 fdError
= fdxOuter
- fdxLeftEdge
+ FIXED_ONE
;
650 idxOuter
= FixedToInt(fdxOuter
);
651 dxOuter
= (float) idxOuter
;
655 span
.y
= FixedToInt(fy
);
657 adjx
= (float)(fx
- eLeft
->fx0
); /* SCALED! */
658 adjy
= eLeft
->adjy
; /* SCALED! */
660 (void) adjx
; /* silence compiler warnings */
661 (void) adjy
; /* silence compiler warnings */
665 (void) vLower
; /* silence compiler warnings */
670 pRow
= (PIXEL_TYPE
*) PIXEL_ADDRESS(FixedToInt(fxLeftEdge
), span
.y
);
671 dPRowOuter
= -((int)BYTES_PER_ROW
) + idxOuter
* sizeof(PIXEL_TYPE
);
672 /* negative because Y=0 at bottom and increases upward */
676 * Now we need the set of parameter (z, color, etc.) values at
677 * the point (fx, fy). This gives us properly-sampled parameter
678 * values that we can step from pixel to pixel. Furthermore,
679 * although we might have intermediate results that overflow
680 * the normal parameter range when we step temporarily outside
681 * the triangle, we shouldn't overflow or underflow for any
682 * pixel that's actually inside the triangle.
687 GLfloat z0
= vLower
->win
[2];
688 if (depthBits
<= 16) {
689 /* interpolate fixed-pt values */
690 GLfloat tmp
= (z0
* FIXED_SCALE
+ span
.dzdx
* adjx
+ span
.dzdy
* adjy
) + FIXED_HALF
;
691 if (tmp
< MAX_GLUINT
/ 2)
692 zLeft
= (GLfixed
) tmp
;
694 zLeft
= MAX_GLUINT
/ 2;
695 fdzOuter
= SignedFloatToFixed(span
.dzdy
+ dxOuter
* span
.dzdx
);
698 /* interpolate depth values exactly */
699 zLeft
= (GLint
) (z0
+ span
.dzdx
* FixedToFloat(adjx
) + span
.dzdy
* FixedToFloat(adjy
));
700 fdzOuter
= (GLint
) (span
.dzdy
+ dxOuter
* span
.dzdx
);
703 zRow
= (DEPTH_TYPE
*)
704 _swrast_zbuffer_address(ctx
, FixedToInt(fxLeftEdge
), span
.y
);
705 dZRowOuter
= (ctx
->DrawBuffer
->Width
+ idxOuter
) * sizeof(DEPTH_TYPE
);
710 wLeft
= vLower
->win
[3] + (span
.dwdx
* adjx
+ span
.dwdy
* adjy
) * (1.0F
/FIXED_SCALE
);
711 dwOuter
= span
.dwdy
+ dxOuter
* span
.dwdx
;
714 fogLeft
= vLower
->fog
+ (span
.dfogdx
* adjx
+ span
.dfogdy
* adjy
) * (1.0F
/FIXED_SCALE
);
715 dfogOuter
= span
.dfogdy
+ dxOuter
* span
.dfogdx
;
718 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
719 # if CHAN_TYPE == GL_FLOAT
720 rLeft
= vLower
->color
[RCOMP
] + (span
.drdx
* adjx
+ span
.drdy
* adjy
) * (1.0F
/ FIXED_SCALE
);
721 gLeft
= vLower
->color
[GCOMP
] + (span
.dgdx
* adjx
+ span
.dgdy
* adjy
) * (1.0F
/ FIXED_SCALE
);
722 bLeft
= vLower
->color
[BCOMP
] + (span
.dbdx
* adjx
+ span
.dbdy
* adjy
) * (1.0F
/ FIXED_SCALE
);
723 fdrOuter
= span
.drdy
+ dxOuter
* span
.drdx
;
724 fdgOuter
= span
.dgdy
+ dxOuter
* span
.dgdx
;
725 fdbOuter
= span
.dbdy
+ dxOuter
* span
.dbdx
;
727 rLeft
= (ChanToFixed(vLower
->color
[RCOMP
]) + span
.drdx
* adjx
+ span
.drdy
* adjy
) + FIXED_HALF
;
728 gLeft
= (ChanToFixed(vLower
->color
[GCOMP
]) + span
.dgdx
* adjx
+ span
.dgdy
* adjy
) + FIXED_HALF
;
729 bLeft
= (ChanToFixed(vLower
->color
[BCOMP
]) + span
.dbdx
* adjx
+ span
.dbdy
* adjy
) + FIXED_HALF
;
730 fdrOuter
= SignedFloatToFixed(span
.drdy
+ dxOuter
* span
.drdx
);
731 fdgOuter
= SignedFloatToFixed(span
.dgdy
+ dxOuter
* span
.dgdx
);
732 fdbOuter
= SignedFloatToFixed(span
.dbdy
+ dxOuter
* span
.dbdx
);
735 # if CHAN_TYPE == GL_FLOAT
736 aLeft
= vLower
->color
[ACOMP
] + (span
.dadx
* adjx
+ span
.dady
* adjy
) * (1.0F
/ FIXED_SCALE
);
737 fdaOuter
= span
.dady
+ dxOuter
* span
.dadx
;
739 aLeft
= (ChanToFixed(vLower
->color
[ACOMP
]) + span
.dadx
* adjx
+ span
.dady
* adjy
) + FIXED_HALF
;
740 fdaOuter
= SignedFloatToFixed(span
.dady
+ dxOuter
* span
.dadx
);
745 ASSERT (ctx
->Light
.ShadeModel
== GL_FLAT
);
746 # if CHAN_TYPE == GL_FLOAT
747 rLeft
= v2
->color
[RCOMP
];
748 gLeft
= v2
->color
[GCOMP
];
749 bLeft
= v2
->color
[BCOMP
];
750 fdrOuter
= fdgOuter
= fdbOuter
= 0.0F
;
752 rLeft
= ChanToFixed(v2
->color
[RCOMP
]);
753 gLeft
= ChanToFixed(v2
->color
[GCOMP
]);
754 bLeft
= ChanToFixed(v2
->color
[BCOMP
]);
755 fdrOuter
= fdgOuter
= fdbOuter
= 0;
758 # if CHAN_TYPE == GL_FLOAT
759 aLeft
= v2
->color
[ACOMP
];
762 aLeft
= ChanToFixed(v2
->color
[ACOMP
]);
770 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
771 # if CHAN_TYPE == GL_FLOAT
772 srLeft
= vLower
->specular
[RCOMP
] + (span
.dsrdx
* adjx
+ span
.dsrdy
* adjy
) * (1.0F
/ FIXED_SCALE
);
773 sgLeft
= vLower
->specular
[GCOMP
] + (span
.dsgdx
* adjx
+ span
.dsgdy
* adjy
) * (1.0F
/ FIXED_SCALE
);
774 sbLeft
= vLower
->specular
[BCOMP
] + (span
.dsbdx
* adjx
+ span
.dsbdy
* adjy
) * (1.0F
/ FIXED_SCALE
);
775 dsrOuter
= span
.dsrdy
+ dxOuter
* span
.dsrdx
;
776 dsgOuter
= span
.dsgdy
+ dxOuter
* span
.dsgdx
;
777 dsbOuter
= span
.dsbdy
+ dxOuter
* span
.dsbdx
;
779 srLeft
= (GLfixed
) (ChanToFixed(vLower
->specular
[RCOMP
]) + span
.dsrdx
* adjx
+ span
.dsrdy
* adjy
) + FIXED_HALF
;
780 sgLeft
= (GLfixed
) (ChanToFixed(vLower
->specular
[GCOMP
]) + span
.dsgdx
* adjx
+ span
.dsgdy
* adjy
) + FIXED_HALF
;
781 sbLeft
= (GLfixed
) (ChanToFixed(vLower
->specular
[BCOMP
]) + span
.dsbdx
* adjx
+ span
.dsbdy
* adjy
) + FIXED_HALF
;
782 dsrOuter
= SignedFloatToFixed(span
.dsrdy
+ dxOuter
* span
.dsrdx
);
783 dsgOuter
= SignedFloatToFixed(span
.dsgdy
+ dxOuter
* span
.dsgdx
);
784 dsbOuter
= SignedFloatToFixed(span
.dsbdy
+ dxOuter
* span
.dsbdx
);
788 #if CHAN_TYPE == GL_FLOAT
789 srLeft
= v2
->specular
[RCOMP
];
790 sgLeft
= v2
->specular
[GCOMP
];
791 sbLeft
= v2
->specular
[BCOMP
];
792 dsrOuter
= dsgOuter
= dsbOuter
= 0.0F
;
794 srLeft
= ChanToFixed(v2
->specular
[RCOMP
]);
795 sgLeft
= ChanToFixed(v2
->specular
[GCOMP
]);
796 sbLeft
= ChanToFixed(v2
->specular
[BCOMP
]);
797 dsrOuter
= dsgOuter
= dsbOuter
= 0;
803 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
804 iLeft
= (GLfixed
)(vLower
->index
* FIXED_SCALE
805 + didx
* adjx
+ didy
* adjy
) + FIXED_HALF
;
806 diOuter
= SignedFloatToFixed(didy
+ dxOuter
* didx
);
809 iLeft
= (GLfixed
) (v2
->index
* FIXED_SCALE
);
813 #ifdef INTERP_INT_TEX
816 s0
= vLower
->texcoord
[0][0] * S_SCALE
;
817 sLeft
= (GLfixed
)(s0
* FIXED_SCALE
+ span
.texStepX
[0][0] * adjx
818 + span
.texStepY
[0][0] * adjy
) + FIXED_HALF
;
819 dsOuter
= SignedFloatToFixed(span
.texStepY
[0][0] + dxOuter
* span
.texStepX
[0][0]);
821 t0
= vLower
->texcoord
[0][1] * T_SCALE
;
822 tLeft
= (GLfixed
)(t0
* FIXED_SCALE
+ span
.texStepX
[0][1] * adjx
823 + span
.texStepY
[0][1] * adjy
) + FIXED_HALF
;
824 dtOuter
= SignedFloatToFixed(span
.texStepY
[0][1] + dxOuter
* span
.texStepX
[0][1]);
829 const GLfloat invW
= vLower
->win
[3];
830 const GLfloat s0
= vLower
->texcoord
[u
][0] * invW
;
831 const GLfloat t0
= vLower
->texcoord
[u
][1] * invW
;
832 const GLfloat u0
= vLower
->texcoord
[u
][2] * invW
;
833 const GLfloat v0
= vLower
->texcoord
[u
][3] * invW
;
834 sLeft
[u
] = s0
+ (span
.texStepX
[u
][0] * adjx
+ span
.texStepY
[u
][0] * adjy
) * (1.0F
/FIXED_SCALE
);
835 tLeft
[u
] = t0
+ (span
.texStepX
[u
][1] * adjx
+ span
.texStepY
[u
][1] * adjy
) * (1.0F
/FIXED_SCALE
);
836 uLeft
[u
] = u0
+ (span
.texStepX
[u
][2] * adjx
+ span
.texStepY
[u
][2] * adjy
) * (1.0F
/FIXED_SCALE
);
837 vLeft
[u
] = v0
+ (span
.texStepX
[u
][3] * adjx
+ span
.texStepY
[u
][3] * adjy
) * (1.0F
/FIXED_SCALE
);
838 dsOuter
[u
] = span
.texStepY
[u
][0] + dxOuter
* span
.texStepX
[u
][0];
839 dtOuter
[u
] = span
.texStepY
[u
][1] + dxOuter
* span
.texStepX
[u
][1];
840 duOuter
[u
] = span
.texStepY
[u
][2] + dxOuter
* span
.texStepX
[u
][2];
841 dvOuter
[u
] = span
.texStepY
[u
][3] + dxOuter
* span
.texStepX
[u
][3];
847 if (setupRight
&& eRight
->lines
>0) {
848 fxRightEdge
= eRight
->fsx
- FIXED_EPSILON
;
849 fdxRightEdge
= eRight
->fdxdy
;
857 /* Rasterize setup */
859 dPRowInner
= dPRowOuter
+ sizeof(PIXEL_TYPE
);
863 dZRowInner
= dZRowOuter
+ sizeof(DEPTH_TYPE
);
865 fdzInner
= fdzOuter
+ span
.zStep
;
868 dwInner
= dwOuter
+ span
.dwdx
;
871 dfogInner
= dfogOuter
+ span
.dfogdx
;
873 #if defined(INTERP_RGB)
874 fdrInner
= fdrOuter
+ span
.redStep
;
875 fdgInner
= fdgOuter
+ span
.greenStep
;
876 fdbInner
= fdbOuter
+ span
.blueStep
;
878 #if defined(INTERP_ALPHA)
879 fdaInner
= fdaOuter
+ span
.alphaStep
;
881 #if defined(INTERP_SPEC)
882 dsrInner
= dsrOuter
+ span
.specRedStep
;
883 dsgInner
= dsgOuter
+ span
.specGreenStep
;
884 dsbInner
= dsbOuter
+ span
.specBlueStep
;
887 diInner
= diOuter
+ span
.indexStep
;
889 #ifdef INTERP_INT_TEX
890 dsInner
= dsOuter
+ span
.intTexStep
[0];
891 dtInner
= dtOuter
+ span
.intTexStep
[1];
895 dsInner
[u
] = dsOuter
[u
] + span
.texStepX
[u
][0];
896 dtInner
[u
] = dtOuter
[u
] + span
.texStepX
[u
][1];
897 duInner
[u
] = duOuter
[u
] + span
.texStepX
[u
][2];
898 dvInner
[u
] = dvOuter
[u
] + span
.texStepX
[u
][3];
903 /* initialize the span interpolants to the leftmost value */
904 /* ff = fixed-pt fragment */
905 const GLint right
= FixedToInt(fxRightEdge
);
907 span
.x
= FixedToInt(fxLeftEdge
);
912 span
.end
= right
- span
.x
;
923 #if defined(INTERP_RGB)
928 #if defined(INTERP_ALPHA)
931 #if defined(INTERP_SPEC)
932 span
.specRed
= srLeft
;
933 span
.specGreen
= sgLeft
;
934 span
.specBlue
= sbLeft
;
939 #ifdef INTERP_INT_TEX
940 span
.intTex
[0] = sLeft
;
941 span
.intTex
[1] = tLeft
;
946 span
.tex
[u
][0] = sLeft
[u
];
947 span
.tex
[u
][1] = tLeft
[u
];
948 span
.tex
[u
][2] = uLeft
[u
];
949 span
.tex
[u
][3] = vLeft
[u
];
955 /* need this to accomodate round-off errors */
956 const GLint len
= right
- span
.x
- 1;
957 GLfixed ffrend
= span
.red
+ len
* span
.redStep
;
958 GLfixed ffgend
= span
.green
+ len
* span
.greenStep
;
959 GLfixed ffbend
= span
.blue
+ len
* span
.blueStep
;
966 span
.green
-= ffgend
;
979 const GLint len
= right
- span
.x
- 1;
980 GLfixed ffaend
= span
.alpha
+ len
* span
.alphaStep
;
982 span
.alpha
-= ffaend
;
990 /* need this to accomodate round-off errors */
991 const GLint len
= right
- span
.x
- 1;
992 GLfixed ffsrend
= span
.specRed
+ len
* span
.specRedStep
;
993 GLfixed ffsgend
= span
.specGreen
+ len
* span
.specGreenStep
;
994 GLfixed ffsbend
= span
.specBlue
+ len
* span
.specBlueStep
;
996 span
.specRed
-= ffsrend
;
997 if (span
.specRed
< 0)
1001 span
.specGreen
-= ffsgend
;
1002 if (span
.specGreen
< 0)
1006 span
.specBlue
-= ffsbend
;
1007 if (span
.specBlue
< 0)
1013 if (span
.index
< 0) span
.index
= 0;
1016 /* This is where we actually generate fragments */
1018 RENDER_SPAN( span
);
1022 * Advance to the next scan line. Compute the
1023 * new edge coordinates, and adjust the
1024 * pixel-center x coordinate so that it stays
1025 * on or inside the major edge.
1030 fxLeftEdge
+= fdxLeftEdge
;
1031 fxRightEdge
+= fdxRightEdge
;
1036 fError
-= FIXED_ONE
;
1037 #ifdef PIXEL_ADDRESS
1038 pRow
= (PIXEL_TYPE
*) ((GLubyte
*) pRow
+ dPRowOuter
);
1042 zRow
= (DEPTH_TYPE
*) ((GLubyte
*) zRow
+ dZRowOuter
);
1050 fogLeft
+= dfogOuter
;
1052 #if defined(INTERP_RGB)
1057 #if defined(INTERP_ALPHA)
1060 #if defined(INTERP_SPEC)
1068 #ifdef INTERP_INT_TEX
1074 sLeft
[u
] += dsOuter
[u
];
1075 tLeft
[u
] += dtOuter
[u
];
1076 uLeft
[u
] += duOuter
[u
];
1077 vLeft
[u
] += dvOuter
[u
];
1082 #ifdef PIXEL_ADDRESS
1083 pRow
= (PIXEL_TYPE
*) ((GLubyte
*) pRow
+ dPRowInner
);
1087 zRow
= (DEPTH_TYPE
*) ((GLubyte
*) zRow
+ dZRowInner
);
1095 fogLeft
+= dfogInner
;
1097 #if defined(INTERP_RGB)
1102 #if defined(INTERP_ALPHA)
1105 #if defined(INTERP_SPEC)
1113 #ifdef INTERP_INT_TEX
1119 sLeft
[u
] += dsInner
[u
];
1120 tLeft
[u
] += dtInner
[u
];
1121 uLeft
[u
] += duInner
[u
];
1122 vLeft
[u
] += dvInner
[u
];
1128 } /* for subTriangle */
1142 #undef BYTES_PER_ROW
1143 #undef PIXEL_ADDRESS
1152 #undef INTERP_INT_TEX
1154 #undef INTERP_MULTITEX
1155 #undef TEX_UNIT_LOOP
1162 #undef DO_OCCLUSION_TEST