1 /* $Id: xm_tri.c,v 1.11 2000/11/19 23:10:26 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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.
29 * This file contains "accelerated" triangle functions. It should be
30 * fairly easy to write new special-purpose triangle functions and hook
31 * them into this module.
35 #include "glxheader.h"
41 /* Internal swrast includes:
43 #include "swrast/s_context.h"
44 #include "swrast/s_depth.h"
45 #include "swrast/s_triangle.h"
50 /**********************************************************************/
51 /*** Triangle rendering ***/
52 /**********************************************************************/
56 * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
58 static void smooth_TRUECOLOR_z_triangle( GLcontext
*ctx
,
63 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
64 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
66 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
68 #define INNER_LOOP( LEFT, RIGHT, Y ) \
70 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer, Y); \
71 GLint len = RIGHT-LEFT; \
73 for (i=0;i<len;i++,xx++) { \
74 GLdepth z = FixedToDepth(ffz); \
77 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
78 XMesaPutPixel( img, xx, yy, p ); \
81 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
85 #include "swrast/s_tritemp.h"
91 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
93 static void smooth_8A8B8G8R_z_triangle( GLcontext
*ctx
,
98 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
100 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
102 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
103 #define PIXEL_TYPE GLuint
104 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
105 #define INNER_LOOP( LEFT, RIGHT, Y ) \
107 GLint i, len = RIGHT-LEFT; \
109 for (i=0;i<len;i++) { \
110 GLdepth z = FixedToDepth(ffz); \
112 pRow[i] = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
116 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
120 #include "swrast/s_tritemp.h"
125 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
127 static void smooth_8R8G8B_z_triangle( GLcontext
*ctx
,
132 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
134 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
136 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
137 #define PIXEL_TYPE GLuint
138 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
139 #define INNER_LOOP( LEFT, RIGHT, Y ) \
141 GLint i, len = RIGHT-LEFT; \
143 for (i=0;i<len;i++) { \
144 GLdepth z = FixedToDepth(ffz); \
146 pRow[i] = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
150 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
154 #include "swrast/s_tritemp.h"
159 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
161 static void smooth_8R8G8B24_z_triangle( GLcontext
*ctx
,
166 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
168 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
170 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
171 #define PIXEL_TYPE bgr_t
172 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
173 #define INNER_LOOP( LEFT, RIGHT, Y ) \
175 GLint i, len = RIGHT-LEFT; \
177 for (i=0;i<len;i++) { \
178 GLdepth z = FixedToDepth(ffz); \
180 PIXEL_TYPE *ptr = pRow + i; \
181 ptr->r = FixedToInt(ffr); \
182 ptr->g = FixedToInt(ffg); \
183 ptr->b = FixedToInt(ffb); \
186 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
190 #include "swrast/s_tritemp.h"
195 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
197 static void smooth_TRUEDITHER_z_triangle( GLcontext
*ctx
,
202 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
203 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
205 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
207 #define INNER_LOOP( LEFT, RIGHT, Y ) \
209 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
211 for (i=0;i<len;i++,xx++) { \
212 GLdepth z = FixedToDepth(ffz); \
215 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), \
216 FixedToInt(ffg), FixedToInt(ffb) ); \
217 XMesaPutPixel( img, xx, yy, p ); \
220 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
224 #include "swrast/s_tritemp.h"
229 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
231 static void smooth_5R6G5B_z_triangle( GLcontext
*ctx
,
236 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
238 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
240 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
241 #define PIXEL_TYPE GLushort
242 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
243 #define INNER_LOOP( LEFT, RIGHT, Y ) \
245 GLint i, len = RIGHT-LEFT; \
247 for (i=0;i<len;i++) { \
248 DEPTH_TYPE z = FixedToDepth(ffz); \
250 pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
254 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
258 #include "swrast/s_tritemp.h"
263 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
265 static void smooth_DITHER_5R6G5B_z_triangle( GLcontext
*ctx
,
270 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
272 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
274 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
275 #define PIXEL_TYPE GLushort
276 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
277 #define INNER_LOOP( LEFT, RIGHT, Y ) \
279 GLint i, len = RIGHT-LEFT; \
281 for (i=0;i<len;i++) { \
282 GLdepth z = FixedToDepth(ffz); \
284 PACK_TRUEDITHER(pRow[i], LEFT+i, Y, FixedToInt(ffr), \
285 FixedToInt(ffg), FixedToInt(ffb) ); \
288 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
292 #include "swrast/s_tritemp.h"
297 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
299 static void smooth_DITHER8_z_triangle( GLcontext
*ctx
,
304 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
306 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
308 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
309 #define PIXEL_TYPE GLubyte
310 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
311 #define INNER_LOOP( LEFT, RIGHT, Y ) \
313 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
316 for (i=0;i<len;i++,xx++) { \
317 GLdepth z = FixedToDepth(ffz); \
319 pRow[i] = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
320 FixedToInt(ffg), FixedToInt(ffb) ); \
323 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
327 #include "swrast/s_tritemp.h"
332 * XImage, smooth, depth-buffered, PF_DITHER triangle.
334 static void smooth_DITHER_z_triangle( GLcontext
*ctx
,
339 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
340 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
342 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
344 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
345 #define PIXEL_TYPE GLubyte
346 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
347 #define INNER_LOOP( LEFT, RIGHT, Y ) \
349 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
352 for (i=0;i<len;i++,xx++) { \
353 GLdepth z = FixedToDepth(ffz); \
355 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
356 FixedToInt(ffg), FixedToInt(ffb) ); \
357 XMesaPutPixel( img, xx, yy, p ); \
360 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
364 #include "swrast/s_tritemp.h"
369 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
371 static void smooth_LOOKUP8_z_triangle( GLcontext
*ctx
,
376 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
378 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
380 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
381 #define PIXEL_TYPE GLubyte
382 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
383 #define INNER_LOOP( LEFT, RIGHT, Y ) \
385 GLint i, len = RIGHT-LEFT; \
388 for (i=0;i<len;i++) { \
389 GLdepth z = FixedToDepth(ffz); \
391 pRow[i] = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
395 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
399 #include "swrast/s_tritemp.h"
405 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
407 static void smooth_HPCR_z_triangle( GLcontext
*ctx
,
412 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
414 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
416 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
417 #define PIXEL_TYPE GLubyte
418 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
419 #define INNER_LOOP( LEFT, RIGHT, Y ) \
421 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
423 for (i=0;i<len;i++,xx++) { \
424 GLdepth z = FixedToDepth(ffz); \
426 pRow[i] = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
427 FixedToInt(ffg), FixedToInt(ffb) ); \
430 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
434 #include "swrast/s_tritemp.h"
439 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
441 static void flat_TRUECOLOR_z_triangle( GLcontext
*ctx
,
446 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
447 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
449 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
451 unsigned long pixel; \
452 PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
454 #define INNER_LOOP( LEFT, RIGHT, Y ) \
456 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
458 for (i=0;i<len;i++,xx++) { \
459 GLdepth z = FixedToDepth(ffz); \
461 XMesaPutPixel( img, xx, yy, pixel ); \
467 #include "swrast/s_tritemp.h"
472 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
474 static void flat_8A8B8G8R_z_triangle( GLcontext
*ctx
,
479 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
481 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
482 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
483 #define PIXEL_TYPE GLuint
484 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
486 unsigned long p = PACK_8B8G8R( v0->color[0], \
487 v0->color[1], v0->color[2] );
488 #define INNER_LOOP( LEFT, RIGHT, Y ) \
490 GLint i, len = RIGHT-LEFT; \
492 for (i=0;i<len;i++) { \
493 GLdepth z = FixedToDepth(ffz); \
495 pRow[i] = (PIXEL_TYPE) p; \
501 #include "swrast/s_tritemp.h"
506 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
508 static void flat_8R8G8B_z_triangle( GLcontext
*ctx
,
513 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
515 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
516 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
517 #define PIXEL_TYPE GLuint
518 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
520 unsigned long p = PACK_8R8G8B( v0->color[0], \
521 v0->color[1], v0->color[2] );
522 #define INNER_LOOP( LEFT, RIGHT, Y ) \
524 GLint i, len = RIGHT-LEFT; \
526 for (i=0;i<len;i++) { \
527 GLdepth z = FixedToDepth(ffz); \
529 pRow[i] = (PIXEL_TYPE) p; \
535 #include "swrast/s_tritemp.h"
540 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
542 static void flat_8R8G8B24_z_triangle( GLcontext
*ctx
,
547 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
548 const GLubyte
*color
= v0
->color
;
550 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
551 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
552 #define PIXEL_TYPE bgr_t
553 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
554 #define INNER_LOOP( LEFT, RIGHT, Y ) \
556 GLint i, len = RIGHT-LEFT; \
558 for (i=0;i<len;i++) { \
559 GLdepth z = FixedToDepth(ffz); \
561 PIXEL_TYPE *ptr = pRow+i; \
562 ptr->r = color[RCOMP]; \
563 ptr->g = color[GCOMP]; \
564 ptr->b = color[BCOMP]; \
570 #include "swrast/s_tritemp.h"
575 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
577 static void flat_TRUEDITHER_z_triangle( GLcontext
*ctx
,
582 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
583 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
585 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
586 #define INNER_LOOP( LEFT, RIGHT, Y ) \
588 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
590 for (i=0;i<len;i++,xx++) { \
591 GLdepth z = FixedToDepth(ffz); \
594 PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
595 v0->color[1], v0->color[2] ); \
596 XMesaPutPixel( img, xx, yy, p ); \
602 #include "swrast/s_tritemp.h"
607 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
609 static void flat_5R6G5B_z_triangle( GLcontext
*ctx
,
614 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
616 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
617 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
618 #define PIXEL_TYPE GLushort
619 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
621 unsigned long p = PACK_5R6G5B( v0->color[0], \
622 v0->color[1], v0->color[2] );
623 #define INNER_LOOP( LEFT, RIGHT, Y ) \
625 GLint i, len = RIGHT-LEFT; \
627 for (i=0;i<len;i++) { \
628 DEPTH_TYPE z = FixedToDepth(ffz); \
630 pRow[i] = (PIXEL_TYPE) p; \
636 #include "swrast/s_tritemp.h"
641 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
643 static void flat_DITHER_5R6G5B_z_triangle( GLcontext
*ctx
,
648 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
649 const GLubyte
*color
= v0
->color
;
651 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
652 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
653 #define PIXEL_TYPE GLushort
654 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
655 #define INNER_LOOP( LEFT, RIGHT, Y ) \
657 GLint i, len = RIGHT-LEFT; \
659 for (i=0;i<len;i++) { \
660 DEPTH_TYPE z = FixedToDepth(ffz); \
662 PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \
663 color[GCOMP], color[BCOMP]); \
669 #include "swrast/s_tritemp.h"
674 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
676 static void flat_DITHER8_z_triangle( GLcontext
*ctx
,
681 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
683 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
684 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
685 #define PIXEL_TYPE GLubyte
686 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
688 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
690 #define INNER_LOOP( LEFT, RIGHT, Y ) \
692 GLint i, xx = LEFT, len = RIGHT-LEFT; \
693 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
695 for (i=0;i<len;i++,xx++) { \
696 GLdepth z = FixedToDepth(ffz); \
698 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(xx); \
704 #include "swrast/s_tritemp.h"
709 * XImage, flat, depth-buffered, PF_DITHER triangle.
711 static void flat_DITHER_z_triangle( GLcontext
*ctx
,
716 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
717 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
719 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
721 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
723 #define INNER_LOOP( LEFT, RIGHT, Y ) \
725 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
726 FLAT_DITHER_ROW_SETUP(yy); \
728 for (i=0;i<len;i++,xx++) { \
729 GLdepth z = FixedToDepth(ffz); \
731 unsigned long p = FLAT_DITHER(xx); \
732 XMesaPutPixel( img, xx, yy, p ); \
738 #include "swrast/s_tritemp.h"
743 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
745 static void flat_HPCR_z_triangle( GLcontext
*ctx
,
750 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
752 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
753 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
754 #define PIXEL_TYPE GLubyte
755 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
757 GLubyte r = v0->color[0]; \
758 GLubyte g = v0->color[1]; \
759 GLubyte b = v0->color[2];
760 #define INNER_LOOP( LEFT, RIGHT, Y ) \
762 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
764 for (i=0;i<len;i++,xx++) { \
765 GLdepth z = FixedToDepth(ffz); \
767 pRow[i] = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
773 #include "swrast/s_tritemp.h"
778 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
780 static void flat_LOOKUP8_z_triangle( GLcontext
*ctx
,
785 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
787 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
788 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
789 #define PIXEL_TYPE GLubyte
790 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
793 GLubyte r = v0->color[0]; \
794 GLubyte g = v0->color[1]; \
795 GLubyte b = v0->color[2]; \
796 GLubyte p = LOOKUP(r,g,b);
797 #define INNER_LOOP( LEFT, RIGHT, Y ) \
799 GLint i, len = RIGHT-LEFT; \
801 for (i=0;i<len;i++) { \
802 GLdepth z = FixedToDepth(ffz); \
810 #include "swrast/s_tritemp.h"
816 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
818 static void smooth_TRUECOLOR_triangle( GLcontext
*ctx
,
823 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
824 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
826 #define INNER_LOOP( LEFT, RIGHT, Y ) \
828 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
829 for (xx=LEFT;xx<RIGHT;xx++) { \
831 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
832 XMesaPutPixel( img, xx, yy, p ); \
833 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
836 #include "swrast/s_tritemp.h"
841 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
843 static void smooth_8A8B8G8R_triangle( GLcontext
*ctx
,
848 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
850 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
851 #define PIXEL_TYPE GLuint
852 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
853 #define INNER_LOOP( LEFT, RIGHT, Y ) \
856 PIXEL_TYPE *pixel = pRow; \
857 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
858 *pixel = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
860 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
863 #include "swrast/s_tritemp.h"
868 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
870 static void smooth_8R8G8B_triangle( GLcontext
*ctx
,
875 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
877 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
878 #define PIXEL_TYPE GLuint
879 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
880 #define INNER_LOOP( LEFT, RIGHT, Y ) \
883 PIXEL_TYPE *pixel = pRow; \
884 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
885 *pixel = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
887 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
890 #include "swrast/s_tritemp.h"
895 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
897 static void smooth_8R8G8B24_triangle( GLcontext
*ctx
,
902 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
904 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
905 #define PIXEL_TYPE bgr_t
906 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
907 #define INNER_LOOP( LEFT, RIGHT, Y ) \
910 PIXEL_TYPE *pixel = pRow; \
911 for (xx=LEFT;xx<RIGHT;xx++) { \
912 pixel->r = FixedToInt(ffr); \
913 pixel->g = FixedToInt(ffg); \
914 pixel->b = FixedToInt(ffb); \
915 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
919 #include "swrast/s_tritemp.h"
924 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
926 static void smooth_TRUEDITHER_triangle( GLcontext
*ctx
,
931 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
932 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
934 #define INNER_LOOP( LEFT, RIGHT, Y ) \
936 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
937 for (xx=LEFT;xx<RIGHT;xx++) { \
939 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), FixedToInt(ffg), \
941 XMesaPutPixel( img, xx, yy, p ); \
942 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
945 #include "swrast/s_tritemp.h"
950 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
952 static void smooth_5R6G5B_triangle( GLcontext
*ctx
,
957 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
959 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
960 #define PIXEL_TYPE GLushort
961 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
962 #define INNER_LOOP( LEFT, RIGHT, Y ) \
965 PIXEL_TYPE *pixel = pRow; \
966 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
967 *pixel = (PIXEL_TYPE) PACK_5R6G5B( FixedToInt(ffr), \
968 FixedToInt(ffg), FixedToInt(ffb) ); \
969 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
972 #include "swrast/s_tritemp.h"
977 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
979 static void smooth_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
984 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
986 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
987 #define PIXEL_TYPE GLushort
988 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
989 #define INNER_LOOP( LEFT, RIGHT, Y ) \
992 PIXEL_TYPE *pixel = pRow; \
993 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
994 PACK_TRUEDITHER(*pixel, xx, Y, FixedToInt(ffr), \
995 FixedToInt(ffg), FixedToInt(ffb) ); \
996 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
999 #include "swrast/s_tritemp.h"
1004 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
1006 static void smooth_DITHER8_triangle( GLcontext
*ctx
,
1009 const SWvertex
*v2
)
1011 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1012 #define INTERP_RGB 1
1013 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1014 #define PIXEL_TYPE GLubyte
1015 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1016 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1018 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1019 PIXEL_TYPE *pixel = pRow; \
1020 XDITHER_SETUP(yy); \
1021 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1022 *pixel = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
1023 FixedToInt(ffg), FixedToInt(ffb) ); \
1024 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1027 #include "swrast/s_tritemp.h"
1032 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
1034 static void smooth_DITHER_triangle( GLcontext
*ctx
,
1037 const SWvertex
*v2
)
1039 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1040 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1042 #define INTERP_RGB 1
1043 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1045 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1046 XDITHER_SETUP(yy); \
1047 for (xx=LEFT;xx<RIGHT;xx++) { \
1048 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
1049 FixedToInt(ffg), FixedToInt(ffb) ); \
1050 XMesaPutPixel( img, xx, yy, p ); \
1051 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1054 #include "swrast/s_tritemp.h"
1059 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1061 static void smooth_LOOKUP8_triangle( GLcontext
*ctx
,
1064 const SWvertex
*v2
)
1066 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1068 #define INTERP_RGB 1
1069 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1070 #define PIXEL_TYPE GLubyte
1071 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1072 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1075 PIXEL_TYPE *pixel = pRow; \
1077 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1078 *pixel = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
1079 FixedToInt(ffb) ); \
1080 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1083 #include "swrast/s_tritemp.h"
1089 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
1091 static void smooth_HPCR_triangle( GLcontext
*ctx
,
1094 const SWvertex
*v2
)
1096 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1098 #define INTERP_RGB 1
1099 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1100 #define PIXEL_TYPE GLubyte
1101 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1102 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1104 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1105 PIXEL_TYPE *pixel = pRow; \
1106 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1107 *pixel = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
1108 FixedToInt(ffg), FixedToInt(ffb) ); \
1109 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1112 #include "swrast/s_tritemp.h"
1117 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
1119 static void flat_TRUECOLOR_triangle( GLcontext
*ctx
,
1122 const SWvertex
*v2
)
1124 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1125 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1126 #define SETUP_CODE \
1127 unsigned long pixel; \
1128 PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
1130 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1132 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1133 for (xx=LEFT;xx<RIGHT;xx++) { \
1134 XMesaPutPixel( img, xx, yy, pixel ); \
1137 #include "swrast/s_tritemp.h"
1142 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
1144 static void flat_8A8B8G8R_triangle( GLcontext
*ctx
,
1147 const SWvertex
*v2
)
1149 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1150 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1151 #define PIXEL_TYPE GLuint
1152 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1153 #define SETUP_CODE \
1154 unsigned long p = PACK_8B8G8R( v0->color[0], \
1155 v0->color[1], v0->color[2] );
1156 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1159 PIXEL_TYPE *pixel = pRow; \
1160 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1161 *pixel = (PIXEL_TYPE) p; \
1164 #include "swrast/s_tritemp.h"
1169 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1171 static void flat_8R8G8B_triangle( GLcontext
*ctx
,
1174 const SWvertex
*v2
)
1176 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1177 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1178 #define PIXEL_TYPE GLuint
1179 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1180 #define SETUP_CODE \
1181 unsigned long p = PACK_8R8G8B( v0->color[0], \
1182 v0->color[1], v0->color[2] );
1183 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1186 PIXEL_TYPE *pixel = pRow; \
1187 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1188 *pixel = (PIXEL_TYPE) p; \
1191 #include "swrast/s_tritemp.h"
1196 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1198 static void flat_8R8G8B24_triangle( GLcontext
*ctx
,
1201 const SWvertex
*v2
)
1203 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1204 const GLubyte
*color
= v0
->color
;
1205 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1206 #define PIXEL_TYPE bgr_t
1207 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1208 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1211 PIXEL_TYPE *pixel = pRow; \
1212 for (xx=LEFT;xx<RIGHT;xx++) { \
1213 pixel->r = color[RCOMP]; \
1214 pixel->g = color[GCOMP]; \
1215 pixel->b = color[BCOMP]; \
1219 #include "swrast/s_tritemp.h"
1223 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1225 static void flat_TRUEDITHER_triangle( GLcontext
*ctx
,
1228 const SWvertex
*v2
)
1230 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1231 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1232 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1234 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1235 for (xx=LEFT;xx<RIGHT;xx++) { \
1237 PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
1238 v0->color[1], v0->color[2] ); \
1239 XMesaPutPixel( img, xx, yy, p ); \
1242 #include "swrast/s_tritemp.h"
1248 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1250 static void flat_5R6G5B_triangle( GLcontext
*ctx
,
1253 const SWvertex
*v2
)
1255 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1256 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1257 #define PIXEL_TYPE GLushort
1258 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1259 #define SETUP_CODE \
1260 unsigned long p = PACK_5R6G5B( v0->color[0], \
1261 v0->color[1], v0->color[2] );
1262 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1265 PIXEL_TYPE *pixel = pRow; \
1266 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1267 *pixel = (PIXEL_TYPE) p; \
1270 #include "swrast/s_tritemp.h"
1275 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1277 static void flat_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
1280 const SWvertex
*v2
)
1282 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1283 const GLubyte
*color
= v0
->color
;
1284 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1285 #define PIXEL_TYPE GLushort
1286 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1287 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1290 PIXEL_TYPE *pixel = pRow; \
1291 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1292 PACK_TRUEDITHER(*pixel, xx, Y, color[RCOMP], \
1293 color[GCOMP], color[BCOMP]); \
1296 #include "swrast/s_tritemp.h"
1301 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1303 static void flat_DITHER8_triangle( GLcontext
*ctx
,
1306 const SWvertex
*v2
)
1308 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1309 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1310 #define PIXEL_TYPE GLubyte
1311 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1312 #define SETUP_CODE \
1313 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
1315 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1318 PIXEL_TYPE *pixel = pRow; \
1319 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
1320 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1321 *pixel = (PIXEL_TYPE) FLAT_DITHER(xx); \
1324 #include "swrast/s_tritemp.h"
1329 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1331 static void flat_DITHER_triangle( GLcontext
*ctx
,
1334 const SWvertex
*v2
)
1336 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1337 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1338 #define SETUP_CODE \
1339 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
1341 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1343 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1344 FLAT_DITHER_ROW_SETUP(yy); \
1345 for (xx=LEFT;xx<RIGHT;xx++) { \
1346 unsigned long p = FLAT_DITHER(xx); \
1347 XMesaPutPixel( img, xx, yy, p ); \
1350 #include "swrast/s_tritemp.h"
1355 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1357 static void flat_HPCR_triangle( GLcontext
*ctx
,
1360 const SWvertex
*v2
)
1362 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1363 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1364 #define PIXEL_TYPE GLubyte
1365 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1366 #define SETUP_CODE \
1367 GLubyte r = v0->color[0]; \
1368 GLubyte g = v0->color[1]; \
1369 GLubyte b = v0->color[2];
1370 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1372 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1373 PIXEL_TYPE *pixel = pRow; \
1374 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1375 *pixel = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
1378 #include "swrast/s_tritemp.h"
1383 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1385 static void flat_LOOKUP8_triangle( GLcontext
*ctx
,
1388 const SWvertex
*v2
)
1390 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1391 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1392 #define PIXEL_TYPE GLubyte
1393 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1394 #define SETUP_CODE \
1396 GLubyte r = v0->color[0]; \
1397 GLubyte g = v0->color[1]; \
1398 GLubyte b = v0->color[2]; \
1399 GLubyte p = LOOKUP(r,g,b);
1400 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1403 PIXEL_TYPE *pixel = pRow; \
1404 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1408 #include "swrast/s_tritemp.h"
1414 _xmesa_print_triangle_func( swrast_tri_func triFunc
)
1416 printf("XMesa tri func = ");
1417 if (triFunc
==smooth_TRUECOLOR_z_triangle
)
1418 printf("smooth_TRUECOLOR_z_triangle\n");
1419 else if (triFunc
==smooth_8A8B8G8R_z_triangle
)
1420 printf("smooth_8A8B8G8R_z_triangle\n");
1421 else if (triFunc
==smooth_8R8G8B_z_triangle
)
1422 printf("smooth_8R8G8B_z_triangle\n");
1423 else if (triFunc
==smooth_8R8G8B24_z_triangle
)
1424 printf("smooth_8R8G8B24_z_triangle\n");
1425 else if (triFunc
==smooth_TRUEDITHER_z_triangle
)
1426 printf("smooth_TRUEDITHER_z_triangle\n");
1427 else if (triFunc
==smooth_5R6G5B_z_triangle
)
1428 printf("smooth_5R6G5B_z_triangle\n");
1429 else if (triFunc
==smooth_DITHER_5R6G5B_z_triangle
)
1430 printf("smooth_DITHER_5R6G5B_z_triangle\n");
1431 else if (triFunc
==smooth_HPCR_z_triangle
)
1432 printf("smooth_HPCR_z_triangle\n");
1433 else if (triFunc
==smooth_DITHER8_z_triangle
)
1434 printf("smooth_DITHER8_z_triangle\n");
1435 else if (triFunc
==smooth_LOOKUP8_z_triangle
)
1436 printf("smooth_LOOKUP8_z_triangle\n");
1437 else if (triFunc
==flat_TRUECOLOR_z_triangle
)
1438 printf("flat_TRUECOLOR_z_triangle\n");
1439 else if (triFunc
==flat_8A8B8G8R_z_triangle
)
1440 printf("flat_8A8B8G8R_z_triangle\n");
1441 else if (triFunc
==flat_8R8G8B_z_triangle
)
1442 printf("flat_8R8G8B_z_triangle\n");
1443 else if (triFunc
==flat_8R8G8B24_z_triangle
)
1444 printf("flat_8R8G8B24_z_triangle\n");
1445 else if (triFunc
==flat_TRUEDITHER_z_triangle
)
1446 printf("flat_TRUEDITHER_z_triangle\n");
1447 else if (triFunc
==flat_5R6G5B_z_triangle
)
1448 printf("flat_5R6G5B_z_triangle\n");
1449 else if (triFunc
==flat_DITHER_5R6G5B_z_triangle
)
1450 printf("flat_DITHER_5R6G5B_z_triangle\n");
1451 else if (triFunc
==flat_HPCR_z_triangle
)
1452 printf("flat_HPCR_z_triangle\n");
1453 else if (triFunc
==flat_DITHER8_z_triangle
)
1454 printf("flat_DITHER8_z_triangle\n");
1455 else if (triFunc
==flat_LOOKUP8_z_triangle
)
1456 printf("flat_LOOKUP8_z_triangle\n");
1457 else if (triFunc
==smooth_TRUECOLOR_triangle
)
1458 printf("smooth_TRUECOLOR_triangle\n");
1459 else if (triFunc
==smooth_8A8B8G8R_triangle
)
1460 printf("smooth_8A8B8G8R_triangle\n");
1461 else if (triFunc
==smooth_8R8G8B_triangle
)
1462 printf("smooth_8R8G8B_triangle\n");
1463 else if (triFunc
==smooth_8R8G8B24_triangle
)
1464 printf("smooth_8R8G8B24_triangle\n");
1465 else if (triFunc
==smooth_TRUEDITHER_triangle
)
1466 printf("smooth_TRUEDITHER_triangle\n");
1467 else if (triFunc
==smooth_5R6G5B_triangle
)
1468 printf("smooth_5R6G5B_triangle\n");
1469 else if (triFunc
==smooth_DITHER_5R6G5B_triangle
)
1470 printf("smooth_DITHER_5R6G5B_triangle\n");
1471 else if (triFunc
==smooth_HPCR_triangle
)
1472 printf("smooth_HPCR_triangle\n");
1473 else if (triFunc
==smooth_DITHER8_triangle
)
1474 printf("smooth_DITHER8_triangle\n");
1475 else if (triFunc
==smooth_LOOKUP8_triangle
)
1476 printf("smooth_LOOKUP8_triangle\n");
1477 else if (triFunc
==flat_TRUECOLOR_triangle
)
1478 printf("flat_TRUECOLOR_triangle\n");
1479 else if (triFunc
==flat_TRUEDITHER_triangle
)
1480 printf("flat_TRUEDITHER_triangle\n");
1481 else if (triFunc
==flat_8A8B8G8R_triangle
)
1482 printf("flat_8A8B8G8R_triangle\n");
1483 else if (triFunc
==flat_8R8G8B_triangle
)
1484 printf("flat_8R8G8B_triangle\n");
1485 else if (triFunc
==flat_8R8G8B24_triangle
)
1486 printf("flat_8R8G8B24_triangle\n");
1487 else if (triFunc
==flat_5R6G5B_triangle
)
1488 printf("flat_5R6G5B_triangle\n");
1489 else if (triFunc
==flat_DITHER_5R6G5B_triangle
)
1490 printf("flat_DITHER_5R6G5B_triangle\n");
1491 else if (triFunc
==flat_HPCR_triangle
)
1492 printf("flat_HPCR_triangle\n");
1493 else if (triFunc
==flat_DITHER8_triangle
)
1494 printf("flat_DITHER8_triangle\n");
1495 else if (triFunc
==flat_LOOKUP8_triangle
)
1496 printf("flat_LOOKUP8_triangle\n");
1503 static swrast_tri_func
get_triangle_func( GLcontext
*ctx
)
1505 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1506 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1507 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
1511 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1512 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1513 if (ctx
->Texture
._ReallyEnabled
) return (swrast_tri_func
) NULL
;
1515 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
1516 if ( ctx
->Light
.ShadeModel
==GL_SMOOTH
1517 && swrast
->_RasterMask
==DEPTH_BIT
1518 && ctx
->Depth
.Func
==GL_LESS
1519 && ctx
->Depth
.Mask
==GL_TRUE
1520 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1521 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1522 switch (xmesa
->pixelformat
) {
1524 return smooth_TRUECOLOR_z_triangle
;
1526 return smooth_8A8B8G8R_z_triangle
;
1528 return smooth_8R8G8B_z_triangle
;
1530 return smooth_8R8G8B24_z_triangle
;
1532 return smooth_TRUEDITHER_z_triangle
;
1534 return smooth_5R6G5B_z_triangle
;
1535 case PF_DITHER_5R6G5B
:
1536 return smooth_DITHER_5R6G5B_z_triangle
;
1538 return smooth_HPCR_z_triangle
;
1540 return (depth
==8) ? smooth_DITHER8_z_triangle
1541 : smooth_DITHER_z_triangle
;
1543 return (depth
==8) ? smooth_LOOKUP8_z_triangle
: (swrast_tri_func
)NULL
;
1545 return (swrast_tri_func
)NULL
;
1548 if ( ctx
->Light
.ShadeModel
==GL_FLAT
1549 && swrast
->_RasterMask
==DEPTH_BIT
1550 && ctx
->Depth
.Func
==GL_LESS
1551 && ctx
->Depth
.Mask
==GL_TRUE
1552 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1553 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1554 switch (xmesa
->pixelformat
) {
1556 return flat_TRUECOLOR_z_triangle
;
1558 return flat_8A8B8G8R_z_triangle
;
1560 return flat_8R8G8B_z_triangle
;
1562 return flat_8R8G8B24_z_triangle
;
1564 return flat_TRUEDITHER_z_triangle
;
1566 return flat_5R6G5B_z_triangle
;
1567 case PF_DITHER_5R6G5B
:
1568 return flat_DITHER_5R6G5B_z_triangle
;
1570 return flat_HPCR_z_triangle
;
1572 return (depth
==8) ? flat_DITHER8_z_triangle
1573 : flat_DITHER_z_triangle
;
1575 return (depth
==8) ? flat_LOOKUP8_z_triangle
: (swrast_tri_func
)NULL
;
1577 return (swrast_tri_func
)NULL
;
1580 if ( swrast
->_RasterMask
==0 /* no depth test */
1581 && ctx
->Light
.ShadeModel
==GL_SMOOTH
1582 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1583 switch (xmesa
->pixelformat
) {
1585 return smooth_TRUECOLOR_triangle
;
1587 return smooth_8A8B8G8R_triangle
;
1589 return smooth_8R8G8B_triangle
;
1591 return smooth_8R8G8B24_triangle
;
1593 return smooth_TRUEDITHER_triangle
;
1595 return smooth_5R6G5B_triangle
;
1596 case PF_DITHER_5R6G5B
:
1597 return smooth_DITHER_5R6G5B_triangle
;
1599 return smooth_HPCR_triangle
;
1601 return (depth
==8) ? smooth_DITHER8_triangle
1602 : smooth_DITHER_triangle
;
1604 return (depth
==8) ? smooth_LOOKUP8_triangle
: (swrast_tri_func
)NULL
;
1606 return (swrast_tri_func
)NULL
;
1610 if ( swrast
->_RasterMask
==0 /* no depth test */
1611 && ctx
->Light
.ShadeModel
==GL_FLAT
1612 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1613 switch (xmesa
->pixelformat
) {
1615 return flat_TRUECOLOR_triangle
;
1617 return flat_TRUEDITHER_triangle
;
1619 return flat_8A8B8G8R_triangle
;
1621 return flat_8R8G8B_triangle
;
1623 return flat_8R8G8B24_triangle
;
1625 return flat_5R6G5B_triangle
;
1626 case PF_DITHER_5R6G5B
:
1627 return flat_DITHER_5R6G5B_triangle
;
1629 return flat_HPCR_triangle
;
1631 return (depth
==8) ? flat_DITHER8_triangle
1632 : flat_DITHER_triangle
;
1634 return (depth
==8) ? flat_LOOKUP8_triangle
: (swrast_tri_func
)NULL
;
1636 return (swrast_tri_func
)NULL
;
1640 return (swrast_tri_func
)NULL
;
1643 /* draw to pixmap */
1644 return (swrast_tri_func
) NULL
;
1649 /* Override for the swrast tri-selection function. Try to use one
1650 * of our internal tri functions, otherwise fall back to the
1651 * standard swrast functions.
1653 void xmesa_choose_triangle( GLcontext
*ctx
)
1655 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1657 if (!(swrast
->Triangle
= get_triangle_func( ctx
)))
1658 _swrast_choose_triangle( ctx
);