• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 
26 /*
27  * This file contains "accelerated" triangle functions.  It should be
28  * fairly easy to write new special-purpose triangle functions and hook
29  * them into this module.
30  */
31 
32 
33 #include <stdio.h>
34 #include "c99_math.h"
35 #include "main/imports.h"
36 #include "main/mtypes.h"
37 #include "glxheader.h"
38 #include "xmesaP.h"
39 
40 /* Internal swrast includes:
41  */
42 #include "swrast/s_context.h"
43 #include "swrast/s_depth.h"
44 #include "swrast/s_triangle.h"
45 
46 
47 #define GET_XRB(XRB)  struct xmesa_renderbuffer *XRB = \
48    xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0])
49 
50 
51 /**********************************************************************/
52 /***                   Triangle rendering                           ***/
53 /**********************************************************************/
54 
55 
56 #if CHAN_BITS == 8
57 
58 /*
59  * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
60  */
61 #define NAME smooth_TRUECOLOR_z_triangle
62 #define INTERP_Z 1
63 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
64 #define INTERP_RGB 1
65 #define SETUP_CODE						\
66    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
67    GET_XRB(xrb);
68 
69 #define RENDER_SPAN( span ) {					\
70    GLint x = span.x, y = YFLIP(xrb, span.y);			\
71    GLuint i;							\
72    for (i = 0; i < span.end; i++, x++) {			\
73       const DEPTH_TYPE z = FixedToDepth(span.z);		\
74       if (z < zRow[i]) {					\
75          unsigned long p;					\
76          PACK_TRUECOLOR(p, FixedToInt(span.red),		\
77             FixedToInt(span.green), FixedToInt(span.blue));	\
78          XMesaPutPixel(xrb->ximage, x, y, p);			\
79          zRow[i] = z;						\
80       }								\
81       span.red += span.redStep;					\
82       span.green += span.greenStep;				\
83       span.blue += span.blueStep;				\
84       span.z += span.zStep;					\
85    } }
86 
87 #include "swrast/s_tritemp.h"
88 
89 
90 
91 
92 /*
93  * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
94  */
95 #define NAME smooth_8A8B8G8R_z_triangle
96 #define INTERP_Z 1
97 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
98 #define INTERP_RGB 1
99 #define INTERP_ALPHA 1
100 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
101 #define PIXEL_TYPE GLuint
102 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
103 #define SETUP_CODE						\
104    GET_XRB(xrb);
105 #define RENDER_SPAN( span ) {					\
106    GLuint i;							\
107    for (i = 0; i < span.end; i++) {				\
108       const DEPTH_TYPE z = FixedToDepth(span.z);		\
109       if (z < zRow[i]) {					\
110          pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red),		\
111             FixedToInt(span.green), FixedToInt(span.blue),	\
112             FixedToInt(span.alpha));				\
113          zRow[i] = z;						\
114       }								\
115       span.red += span.redStep;					\
116       span.green += span.greenStep;				\
117       span.blue += span.blueStep;				\
118       span.alpha += span.alphaStep;				\
119       span.z += span.zStep;					\
120    } }
121 
122 #include "swrast/s_tritemp.h"
123 
124 
125 
126 /*
127  * XImage, smooth, depth-buffered, PF_8A8R8G8B triangle.
128  */
129 #define NAME smooth_8A8R8G8B_z_triangle
130 #define INTERP_Z 1
131 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
132 #define INTERP_RGB 1
133 #define INTERP_ALPHA 1
134 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
135 #define PIXEL_TYPE GLuint
136 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
137 #define SETUP_CODE						\
138    GET_XRB(xrb);
139 
140 #define RENDER_SPAN( span ) {					\
141    GLuint i;							\
142    for (i = 0; i < span.end; i++) {				\
143       const DEPTH_TYPE z = FixedToDepth(span.z);		\
144       if (z < zRow[i]) {					\
145          pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red),		\
146             FixedToInt(span.green), FixedToInt(span.blue),	\
147             FixedToInt(span.alpha));				\
148          zRow[i] = z;						\
149       }								\
150       span.red += span.redStep;					\
151       span.green += span.greenStep;				\
152       span.blue += span.blueStep;				\
153       span.alpha += span.alphaStep;				\
154       span.z += span.zStep;					\
155    } }
156 
157 #include "swrast/s_tritemp.h"
158 
159 
160 
161 /*
162  * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
163  */
164 #define NAME smooth_8R8G8B_z_triangle
165 #define INTERP_Z 1
166 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
167 #define INTERP_RGB 1
168 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
169 #define PIXEL_TYPE GLuint
170 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
171 #define SETUP_CODE						\
172    GET_XRB(xrb);
173 
174 #define RENDER_SPAN( span ) {					\
175    GLuint i;							\
176    for (i = 0; i < span.end; i++) {				\
177       const DEPTH_TYPE z = FixedToDepth(span.z);		\
178       if (z < zRow[i]) {					\
179          pRow[i] = PACK_8R8G8B(FixedToInt(span.red),		\
180             FixedToInt(span.green), FixedToInt(span.blue));	\
181          zRow[i] = z;						\
182       }								\
183       span.red += span.redStep;					\
184       span.green += span.greenStep;				\
185       span.blue += span.blueStep;				\
186       span.z += span.zStep;					\
187    } }
188 
189 #include "swrast/s_tritemp.h"
190 
191 
192 
193 /*
194  * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
195  */
196 #define NAME smooth_8R8G8B24_z_triangle
197 #define INTERP_Z 1
198 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
199 #define INTERP_RGB 1
200 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
201 #define PIXEL_TYPE bgr_t
202 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
203 #define SETUP_CODE						\
204    GET_XRB(xrb);
205 #define RENDER_SPAN( span ) {					\
206    GLuint i;							\
207    for (i = 0; i < span.end; i++) {				\
208       const DEPTH_TYPE z = FixedToDepth(span.z);		\
209       if (z < zRow[i]) {					\
210 	 PIXEL_TYPE *ptr = pRow + i;				\
211          ptr->r = FixedToInt(span.red);				\
212          ptr->g = FixedToInt(span.green);			\
213          ptr->b = FixedToInt(span.blue);			\
214          zRow[i] = z;						\
215       }								\
216       span.red += span.redStep;					\
217       span.green += span.greenStep;				\
218       span.blue += span.blueStep;				\
219       span.z += span.zStep;					\
220    } }
221 #include "swrast/s_tritemp.h"
222 
223 
224 
225 /*
226  * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
227  */
228 #define NAME smooth_TRUEDITHER_z_triangle
229 #define INTERP_Z 1
230 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
231 #define INTERP_RGB 1
232 #define SETUP_CODE						\
233    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
234    GET_XRB(xrb);
235 #define RENDER_SPAN( span ) {					\
236    GLuint i;							\
237    GLint x = span.x, y = YFLIP(xrb, span.y);			\
238    for (i = 0; i < span.end; i++, x++) {			\
239       const DEPTH_TYPE z = FixedToDepth(span.z);		\
240       if (z < zRow[i]) {					\
241          unsigned long p;					\
242          PACK_TRUEDITHER(p, x, y, FixedToInt(span.red),		\
243             FixedToInt(span.green), FixedToInt(span.blue));	\
244          XMesaPutPixel(xrb->ximage, x, y, p);			\
245          zRow[i] = z;						\
246       }								\
247       span.red += span.redStep;					\
248       span.green += span.greenStep;				\
249       span.blue += span.blueStep;				\
250       span.z += span.zStep;					\
251    } }
252 #include "swrast/s_tritemp.h"
253 
254 
255 
256 /*
257  * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
258  */
259 #define NAME smooth_5R6G5B_z_triangle
260 #define INTERP_Z 1
261 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
262 #define INTERP_RGB 1
263 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
264 #define PIXEL_TYPE GLushort
265 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
266 #define SETUP_CODE						\
267    GET_XRB(xrb);
268 #define RENDER_SPAN( span ) {					\
269    GLuint i;							\
270    for (i = 0; i < span.end; i++) {				\
271       const DEPTH_TYPE z = FixedToDepth(span.z);		\
272       if (z < zRow[i]) {					\
273          pRow[i] = PACK_5R6G5B(FixedToInt(span.red),		\
274             FixedToInt(span.green), FixedToInt(span.blue));	\
275          zRow[i] = z;						\
276       }								\
277       span.red += span.redStep;					\
278       span.green += span.greenStep;				\
279       span.blue += span.blueStep;				\
280       span.z += span.zStep;					\
281    } }
282 #include "swrast/s_tritemp.h"
283 
284 
285 
286 /*
287  * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
288  */
289 #define NAME smooth_DITHER_5R6G5B_z_triangle
290 #define INTERP_Z 1
291 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
292 #define INTERP_RGB 1
293 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
294 #define PIXEL_TYPE GLushort
295 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
296 #define SETUP_CODE						\
297    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
298    GET_XRB(xrb);
299 #define RENDER_SPAN( span ) {					\
300    GLuint i;							\
301    GLint x = span.x, y = YFLIP(xrb, span.y);			\
302    for (i = 0; i < span.end; i++, x++) {			\
303       const DEPTH_TYPE z = FixedToDepth(span.z);		\
304       if (z < zRow[i]) {					\
305          PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red),	\
306             FixedToInt(span.green), FixedToInt(span.blue));	\
307          zRow[i] = z;						\
308       }								\
309       span.red += span.redStep;					\
310       span.green += span.greenStep;				\
311       span.blue += span.blueStep;				\
312       span.z += span.zStep;					\
313    } }
314 #include "swrast/s_tritemp.h"
315 
316 
317 
318 /*
319  * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
320  */
321 #define NAME flat_TRUECOLOR_z_triangle
322 #define INTERP_Z 1
323 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
324 #define SETUP_CODE						\
325    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
326    GET_XRB(xrb);						\
327    XMesaImage *img = xrb->ximage;				\
328    unsigned long pixel;						\
329    PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
330 #define RENDER_SPAN( span ) {					\
331    GLuint i;							\
332    GLint x = span.x, y = YFLIP(xrb, span.y);			\
333    for (i = 0; i < span.end; i++, x++) {			\
334       const DEPTH_TYPE z = FixedToDepth(span.z);		\
335       if (z < zRow[i]) {					\
336          XMesaPutPixel(img, x, y, pixel);			\
337          zRow[i] = z;						\
338       }								\
339       span.z += span.zStep;					\
340    } }
341 #include "swrast/s_tritemp.h"
342 
343 
344 
345 /*
346  * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
347  */
348 #define NAME flat_8A8B8G8R_z_triangle
349 #define INTERP_Z 1
350 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
351 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
352 #define PIXEL_TYPE GLuint
353 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
354 #define SETUP_CODE					\
355    GET_XRB(xrb);					\
356    GLuint p = PACK_8A8B8G8R( v2->color[0], v2->color[1],\
357                              v2->color[2], v2->color[3]);
358 #define RENDER_SPAN( span ) {				\
359    GLuint i;						\
360    for (i = 0; i < span.end; i++) {			\
361       const DEPTH_TYPE z = FixedToDepth(span.z);	\
362       if (z < zRow[i]) {				\
363 	 pRow[i] = (PIXEL_TYPE) p;			\
364          zRow[i] = z;					\
365       }							\
366       span.z += span.zStep;				\
367    } }
368 #include "swrast/s_tritemp.h"
369 
370 
371 
372 /*
373  * XImage, flat, depth-buffered, PF_8A8R8G8B triangle.
374  */
375 #define NAME flat_8A8R8G8B_z_triangle
376 #define INTERP_Z 1
377 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
378 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
379 #define PIXEL_TYPE GLuint
380 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
381 #define SETUP_CODE					\
382    GET_XRB(xrb);					\
383    GLuint p = PACK_8A8R8G8B(v2->color[0], v2->color[1],	\
384                             v2->color[2], v2->color[3]);
385 #define RENDER_SPAN( span ) {				\
386    GLuint i;						\
387    for (i = 0; i < span.end; i++) {			\
388       const DEPTH_TYPE z = FixedToDepth(span.z);	\
389       if (z < zRow[i]) {				\
390 	 pRow[i] = (PIXEL_TYPE) p;			\
391          zRow[i] = z;					\
392       }							\
393       span.z += span.zStep;				\
394    } }
395 #include "swrast/s_tritemp.h"
396 
397 
398 
399 /*
400  * XImage, flat, depth-buffered, PF_8R8G8B triangle.
401  */
402 #define NAME flat_8R8G8B_z_triangle
403 #define INTERP_Z 1
404 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
405 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
406 #define PIXEL_TYPE GLuint
407 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
408 #define SETUP_CODE					\
409    GET_XRB(xrb);					\
410    GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
411 #define RENDER_SPAN( span ) {			\
412    GLuint i;					\
413    for (i = 0; i < span.end; i++) {		\
414       DEPTH_TYPE z = FixedToDepth(span.z);	\
415       if (z < zRow[i]) {			\
416 	 pRow[i] = (PIXEL_TYPE) p;		\
417          zRow[i] = z;				\
418       }						\
419       span.z += span.zStep;			\
420    } }
421 
422 #include "swrast/s_tritemp.h"
423 
424 
425 
426 /*
427  * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
428  */
429 #define NAME flat_8R8G8B24_z_triangle
430 #define INTERP_Z 1
431 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
432 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
433 #define PIXEL_TYPE bgr_t
434 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
435 #define SETUP_CODE					\
436    GET_XRB(xrb);					\
437    const GLubyte *color = v2->color;
438 #define RENDER_SPAN( span ) {				\
439    GLuint i;						\
440    for (i = 0; i < span.end; i++) {			\
441       const DEPTH_TYPE z = FixedToDepth(span.z);	\
442       if (z < zRow[i]) {				\
443 	 PIXEL_TYPE *ptr = pRow + i;			\
444          ptr->r = color[RCOMP];				\
445          ptr->g = color[GCOMP];				\
446          ptr->b = color[BCOMP];				\
447          zRow[i] = z;					\
448       }							\
449       span.z += span.zStep;				\
450    } }
451 #include "swrast/s_tritemp.h"
452 
453 
454 
455 /*
456  * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
457  */
458 #define NAME flat_TRUEDITHER_z_triangle
459 #define INTERP_Z 1
460 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
461 #define SETUP_CODE						\
462    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
463    GET_XRB(xrb);						\
464    XMesaImage *img = xrb->ximage;
465 #define RENDER_SPAN( span ) {					\
466    GLuint i;							\
467    GLint x = span.x, y = YFLIP(xrb, span.y);			\
468    for (i = 0; i < span.end; i++, x++) {			\
469       const DEPTH_TYPE z = FixedToDepth(span.z);		\
470       if (z < zRow[i]) {					\
471          unsigned long p;					\
472          PACK_TRUEDITHER(p, x, y, v2->color[0],			\
473             v2->color[1], v2->color[2]);			\
474          XMesaPutPixel(img, x, y, p);				\
475          zRow[i] = z;						\
476       }								\
477       span.z += span.zStep;					\
478    } }
479 #include "swrast/s_tritemp.h"
480 
481 
482 
483 /*
484  * XImage, flat, depth-buffered, PF_5R6G5B triangle.
485  */
486 #define NAME flat_5R6G5B_z_triangle
487 #define INTERP_Z 1
488 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
489 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
490 #define PIXEL_TYPE GLushort
491 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
492 #define SETUP_CODE					\
493    GET_XRB(xrb);					\
494    GLushort p = PACK_5R6G5B( v2->color[0], v2->color[1], v2->color[2] );
495 #define RENDER_SPAN( span ) {				\
496    GLuint i;						\
497    for (i = 0; i < span.end; i++) {			\
498       const DEPTH_TYPE z = FixedToDepth(span.z);	\
499       if (z < zRow[i]) {				\
500 	 pRow[i] = (PIXEL_TYPE) p;			\
501          zRow[i] = z;					\
502       }							\
503       span.z += span.zStep;				\
504    } }
505 #include "swrast/s_tritemp.h"
506 
507 
508 
509 /*
510  * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
511  */
512 #define NAME flat_DITHER_5R6G5B_z_triangle
513 #define INTERP_Z 1
514 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
515 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
516 #define PIXEL_TYPE GLushort
517 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
518 #define SETUP_CODE						\
519    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
520    GET_XRB(xrb);						\
521    const GLubyte *color = v2->color;
522 #define RENDER_SPAN( span ) {					\
523    GLuint i;							\
524    GLint x = span.x, y = YFLIP(xrb, span.y);			\
525    for (i = 0; i < span.end; i++, x++) {			\
526       const DEPTH_TYPE z = FixedToDepth(span.z);		\
527       if (z < zRow[i]) {					\
528 	 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP],		\
529 			 color[GCOMP], color[BCOMP]);		\
530          zRow[i] = z;						\
531       }								\
532       span.z += span.zStep;					\
533    } }
534 #include "swrast/s_tritemp.h"
535 
536 
537 /*
538  * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
539  */
540 #define NAME smooth_TRUECOLOR_triangle
541 #define INTERP_RGB 1
542 #define SETUP_CODE						\
543    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
544    GET_XRB(xrb);						\
545    XMesaImage *img = xrb->ximage;
546 #define RENDER_SPAN( span ) {					\
547    GLuint i;							\
548    GLint x = span.x, y = YFLIP(xrb, span.y);	\
549    for (i = 0; i < span.end; i++, x++) {			\
550       unsigned long p;						\
551       PACK_TRUECOLOR(p, FixedToInt(span.red),			\
552          FixedToInt(span.green), FixedToInt(span.blue));	\
553       XMesaPutPixel(img, x, y, p);				\
554       span.red += span.redStep;					\
555       span.green += span.greenStep;				\
556       span.blue += span.blueStep;				\
557    } }
558 #include "swrast/s_tritemp.h"
559 
560 
561 
562 /*
563  * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
564  */
565 #define NAME smooth_8A8B8G8R_triangle
566 #define INTERP_RGB 1
567 #define INTERP_ALPHA 1
568 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
569 #define PIXEL_TYPE GLuint
570 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
571 #define SETUP_CODE						\
572    GET_XRB(xrb);
573 #define RENDER_SPAN( span ) {					\
574    GLuint i;							\
575    for (i = 0; i < span.end; i++) {				\
576       pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red),		\
577          FixedToInt(span.green), FixedToInt(span.blue),		\
578          FixedToInt(span.alpha));				\
579       span.red += span.redStep;					\
580       span.green += span.greenStep;				\
581       span.blue += span.blueStep;				\
582       span.alpha += span.alphaStep;				\
583    } }
584 #include "swrast/s_tritemp.h"
585 
586 
587 
588 /*
589  * XImage, smooth, NON-depth-buffered, PF_8A8R8G8B triangle.
590  */
591 #define NAME smooth_8A8R8G8B_triangle
592 #define INTERP_RGB 1
593 #define INTERP_ALPHA 1
594 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
595 #define PIXEL_TYPE GLuint
596 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
597 #define SETUP_CODE						\
598    GET_XRB(xrb);
599 #define RENDER_SPAN( span ) {					\
600    GLuint i;							\
601    for (i = 0; i < span.end; i++) {				\
602       pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red),		\
603          FixedToInt(span.green), FixedToInt(span.blue),		\
604          FixedToInt(span.alpha));				\
605       span.red += span.redStep;					\
606       span.green += span.greenStep;				\
607       span.blue += span.blueStep;				\
608       span.alpha += span.alphaStep;				\
609    } }
610 #include "swrast/s_tritemp.h"
611 
612 
613 
614 /*
615  * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
616  */
617 #define NAME smooth_8R8G8B_triangle
618 #define INTERP_RGB 1
619 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
620 #define PIXEL_TYPE GLuint
621 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
622 #define SETUP_CODE						\
623    GET_XRB(xrb);
624 #define RENDER_SPAN( span ) {					\
625    GLuint i;							\
626    for (i = 0; i < span.end; i++) {				\
627       pRow[i] = PACK_8R8G8B(FixedToInt(span.red),		\
628          FixedToInt(span.green), FixedToInt(span.blue) );	\
629       span.red += span.redStep;					\
630       span.green += span.greenStep;				\
631       span.blue += span.blueStep;				\
632    } }
633 #include "swrast/s_tritemp.h"
634 
635 
636 
637 /*
638  * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
639  */
640 #define NAME smooth_8R8G8B24_triangle
641 #define INTERP_RGB 1
642 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
643 #define PIXEL_TYPE bgr_t
644 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
645 #define SETUP_CODE					\
646    GET_XRB(xrb);
647 #define RENDER_SPAN( span ) {				\
648    GLuint i;						\
649    PIXEL_TYPE *pixel = pRow;				\
650    for (i = 0; i < span.end; i++, pixel++) {		\
651       pixel->r = FixedToInt(span.red);			\
652       pixel->g = FixedToInt(span.green);		\
653       pixel->b = FixedToInt(span.blue);			\
654       span.red += span.redStep;				\
655       span.green += span.greenStep;			\
656       span.blue += span.blueStep;			\
657    } }
658 #include "swrast/s_tritemp.h"
659 
660 
661 
662 /*
663  * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
664  */
665 #define NAME smooth_TRUEDITHER_triangle
666 #define INTERP_RGB 1
667 #define SETUP_CODE						\
668    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
669    GET_XRB(xrb);						\
670    XMesaImage *img = xrb->ximage;
671 #define RENDER_SPAN( span ) {					\
672    GLuint i;							\
673    GLint x = span.x, y = YFLIP(xrb, span.y);	\
674    for (i = 0; i < span.end; i++, x++) {			\
675       unsigned long p;						\
676       PACK_TRUEDITHER(p, x, y, FixedToInt(span.red),		\
677          FixedToInt(span.green), FixedToInt(span.blue));	\
678       XMesaPutPixel(img, x, y, p );				\
679       span.red += span.redStep;					\
680       span.green += span.greenStep;				\
681       span.blue += span.blueStep;				\
682    } }
683 #include "swrast/s_tritemp.h"
684 
685 
686 
687 /*
688  * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
689  */
690 #define NAME smooth_5R6G5B_triangle
691 #define INTERP_RGB 1
692 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
693 #define PIXEL_TYPE GLushort
694 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
695 #define SETUP_CODE						\
696    GET_XRB(xrb);
697 #define RENDER_SPAN( span ) {					\
698    GLuint i;							\
699    for (i = 0; i < span.end; i++) {				\
700       pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span.red),	\
701          FixedToInt(span.green), FixedToInt(span.blue));	\
702       span.red += span.redStep;					\
703       span.green += span.greenStep;				\
704       span.blue += span.blueStep;				\
705    } }
706 #include "swrast/s_tritemp.h"
707 
708 
709 
710 /*
711  * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
712  */
713 #define NAME smooth_DITHER_5R6G5B_triangle
714 #define INTERP_RGB 1
715 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
716 #define PIXEL_TYPE GLushort
717 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
718 #define SETUP_CODE						\
719    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
720    GET_XRB(xrb);
721 #define RENDER_SPAN( span ) {					\
722    GLuint i;							\
723    GLint x = span.x, y = YFLIP(xrb, span.y);	\
724    for (i = 0; i < span.end; i++, x++) {			\
725       PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red),	\
726          FixedToInt(span.green), FixedToInt(span.blue));	\
727       span.red += span.redStep;					\
728       span.green += span.greenStep;				\
729       span.blue += span.blueStep;				\
730    } }
731 #include "swrast/s_tritemp.h"
732 
733 
734 
735 /*
736  * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
737  */
738 #define NAME flat_TRUECOLOR_triangle
739 #define SETUP_CODE						\
740    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
741    GET_XRB(xrb);						\
742    XMesaImage *img = xrb->ximage;				\
743    unsigned long pixel;						\
744    PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
745 #define RENDER_SPAN( span ) {					\
746    GLuint i;							\
747    GLint x = span.x, y = YFLIP(xrb, span.y);	\
748    for (i = 0; i < span.end; i++, x++) {			\
749       XMesaPutPixel(img, x, y, pixel);				\
750    } }
751 #include "swrast/s_tritemp.h"
752 
753 
754 
755 /*
756  * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
757  */
758 #define NAME flat_8A8B8G8R_triangle
759 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
760 #define PIXEL_TYPE GLuint
761 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
762 #define SETUP_CODE					\
763    GET_XRB(xrb);					\
764    unsigned long p = PACK_8B8G8R( v2->color[0],		\
765 		 v2->color[1], v2->color[2] );
766 #define RENDER_SPAN( span ) {				\
767    GLuint i;						\
768    for (i = 0; i < span.end; i++) {			\
769       pRow[i] = (PIXEL_TYPE) p;				\
770    } }
771 #include "swrast/s_tritemp.h"
772 
773 
774 
775 /*
776  * XImage, flat, NON-depth-buffered, PF_8A8R8G8B triangle.
777  */
778 #define NAME flat_8A8R8G8B_triangle
779 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
780 #define PIXEL_TYPE GLuint
781 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
782 #define SETUP_CODE					\
783    GET_XRB(xrb);					\
784    unsigned long p = PACK_8R8G8B( v2->color[0],		\
785 		 v2->color[1], v2->color[2] );
786 #define RENDER_SPAN( span ) {				\
787    GLuint i;						\
788    for (i = 0; i < span.end; i++) {			\
789       pRow[i] = (PIXEL_TYPE) p;				\
790    } }
791 #include "swrast/s_tritemp.h"
792 
793 
794 
795 /*
796  * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
797  */
798 #define NAME flat_8R8G8B_triangle
799 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
800 #define PIXEL_TYPE GLuint
801 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
802 #define SETUP_CODE					\
803    GET_XRB(xrb);					\
804    unsigned long p = PACK_8R8G8B( v2->color[0],		\
805 		 v2->color[1], v2->color[2] );
806 #define RENDER_SPAN( span ) {				\
807    GLuint i;						\
808    for (i = 0; i < span.end; i++) {			\
809       pRow[i] = (PIXEL_TYPE) p;				\
810    } }
811 #include "swrast/s_tritemp.h"
812 
813 
814 
815 /*
816  * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
817  */
818 #define NAME flat_8R8G8B24_triangle
819 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
820 #define PIXEL_TYPE bgr_t
821 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
822 #define SETUP_CODE					\
823    GET_XRB(xrb);					\
824    const GLubyte *color = v2->color;
825 #define RENDER_SPAN( span ) {				\
826    GLuint i;						\
827    PIXEL_TYPE *pixel = pRow;				\
828    for (i = 0; i < span.end; i++, pixel++) {		\
829       pixel->r = color[RCOMP];				\
830       pixel->g = color[GCOMP];				\
831       pixel->b = color[BCOMP];				\
832    } }
833 #include "swrast/s_tritemp.h"
834 
835 
836 
837 /*
838  * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
839  */
840 #define NAME flat_TRUEDITHER_triangle
841 #define SETUP_CODE						\
842    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
843    GET_XRB(xrb);						\
844    XMesaImage *img = xrb->ximage;
845 #define RENDER_SPAN( span ) {					\
846    GLuint i;							\
847    GLint x = span.x, y = YFLIP(xrb, span.y);	\
848    for (i = 0; i < span.end; i++, x++) {			\
849       unsigned long p;						\
850       PACK_TRUEDITHER(p, x, y, v2->color[0],			\
851                v2->color[1], v2->color[2] );			\
852       XMesaPutPixel(img, x, y, p);				\
853    } }
854 #include "swrast/s_tritemp.h"
855 
856 
857 
858 /*
859  * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
860  */
861 #define NAME flat_5R6G5B_triangle
862 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
863 #define PIXEL_TYPE GLushort
864 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
865 #define SETUP_CODE					\
866    GET_XRB(xrb);					\
867    unsigned long p = PACK_5R6G5B( v2->color[0],		\
868 		 v2->color[1], v2->color[2] );
869 #define RENDER_SPAN( span ) {				\
870    GLuint i;						\
871    for (i = 0; i < span.end; i++) {			\
872       pRow[i] = (PIXEL_TYPE) p;				\
873    } }
874 #include "swrast/s_tritemp.h"
875 
876 
877 
878 /*
879  * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
880  */
881 #define NAME flat_DITHER_5R6G5B_triangle
882 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
883 #define PIXEL_TYPE GLushort
884 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
885 #define SETUP_CODE						\
886    XMesaContext xmesa = XMESA_CONTEXT(ctx);			\
887    GET_XRB(xrb);						\
888    const GLubyte *color = v2->color;
889 #define RENDER_SPAN( span ) {					\
890    GLuint i;							\
891    GLint x = span.x, y = YFLIP(xrb, span.y);	\
892    for (i = 0; i < span.end; i++, x++) {			\
893       PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP],		\
894          color[GCOMP], color[BCOMP]);				\
895    } }
896 #include "swrast/s_tritemp.h"
897 
898 
899 
900 #endif /* CHAN_BITS == 8 */
901 
902 
903 #if defined(DEBUG) && CHAN_BITS == 8
904 extern void _xmesa_print_triangle_func( swrast_tri_func triFunc );
_xmesa_print_triangle_func(swrast_tri_func triFunc)905 void _xmesa_print_triangle_func( swrast_tri_func triFunc )
906 {
907    printf("XMesa tri func = ");
908    if (triFunc ==smooth_TRUECOLOR_z_triangle)
909       printf("smooth_TRUECOLOR_z_triangle\n");
910    else if (triFunc ==smooth_8A8B8G8R_z_triangle)
911       printf("smooth_8A8B8G8R_z_triangle\n");
912    else if (triFunc ==smooth_8A8R8G8B_z_triangle)
913       printf("smooth_8A8R8G8B_z_triangle\n");
914    else if (triFunc ==smooth_8R8G8B_z_triangle)
915       printf("smooth_8R8G8B_z_triangle\n");
916    else if (triFunc ==smooth_8R8G8B24_z_triangle)
917       printf("smooth_8R8G8B24_z_triangle\n");
918    else if (triFunc ==smooth_TRUEDITHER_z_triangle)
919       printf("smooth_TRUEDITHER_z_triangle\n");
920    else if (triFunc ==smooth_5R6G5B_z_triangle)
921       printf("smooth_5R6G5B_z_triangle\n");
922    else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle)
923       printf("smooth_DITHER_5R6G5B_z_triangle\n");
924    else if (triFunc ==flat_TRUECOLOR_z_triangle)
925       printf("flat_TRUECOLOR_z_triangle\n");
926    else if (triFunc ==flat_8A8B8G8R_z_triangle)
927       printf("flat_8A8B8G8R_z_triangle\n");
928    else if (triFunc ==flat_8A8R8G8B_z_triangle)
929       printf("flat_8A8R8G8B_z_triangle\n");
930    else if (triFunc ==flat_8R8G8B_z_triangle)
931       printf("flat_8R8G8B_z_triangle\n");
932    else if (triFunc ==flat_8R8G8B24_z_triangle)
933       printf("flat_8R8G8B24_z_triangle\n");
934    else if (triFunc ==flat_TRUEDITHER_z_triangle)
935       printf("flat_TRUEDITHER_z_triangle\n");
936    else if (triFunc ==flat_5R6G5B_z_triangle)
937       printf("flat_5R6G5B_z_triangle\n");
938    else if (triFunc ==flat_DITHER_5R6G5B_z_triangle)
939       printf("flat_DITHER_5R6G5B_z_triangle\n");
940    else if (triFunc ==smooth_TRUECOLOR_triangle)
941       printf("smooth_TRUECOLOR_triangle\n");
942    else if (triFunc ==smooth_8A8B8G8R_triangle)
943       printf("smooth_8A8B8G8R_triangle\n");
944    else if (triFunc ==smooth_8A8R8G8B_triangle)
945       printf("smooth_8A8R8G8B_triangle\n");
946    else if (triFunc ==smooth_8R8G8B_triangle)
947       printf("smooth_8R8G8B_triangle\n");
948    else if (triFunc ==smooth_8R8G8B24_triangle)
949       printf("smooth_8R8G8B24_triangle\n");
950    else if (triFunc ==smooth_TRUEDITHER_triangle)
951       printf("smooth_TRUEDITHER_triangle\n");
952    else if (triFunc ==smooth_5R6G5B_triangle)
953       printf("smooth_5R6G5B_triangle\n");
954    else if (triFunc ==smooth_DITHER_5R6G5B_triangle)
955       printf("smooth_DITHER_5R6G5B_triangle\n");
956    else if (triFunc ==flat_TRUECOLOR_triangle)
957       printf("flat_TRUECOLOR_triangle\n");
958    else if (triFunc ==flat_TRUEDITHER_triangle)
959       printf("flat_TRUEDITHER_triangle\n");
960    else if (triFunc ==flat_8A8B8G8R_triangle)
961       printf("flat_8A8B8G8R_triangle\n");
962    else if (triFunc ==flat_8A8R8G8B_triangle)
963       printf("flat_8A8R8G8B_triangle\n");
964    else if (triFunc ==flat_8R8G8B_triangle)
965       printf("flat_8R8G8B_triangle\n");
966    else if (triFunc ==flat_8R8G8B24_triangle)
967       printf("flat_8R8G8B24_triangle\n");
968    else if (triFunc ==flat_5R6G5B_triangle)
969       printf("flat_5R6G5B_triangle\n");
970    else if (triFunc ==flat_DITHER_5R6G5B_triangle)
971       printf("flat_DITHER_5R6G5B_triangle\n");
972    else
973       printf("???\n");
974 }
975 #endif
976 
977 
978 #ifdef DEBUG
979 
980 /* record the current triangle function name */
981 static const char *triFuncName = NULL;
982 
983 #define USE(triFunc)                   \
984 do {                                   \
985     triFuncName = #triFunc;            \
986     return triFunc;                    \
987 } while (0)
988 
989 #else
990 
991 #define USE(triFunc)  return triFunc
992 
993 #endif
994 
995 
996 /**
997  * Return pointer to line drawing function, or NULL if we should use a
998  * swrast fallback.
999  */
1000 static swrast_tri_func
get_triangle_func(struct gl_context * ctx)1001 get_triangle_func(struct gl_context *ctx)
1002 {
1003 #if CHAN_BITS == 8
1004    SWcontext *swrast = SWRAST_CONTEXT(ctx);
1005    XMesaContext xmesa = XMESA_CONTEXT(ctx);
1006    const struct xmesa_renderbuffer *xrb;
1007 
1008 #ifdef DEBUG
1009    triFuncName = NULL;
1010 #endif
1011 
1012    /* trivial fallback tests */
1013    if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) &&
1014        (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT))
1015       return (swrast_tri_func) NULL;
1016    if (ctx->RenderMode != GL_RENDER)
1017       return (swrast_tri_func) NULL;
1018    if (ctx->Polygon.SmoothFlag)
1019       return (swrast_tri_func) NULL;
1020    if (ctx->Texture._MaxEnabledTexImageUnit != -1)
1021       return (swrast_tri_func) NULL;
1022    if (swrast->_RasterMask & MULTI_DRAW_BIT)
1023       return (swrast_tri_func) NULL;
1024    if (ctx->Polygon.CullFlag &&
1025        ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
1026       return (swrast_tri_func) NULL;
1027 
1028    xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
1029 
1030    if (xrb->ximage) {
1031       if (   ctx->Light.ShadeModel==GL_SMOOTH
1032           && swrast->_RasterMask==DEPTH_BIT
1033           && ctx->Depth.Func==GL_LESS
1034           && ctx->Depth.Mask==GL_TRUE
1035           && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
1036           && ctx->Polygon.StippleFlag==GL_FALSE) {
1037          switch (xmesa->pixelformat) {
1038             case PF_Truecolor:
1039 	       USE(smooth_TRUECOLOR_z_triangle);
1040             case PF_8A8B8G8R:
1041                USE(smooth_8A8B8G8R_z_triangle);
1042             case PF_8A8R8G8B:
1043                USE(smooth_8A8R8G8B_z_triangle);
1044             case PF_8R8G8B:
1045                USE(smooth_8R8G8B_z_triangle);
1046             case PF_8R8G8B24:
1047                USE(smooth_8R8G8B24_z_triangle);
1048             case PF_Dither_True:
1049                USE(smooth_TRUEDITHER_z_triangle);
1050             case PF_5R6G5B:
1051                USE(smooth_5R6G5B_z_triangle);
1052             case PF_Dither_5R6G5B:
1053                USE(smooth_DITHER_5R6G5B_z_triangle);
1054             default:
1055                return (swrast_tri_func) NULL;
1056          }
1057       }
1058       if (   ctx->Light.ShadeModel==GL_FLAT
1059           && swrast->_RasterMask==DEPTH_BIT
1060           && ctx->Depth.Func==GL_LESS
1061           && ctx->Depth.Mask==GL_TRUE
1062           && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
1063           && ctx->Polygon.StippleFlag==GL_FALSE) {
1064          switch (xmesa->pixelformat) {
1065             case PF_Truecolor:
1066 	       USE(flat_TRUECOLOR_z_triangle);
1067             case PF_8A8B8G8R:
1068                USE(flat_8A8B8G8R_z_triangle);
1069             case PF_8A8R8G8B:
1070                USE(flat_8A8R8G8B_z_triangle);
1071             case PF_8R8G8B:
1072                USE(flat_8R8G8B_z_triangle);
1073             case PF_8R8G8B24:
1074                USE(flat_8R8G8B24_z_triangle);
1075             case PF_Dither_True:
1076                USE(flat_TRUEDITHER_z_triangle);
1077             case PF_5R6G5B:
1078                USE(flat_5R6G5B_z_triangle);
1079             case PF_Dither_5R6G5B:
1080                USE(flat_DITHER_5R6G5B_z_triangle);
1081             default:
1082                return (swrast_tri_func) NULL;
1083          }
1084       }
1085       if (   swrast->_RasterMask==0   /* no depth test */
1086           && ctx->Light.ShadeModel==GL_SMOOTH
1087           && ctx->Polygon.StippleFlag==GL_FALSE) {
1088          switch (xmesa->pixelformat) {
1089             case PF_Truecolor:
1090 	       USE(smooth_TRUECOLOR_triangle);
1091             case PF_8A8B8G8R:
1092                USE(smooth_8A8B8G8R_triangle);
1093             case PF_8A8R8G8B:
1094                USE(smooth_8A8R8G8B_triangle);
1095             case PF_8R8G8B:
1096                USE(smooth_8R8G8B_triangle);
1097             case PF_8R8G8B24:
1098                USE(smooth_8R8G8B24_triangle);
1099             case PF_Dither_True:
1100                USE(smooth_TRUEDITHER_triangle);
1101             case PF_5R6G5B:
1102                USE(smooth_5R6G5B_triangle);
1103             case PF_Dither_5R6G5B:
1104                USE(smooth_DITHER_5R6G5B_triangle);
1105             default:
1106                return (swrast_tri_func) NULL;
1107          }
1108       }
1109 
1110       if (   swrast->_RasterMask==0   /* no depth test */
1111           && ctx->Light.ShadeModel==GL_FLAT
1112           && ctx->Polygon.StippleFlag==GL_FALSE) {
1113          switch (xmesa->pixelformat) {
1114             case PF_Truecolor:
1115 	       USE(flat_TRUECOLOR_triangle);
1116             case PF_Dither_True:
1117 	       USE(flat_TRUEDITHER_triangle);
1118             case PF_8A8B8G8R:
1119                USE(flat_8A8B8G8R_triangle);
1120             case PF_8A8R8G8B:
1121                USE(flat_8A8R8G8B_triangle);
1122             case PF_8R8G8B:
1123                USE(flat_8R8G8B_triangle);
1124             case PF_8R8G8B24:
1125                USE(flat_8R8G8B24_triangle);
1126             case PF_5R6G5B:
1127                USE(flat_5R6G5B_triangle);
1128             case PF_Dither_5R6G5B:
1129                USE(flat_DITHER_5R6G5B_triangle);
1130             default:
1131                return (swrast_tri_func) NULL;
1132          }
1133       }
1134    }
1135 #endif /* CHAN_BITS == 8 */
1136 
1137    return (swrast_tri_func) NULL;
1138 }
1139 
1140 
1141 /* Override for the swrast tri-selection function.  Try to use one
1142  * of our internal tri functions, otherwise fall back to the
1143  * standard swrast functions.
1144  */
xmesa_choose_triangle(struct gl_context * ctx)1145 void xmesa_choose_triangle( struct gl_context *ctx )
1146 {
1147    SWcontext *swrast = SWRAST_CONTEXT(ctx);
1148 
1149    if (!(swrast->Triangle = get_triangle_func( ctx )))
1150       _swrast_choose_triangle( ctx );
1151 }
1152 
1153