1 /* $Id: xm_tri.c,v 1.23 2002/06/15 02:38:17 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"
43 /* Internal swrast includes:
45 #include "swrast/s_context.h"
46 #include "swrast/s_depth.h"
47 #include "swrast/s_triangle.h"
51 /**********************************************************************/
52 /*** Triangle rendering ***/
53 /**********************************************************************/
57 * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
59 static void smooth_TRUECOLOR_z_triangle( GLcontext
*ctx
,
64 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
65 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
67 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
70 #define RENDER_SPAN( span ) \
71 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
73 for (i = 0; i < span->end; i++, x++) { \
74 const DEPTH_TYPE z = FixedToDepth(span->z); \
77 PACK_TRUECOLOR(p, FixedToInt(span->red), \
78 FixedToInt(span->green), FixedToInt(span->blue)); \
79 XMesaPutPixel(img, x, y, p); \
82 span->red += span->redStep; \
83 span->green += span->greenStep; \
84 span->blue += span->blueStep; \
85 span->z += span->zStep; \
88 #include "swrast/s_tritemp.h"
94 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
96 static void smooth_8A8B8G8R_z_triangle( GLcontext
*ctx
,
101 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
103 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
105 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
106 #define PIXEL_TYPE GLuint
107 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
109 #define RENDER_SPAN( span ) \
111 for (i = 0; i < span->end; i++) { \
112 const DEPTH_TYPE z = FixedToDepth(span->z); \
114 pRow[i] = PACK_8B8G8R(FixedToInt(span->red), \
115 FixedToInt(span->green), FixedToInt(span->blue)); \
118 span->red += span->redStep; \
119 span->green += span->greenStep; \
120 span->blue += span->blueStep; \
121 span->z += span->zStep; \
124 #include "swrast/s_tritemp.h"
129 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
131 static void smooth_8R8G8B_z_triangle( GLcontext
*ctx
,
136 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
138 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
140 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
141 #define PIXEL_TYPE GLuint
142 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
144 #define RENDER_SPAN( span ) \
146 for (i = 0; i < span->end; i++) { \
147 const DEPTH_TYPE z = FixedToDepth(span->z); \
149 pRow[i] = PACK_8R8G8B(FixedToInt(span->red), \
150 FixedToInt(span->green), FixedToInt(span->blue)); \
153 span->red += span->redStep; \
154 span->green += span->greenStep; \
155 span->blue += span->blueStep; \
156 span->z += span->zStep; \
159 #include "swrast/s_tritemp.h"
164 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
166 static void smooth_8R8G8B24_z_triangle( GLcontext
*ctx
,
171 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
173 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
175 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
176 #define PIXEL_TYPE bgr_t
177 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
179 #define RENDER_SPAN( span ) \
181 for (i = 0; i < span->end; i++) { \
182 const DEPTH_TYPE z = FixedToDepth(span->z); \
184 PIXEL_TYPE *ptr = pRow + i; \
185 ptr->r = FixedToInt(span->red); \
186 ptr->g = FixedToInt(span->green); \
187 ptr->b = FixedToInt(span->blue); \
190 span->red += span->redStep; \
191 span->green += span->greenStep; \
192 span->blue += span->blueStep; \
193 span->z += span->zStep; \
196 #include "swrast/s_tritemp.h"
201 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
203 static void smooth_TRUEDITHER_z_triangle( GLcontext
*ctx
,
208 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
209 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
211 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
214 #define RENDER_SPAN( span ) \
216 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
217 for (i = 0; i < span->end; i++, x++) { \
218 const DEPTH_TYPE z = FixedToDepth(span->z); \
221 PACK_TRUEDITHER(p, x, y, FixedToInt(span->red), \
222 FixedToInt(span->green), FixedToInt(span->blue)); \
223 XMesaPutPixel(img, x, y, p); \
226 span->red += span->redStep; \
227 span->green += span->greenStep; \
228 span->blue += span->blueStep; \
229 span->z += span->zStep; \
232 #include "swrast/s_tritemp.h"
237 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
239 static void smooth_5R6G5B_z_triangle( GLcontext
*ctx
,
244 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
246 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
248 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
249 #define PIXEL_TYPE GLushort
250 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
252 #define RENDER_SPAN( span ) \
254 for (i = 0; i < span->end; i++) { \
255 const DEPTH_TYPE z = FixedToDepth(span->z); \
257 pRow[i] = PACK_5R6G5B(FixedToInt(span->red), \
258 FixedToInt(span->green), FixedToInt(span->blue)); \
261 span->red += span->redStep; \
262 span->green += span->greenStep; \
263 span->blue += span->blueStep; \
264 span->z += span->zStep; \
267 #include "swrast/s_tritemp.h"
272 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
274 static void smooth_DITHER_5R6G5B_z_triangle( GLcontext
*ctx
,
279 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
281 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
283 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
284 #define PIXEL_TYPE GLushort
285 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
287 #define RENDER_SPAN( span ) \
289 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
290 for (i = 0; i < span->end; i++, x++) { \
291 const DEPTH_TYPE z = FixedToDepth(span->z); \
293 PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span->red), \
294 FixedToInt(span->green), FixedToInt(span->blue)); \
297 span->red += span->redStep; \
298 span->green += span->greenStep; \
299 span->blue += span->blueStep; \
300 span->z += span->zStep; \
303 #include "swrast/s_tritemp.h"
308 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
310 static void smooth_DITHER8_z_triangle( GLcontext
*ctx
,
315 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
317 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
319 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
320 #define PIXEL_TYPE GLubyte
321 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
323 #define RENDER_SPAN( span ) \
325 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
327 for (i = 0; i < span->end; i++, x++) { \
328 const DEPTH_TYPE z = FixedToDepth(span->z); \
330 pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span->red),\
331 FixedToInt(span->green), FixedToInt(span->blue) ); \
334 span->red += span->redStep; \
335 span->green += span->greenStep; \
336 span->blue += span->blueStep; \
337 span->z += span->zStep; \
340 #include "swrast/s_tritemp.h"
345 * XImage, smooth, depth-buffered, PF_DITHER triangle.
347 static void smooth_DITHER_z_triangle( GLcontext
*ctx
,
352 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
353 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
355 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
358 #define RENDER_SPAN( span ) \
360 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
362 for (i = 0; i < span->end; i++, x++) { \
363 const DEPTH_TYPE z = FixedToDepth(span->z); \
365 unsigned long p = XDITHER(x, FixedToInt(span->red), \
366 FixedToInt(span->green), FixedToInt(span->blue)); \
367 XMesaPutPixel(img, x, y, p); \
370 span->red += span->redStep; \
371 span->green += span->greenStep; \
372 span->blue += span->blueStep; \
373 span->z += span->zStep; \
376 #include "swrast/s_tritemp.h"
381 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
383 static void smooth_LOOKUP8_z_triangle( GLcontext
*ctx
,
388 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
390 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
392 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
393 #define PIXEL_TYPE GLubyte
394 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
396 #define RENDER_SPAN( span ) \
399 for (i = 0; i < span->end; i++) { \
400 const DEPTH_TYPE z = FixedToDepth(span->z); \
402 pRow[i] = LOOKUP(FixedToInt(span->red), \
403 FixedToInt(span->green), FixedToInt(span->blue)); \
406 span->red += span->redStep; \
407 span->green += span->greenStep; \
408 span->blue += span->blueStep; \
409 span->z += span->zStep; \
412 #include "swrast/s_tritemp.h"
418 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
420 static void smooth_HPCR_z_triangle( GLcontext
*ctx
,
425 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
427 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
429 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
430 #define PIXEL_TYPE GLubyte
431 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
433 #define RENDER_SPAN( span ) \
435 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
436 for (i = 0; i < span->end; i++, x++) { \
437 const DEPTH_TYPE z = FixedToDepth(span->z); \
439 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span->red), \
440 FixedToInt(span->green), FixedToInt(span->blue) ); \
443 span->red += span->redStep; \
444 span->green += span->greenStep; \
445 span->blue += span->blueStep; \
446 span->z += span->zStep; \
449 #include "swrast/s_tritemp.h"
454 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
456 static void flat_TRUECOLOR_z_triangle( GLcontext
*ctx
,
461 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
462 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
464 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
466 unsigned long pixel; \
467 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
469 #define RENDER_SPAN( span ) \
471 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
472 for (i = 0; i < span->end; i++, x++) { \
473 const DEPTH_TYPE z = FixedToDepth(span->z); \
475 XMesaPutPixel(img, x, y, pixel); \
478 span->z += span->zStep; \
481 #include "swrast/s_tritemp.h"
486 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
488 static void flat_8A8B8G8R_z_triangle( GLcontext
*ctx
,
493 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
495 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
496 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
497 #define PIXEL_TYPE GLuint
498 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
500 unsigned long p = PACK_8B8G8R( v2->color[0], \
501 v2->color[1], v2->color[2] );
502 #define RENDER_SPAN( span ) \
504 for (i = 0; i < span->end; i++) { \
505 const DEPTH_TYPE z = FixedToDepth(span->z); \
507 pRow[i] = (PIXEL_TYPE) p; \
510 span->z += span->zStep; \
513 #include "swrast/s_tritemp.h"
518 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
520 static void flat_8R8G8B_z_triangle( GLcontext
*ctx
,
525 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
527 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
528 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
529 #define PIXEL_TYPE GLuint
530 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
532 unsigned long p = PACK_8R8G8B( v2->color[0], \
533 v2->color[1], v2->color[2] );
534 #define RENDER_SPAN( span ) \
536 for (i = 0; i < span->end; i++) { \
537 DEPTH_TYPE z = FixedToDepth(span->z); \
539 pRow[i] = (PIXEL_TYPE) p; \
542 span->z += span->zStep; \
545 #include "swrast/s_tritemp.h"
550 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
552 static void flat_8R8G8B24_z_triangle( GLcontext
*ctx
,
557 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
558 const GLubyte
*color
= v2
->color
;
560 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
561 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
562 #define PIXEL_TYPE bgr_t
563 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
564 #define RENDER_SPAN( span ) \
566 for (i = 0; i < span->end; i++) { \
567 const DEPTH_TYPE z = FixedToDepth(span->z); \
569 PIXEL_TYPE *ptr = pRow + i; \
570 ptr->r = color[RCOMP]; \
571 ptr->g = color[GCOMP]; \
572 ptr->b = color[BCOMP]; \
575 span->z += span->zStep; \
578 #include "swrast/s_tritemp.h"
583 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
585 static void flat_TRUEDITHER_z_triangle( GLcontext
*ctx
,
590 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
591 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
593 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
594 #define RENDER_SPAN( span ) \
596 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
597 for (i = 0; i < span->end; i++, x++) { \
598 const DEPTH_TYPE z = FixedToDepth(span->z); \
601 PACK_TRUEDITHER(p, x, y, v2->color[0], \
602 v2->color[1], v2->color[2]); \
603 XMesaPutPixel(img, x, y, p); \
606 span->z += span->zStep; \
609 #include "swrast/s_tritemp.h"
614 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
616 static void flat_5R6G5B_z_triangle( GLcontext
*ctx
,
621 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
623 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
624 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
625 #define PIXEL_TYPE GLushort
626 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
628 unsigned long p = PACK_5R6G5B( v2->color[0], \
629 v2->color[1], v2->color[2] );
630 #define RENDER_SPAN( span ) \
632 for (i = 0; i < span->end; i++) { \
633 const DEPTH_TYPE z = FixedToDepth(span->z); \
635 pRow[i] = (PIXEL_TYPE) p; \
638 span->z += span->zStep; \
641 #include "swrast/s_tritemp.h"
646 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
648 static void flat_DITHER_5R6G5B_z_triangle( GLcontext
*ctx
,
653 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
654 const GLubyte
*color
= v2
->color
;
656 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
657 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
658 #define PIXEL_TYPE GLushort
659 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
660 #define RENDER_SPAN( span ) \
662 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
663 for (i = 0; i < span->end; i++, x++) { \
664 const DEPTH_TYPE z = FixedToDepth(span->z); \
666 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
667 color[GCOMP], color[BCOMP]); \
670 span->z += span->zStep; \
673 #include "swrast/s_tritemp.h"
678 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
680 static void flat_DITHER8_z_triangle( GLcontext
*ctx
,
685 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
687 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
688 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
689 #define PIXEL_TYPE GLubyte
690 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
692 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
694 #define RENDER_SPAN( span ) \
696 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
697 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
698 for (i = 0; i < span->end; i++, x++) { \
699 const DEPTH_TYPE z = FixedToDepth(span->z); \
701 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
704 span->z += span->zStep; \
707 #include "swrast/s_tritemp.h"
712 * XImage, flat, depth-buffered, PF_DITHER triangle.
714 static void flat_DITHER_z_triangle( GLcontext
*ctx
,
719 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
720 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
722 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
724 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
726 #define RENDER_SPAN( span ) \
728 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
729 FLAT_DITHER_ROW_SETUP(y); \
730 for (i = 0; i < span->end; i++, x++) { \
731 const DEPTH_TYPE z = FixedToDepth(span->z); \
733 unsigned long p = FLAT_DITHER(x); \
734 XMesaPutPixel(img, x, y, p); \
737 span->z += span->zStep; \
740 #include "swrast/s_tritemp.h"
745 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
747 static void flat_HPCR_z_triangle( GLcontext
*ctx
,
752 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
754 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
755 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
756 #define PIXEL_TYPE GLubyte
757 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
759 GLubyte r = v2->color[0]; \
760 GLubyte g = v2->color[1]; \
761 GLubyte b = v2->color[2];
762 #define RENDER_SPAN( span ) \
764 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
765 for (i = 0; i < span->end; i++, x++) { \
766 const DEPTH_TYPE z = FixedToDepth(span->z); \
768 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
771 span->z += span->zStep; \
774 #include "swrast/s_tritemp.h"
779 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
781 static void flat_LOOKUP8_z_triangle( GLcontext
*ctx
,
786 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
788 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
789 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
790 #define PIXEL_TYPE GLubyte
791 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
794 GLubyte r = v2->color[0]; \
795 GLubyte g = v2->color[1]; \
796 GLubyte b = v2->color[2]; \
797 GLubyte p = LOOKUP(r,g,b);
798 #define RENDER_SPAN( span ) \
800 for (i = 0; i < span->end; i++) { \
801 const DEPTH_TYPE z = FixedToDepth(span->z); \
806 span->z += span->zStep; \
809 #include "swrast/s_tritemp.h"
815 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
817 static void smooth_TRUECOLOR_triangle( GLcontext
*ctx
,
822 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
823 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
825 #define RENDER_SPAN( span ) \
827 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
828 for (i = 0; i < span->end; i++, x++) { \
830 PACK_TRUECOLOR(p, FixedToInt(span->red), \
831 FixedToInt(span->green), FixedToInt(span->blue)); \
832 XMesaPutPixel(img, x, y, p); \
833 span->red += span->redStep; \
834 span->green += span->greenStep; \
835 span->blue += span->blueStep; \
838 #include "swrast/s_tritemp.h"
843 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
845 static void smooth_8A8B8G8R_triangle( GLcontext
*ctx
,
850 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
852 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
853 #define PIXEL_TYPE GLuint
854 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
855 #define RENDER_SPAN( span ) \
857 for (i = 0; i < span->end; i++) { \
858 pRow[i] = PACK_8B8G8R(FixedToInt(span->red), \
859 FixedToInt(span->green), FixedToInt(span->blue) ); \
860 span->red += span->redStep; \
861 span->green += span->greenStep; \
862 span->blue += span->blueStep; \
865 #include "swrast/s_tritemp.h"
870 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
872 static void smooth_8R8G8B_triangle( GLcontext
*ctx
,
877 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
879 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
880 #define PIXEL_TYPE GLuint
881 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
882 #define RENDER_SPAN( span ) \
884 for (i = 0; i < span->end; i++) { \
885 pRow[i] = PACK_8R8G8B(FixedToInt(span->red), \
886 FixedToInt(span->green), FixedToInt(span->blue) ); \
887 span->red += span->redStep; \
888 span->green += span->greenStep; \
889 span->blue += span->blueStep; \
892 #include "swrast/s_tritemp.h"
897 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
899 static void smooth_8R8G8B24_triangle( GLcontext
*ctx
,
904 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
906 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
907 #define PIXEL_TYPE bgr_t
908 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
909 #define RENDER_SPAN( span ) \
911 PIXEL_TYPE *pixel = pRow; \
912 for (i = 0; i < span->end; i++, pixel++) { \
913 pixel->r = FixedToInt(span->red); \
914 pixel->g = FixedToInt(span->green); \
915 pixel->b = FixedToInt(span->blue); \
916 span->red += span->redStep; \
917 span->green += span->greenStep; \
918 span->blue += span->blueStep; \
921 #include "swrast/s_tritemp.h"
926 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
928 static void smooth_TRUEDITHER_triangle( GLcontext
*ctx
,
933 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
934 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
936 #define RENDER_SPAN( span ) \
938 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
939 for (i = 0; i < span->end; i++, x++) { \
941 PACK_TRUEDITHER(p, x, y, FixedToInt(span->red), \
942 FixedToInt(span->green), FixedToInt(span->blue)); \
943 XMesaPutPixel(img, x, y, p ); \
944 span->red += span->redStep; \
945 span->green += span->greenStep; \
946 span->blue += span->blueStep; \
949 #include "swrast/s_tritemp.h"
954 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
956 static void smooth_5R6G5B_triangle( GLcontext
*ctx
,
961 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
963 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
964 #define PIXEL_TYPE GLushort
965 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
966 #define RENDER_SPAN( span ) \
968 for (i = 0; i < span->end; i++) { \
969 pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span->red), \
970 FixedToInt(span->green), FixedToInt(span->blue)); \
971 span->red += span->redStep; \
972 span->green += span->greenStep; \
973 span->blue += span->blueStep; \
976 #include "swrast/s_tritemp.h"
981 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
983 static void smooth_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
988 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
990 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
991 #define PIXEL_TYPE GLushort
992 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
993 #define RENDER_SPAN( span ) \
995 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
996 for (i = 0; i < span->end; i++, x++) { \
997 PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span->red), \
998 FixedToInt(span->green), FixedToInt(span->blue)); \
999 span->red += span->redStep; \
1000 span->green += span->greenStep; \
1001 span->blue += span->blueStep; \
1004 #include "swrast/s_tritemp.h"
1009 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
1011 static void smooth_DITHER8_triangle( GLcontext
*ctx
,
1014 const SWvertex
*v2
)
1016 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1017 #define INTERP_RGB 1
1018 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1019 #define PIXEL_TYPE GLubyte
1020 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1021 #define RENDER_SPAN( span ) \
1023 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1025 for (i = 0; i < span->end; i++, x++) { \
1026 pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span->red), \
1027 FixedToInt(span->green), FixedToInt(span->blue) ); \
1028 span->red += span->redStep; \
1029 span->green += span->greenStep; \
1030 span->blue += span->blueStep; \
1033 #include "swrast/s_tritemp.h"
1038 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
1040 static void smooth_DITHER_triangle( GLcontext
*ctx
,
1043 const SWvertex
*v2
)
1045 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1046 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1048 #define INTERP_RGB 1
1049 #define RENDER_SPAN( span ) \
1051 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1053 for (i = 0; i < span->end; i++, x++) { \
1054 unsigned long p = XDITHER(x, FixedToInt(span->red), \
1055 FixedToInt(span->green), FixedToInt(span->blue) ); \
1056 XMesaPutPixel(img, x, y, p); \
1057 span->red += span->redStep; \
1058 span->green += span->greenStep; \
1059 span->blue += span->blueStep; \
1062 #include "swrast/s_tritemp.h"
1067 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1069 static void smooth_LOOKUP8_triangle( GLcontext
*ctx
,
1072 const SWvertex
*v2
)
1074 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1076 #define INTERP_RGB 1
1077 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1078 #define PIXEL_TYPE GLubyte
1079 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1080 #define RENDER_SPAN( span ) \
1083 for (i = 0; i < span->end; i++) { \
1084 pRow[i] = LOOKUP(FixedToInt(span->red), \
1085 FixedToInt(span->green), FixedToInt(span->blue));\
1086 span->red += span->redStep; \
1087 span->green += span->greenStep; \
1088 span->blue += span->blueStep; \
1091 #include "swrast/s_tritemp.h"
1097 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
1099 static void smooth_HPCR_triangle( GLcontext
*ctx
,
1102 const SWvertex
*v2
)
1104 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1106 #define INTERP_RGB 1
1107 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1108 #define PIXEL_TYPE GLubyte
1109 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1110 #define RENDER_SPAN( span ) \
1112 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1113 for (i = 0; i < span->end; i++, x++) { \
1114 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span->red), \
1115 FixedToInt(span->green), FixedToInt(span->blue)); \
1116 span->red += span->redStep; \
1117 span->green += span->greenStep; \
1118 span->blue += span->blueStep; \
1121 #include "swrast/s_tritemp.h"
1126 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
1128 static void flat_TRUECOLOR_triangle( GLcontext
*ctx
,
1131 const SWvertex
*v2
)
1133 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1134 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1135 #define SETUP_CODE \
1136 unsigned long pixel; \
1137 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
1139 #define RENDER_SPAN( span ) \
1141 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1142 for (i = 0; i < span->end; i++, x++) { \
1143 XMesaPutPixel(img, x, y, pixel); \
1146 #include "swrast/s_tritemp.h"
1151 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
1153 static void flat_8A8B8G8R_triangle( GLcontext
*ctx
,
1156 const SWvertex
*v2
)
1158 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1159 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1160 #define PIXEL_TYPE GLuint
1161 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1162 #define SETUP_CODE \
1163 unsigned long p = PACK_8B8G8R( v2->color[0], \
1164 v2->color[1], v2->color[2] );
1165 #define RENDER_SPAN( span ) \
1167 for (i = 0; i < span->end; i++) { \
1168 pRow[i] = (PIXEL_TYPE) p; \
1171 #include "swrast/s_tritemp.h"
1176 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1178 static void flat_8R8G8B_triangle( GLcontext
*ctx
,
1181 const SWvertex
*v2
)
1183 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1184 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1185 #define PIXEL_TYPE GLuint
1186 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1187 #define SETUP_CODE \
1188 unsigned long p = PACK_8R8G8B( v2->color[0], \
1189 v2->color[1], v2->color[2] );
1190 #define RENDER_SPAN( span ) \
1192 for (i = 0; i < span->end; i++) { \
1193 pRow[i] = (PIXEL_TYPE) p; \
1196 #include "swrast/s_tritemp.h"
1201 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1203 static void flat_8R8G8B24_triangle( GLcontext
*ctx
,
1206 const SWvertex
*v2
)
1208 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1209 const GLubyte
*color
= v2
->color
;
1210 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1211 #define PIXEL_TYPE bgr_t
1212 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1213 #define RENDER_SPAN( span ) \
1215 PIXEL_TYPE *pixel = pRow; \
1216 for (i = 0; i < span->end; i++, pixel++) { \
1217 pixel->r = color[RCOMP]; \
1218 pixel->g = color[GCOMP]; \
1219 pixel->b = color[BCOMP]; \
1222 #include "swrast/s_tritemp.h"
1226 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1228 static void flat_TRUEDITHER_triangle( GLcontext
*ctx
,
1231 const SWvertex
*v2
)
1233 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1234 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1236 #define RENDER_SPAN( span ) \
1238 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1239 for (i = 0; i < span->end; i++, x++) { \
1241 PACK_TRUEDITHER(p, x, y, v2->color[0], \
1242 v2->color[1], v2->color[2] ); \
1243 XMesaPutPixel(img, x, y, p); \
1246 #include "swrast/s_tritemp.h"
1252 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1254 static void flat_5R6G5B_triangle( GLcontext
*ctx
,
1257 const SWvertex
*v2
)
1259 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1260 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1261 #define PIXEL_TYPE GLushort
1262 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1263 #define SETUP_CODE \
1264 unsigned long p = PACK_5R6G5B( v2->color[0], \
1265 v2->color[1], v2->color[2] );
1266 #define RENDER_SPAN( span ) \
1268 for (i = 0; i < span->end; i++) { \
1269 pRow[i] = (PIXEL_TYPE) p; \
1272 #include "swrast/s_tritemp.h"
1277 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1279 static void flat_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
1282 const SWvertex
*v2
)
1284 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1285 const GLubyte
*color
= v2
->color
;
1286 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1287 #define PIXEL_TYPE GLushort
1288 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1289 #define RENDER_SPAN( span ) \
1291 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1292 for (i = 0; i < span->end; i++, x++) { \
1293 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
1294 color[GCOMP], color[BCOMP]); \
1297 #include "swrast/s_tritemp.h"
1302 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1304 static void flat_DITHER8_triangle( GLcontext
*ctx
,
1307 const SWvertex
*v2
)
1309 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1310 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1311 #define PIXEL_TYPE GLubyte
1312 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1313 #define SETUP_CODE \
1314 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1316 #define RENDER_SPAN( span ) \
1318 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1319 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
1320 for (i = 0; i < span->end; i++, x++) { \
1321 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
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( v2->color[0], v2->color[1], v2->color[2] );
1341 #define RENDER_SPAN( span ) \
1343 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1344 FLAT_DITHER_ROW_SETUP(y); \
1345 for (i = 0; i < span->end; i++, x++) { \
1346 unsigned long p = FLAT_DITHER(x); \
1347 XMesaPutPixel(img, x, y, 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 = v2->color[0]; \
1368 GLubyte g = v2->color[1]; \
1369 GLubyte b = v2->color[2];
1370 #define RENDER_SPAN( span ) \
1372 GLint x = span->x, y = FLIP(xmesa->xm_buffer, span->y); \
1373 for (i = 0; i < span->end; i++, x++) { \
1374 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
1377 #include "swrast/s_tritemp.h"
1382 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1384 static void flat_LOOKUP8_triangle( GLcontext
*ctx
,
1387 const SWvertex
*v2
)
1389 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1390 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1391 #define PIXEL_TYPE GLubyte
1392 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1393 #define SETUP_CODE \
1395 GLubyte r = v2->color[0]; \
1396 GLubyte g = v2->color[1]; \
1397 GLubyte b = v2->color[2]; \
1398 GLubyte p = LOOKUP(r,g,b);
1399 #define RENDER_SPAN( span ) \
1401 for (i = 0; i < span->end; i++) { \
1402 pRow[i] = (PIXEL_TYPE) p; \
1405 #include "swrast/s_tritemp.h"
1410 extern void _xmesa_print_triangle_func( swrast_tri_func triFunc
);
1411 void _xmesa_print_triangle_func( swrast_tri_func triFunc
)
1413 printf("XMesa tri func = ");
1414 if (triFunc
==smooth_TRUECOLOR_z_triangle
)
1415 printf("smooth_TRUECOLOR_z_triangle\n");
1416 else if (triFunc
==smooth_8A8B8G8R_z_triangle
)
1417 printf("smooth_8A8B8G8R_z_triangle\n");
1418 else if (triFunc
==smooth_8R8G8B_z_triangle
)
1419 printf("smooth_8R8G8B_z_triangle\n");
1420 else if (triFunc
==smooth_8R8G8B24_z_triangle
)
1421 printf("smooth_8R8G8B24_z_triangle\n");
1422 else if (triFunc
==smooth_TRUEDITHER_z_triangle
)
1423 printf("smooth_TRUEDITHER_z_triangle\n");
1424 else if (triFunc
==smooth_5R6G5B_z_triangle
)
1425 printf("smooth_5R6G5B_z_triangle\n");
1426 else if (triFunc
==smooth_DITHER_5R6G5B_z_triangle
)
1427 printf("smooth_DITHER_5R6G5B_z_triangle\n");
1428 else if (triFunc
==smooth_HPCR_z_triangle
)
1429 printf("smooth_HPCR_z_triangle\n");
1430 else if (triFunc
==smooth_DITHER8_z_triangle
)
1431 printf("smooth_DITHER8_z_triangle\n");
1432 else if (triFunc
==smooth_LOOKUP8_z_triangle
)
1433 printf("smooth_LOOKUP8_z_triangle\n");
1434 else if (triFunc
==flat_TRUECOLOR_z_triangle
)
1435 printf("flat_TRUECOLOR_z_triangle\n");
1436 else if (triFunc
==flat_8A8B8G8R_z_triangle
)
1437 printf("flat_8A8B8G8R_z_triangle\n");
1438 else if (triFunc
==flat_8R8G8B_z_triangle
)
1439 printf("flat_8R8G8B_z_triangle\n");
1440 else if (triFunc
==flat_8R8G8B24_z_triangle
)
1441 printf("flat_8R8G8B24_z_triangle\n");
1442 else if (triFunc
==flat_TRUEDITHER_z_triangle
)
1443 printf("flat_TRUEDITHER_z_triangle\n");
1444 else if (triFunc
==flat_5R6G5B_z_triangle
)
1445 printf("flat_5R6G5B_z_triangle\n");
1446 else if (triFunc
==flat_DITHER_5R6G5B_z_triangle
)
1447 printf("flat_DITHER_5R6G5B_z_triangle\n");
1448 else if (triFunc
==flat_HPCR_z_triangle
)
1449 printf("flat_HPCR_z_triangle\n");
1450 else if (triFunc
==flat_DITHER8_z_triangle
)
1451 printf("flat_DITHER8_z_triangle\n");
1452 else if (triFunc
==flat_LOOKUP8_z_triangle
)
1453 printf("flat_LOOKUP8_z_triangle\n");
1454 else if (triFunc
==smooth_TRUECOLOR_triangle
)
1455 printf("smooth_TRUECOLOR_triangle\n");
1456 else if (triFunc
==smooth_8A8B8G8R_triangle
)
1457 printf("smooth_8A8B8G8R_triangle\n");
1458 else if (triFunc
==smooth_8R8G8B_triangle
)
1459 printf("smooth_8R8G8B_triangle\n");
1460 else if (triFunc
==smooth_8R8G8B24_triangle
)
1461 printf("smooth_8R8G8B24_triangle\n");
1462 else if (triFunc
==smooth_TRUEDITHER_triangle
)
1463 printf("smooth_TRUEDITHER_triangle\n");
1464 else if (triFunc
==smooth_5R6G5B_triangle
)
1465 printf("smooth_5R6G5B_triangle\n");
1466 else if (triFunc
==smooth_DITHER_5R6G5B_triangle
)
1467 printf("smooth_DITHER_5R6G5B_triangle\n");
1468 else if (triFunc
==smooth_HPCR_triangle
)
1469 printf("smooth_HPCR_triangle\n");
1470 else if (triFunc
==smooth_DITHER8_triangle
)
1471 printf("smooth_DITHER8_triangle\n");
1472 else if (triFunc
==smooth_LOOKUP8_triangle
)
1473 printf("smooth_LOOKUP8_triangle\n");
1474 else if (triFunc
==flat_TRUECOLOR_triangle
)
1475 printf("flat_TRUECOLOR_triangle\n");
1476 else if (triFunc
==flat_TRUEDITHER_triangle
)
1477 printf("flat_TRUEDITHER_triangle\n");
1478 else if (triFunc
==flat_8A8B8G8R_triangle
)
1479 printf("flat_8A8B8G8R_triangle\n");
1480 else if (triFunc
==flat_8R8G8B_triangle
)
1481 printf("flat_8R8G8B_triangle\n");
1482 else if (triFunc
==flat_8R8G8B24_triangle
)
1483 printf("flat_8R8G8B24_triangle\n");
1484 else if (triFunc
==flat_5R6G5B_triangle
)
1485 printf("flat_5R6G5B_triangle\n");
1486 else if (triFunc
==flat_DITHER_5R6G5B_triangle
)
1487 printf("flat_DITHER_5R6G5B_triangle\n");
1488 else if (triFunc
==flat_HPCR_triangle
)
1489 printf("flat_HPCR_triangle\n");
1490 else if (triFunc
==flat_DITHER8_triangle
)
1491 printf("flat_DITHER8_triangle\n");
1492 else if (triFunc
==flat_LOOKUP8_triangle
)
1493 printf("flat_LOOKUP8_triangle\n");
1502 /* record the current triangle function name */
1503 static const char *triFuncName
= NULL
;
1505 #define USE(triFunc) \
1507 triFuncName = #triFunc; \
1513 #define USE(triFunc) return triFunc
1518 static swrast_tri_func
get_triangle_func( GLcontext
*ctx
)
1520 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1521 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1522 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
1530 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1531 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1532 if (ctx
->Texture
._ReallyEnabled
) return (swrast_tri_func
) NULL
;
1533 if (swrast
->_RasterMask
& MULTI_DRAW_BIT
) return (swrast_tri_func
) NULL
;
1535 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
1536 if ( ctx
->Light
.ShadeModel
==GL_SMOOTH
1537 && swrast
->_RasterMask
==DEPTH_BIT
1538 && ctx
->Depth
.Func
==GL_LESS
1539 && ctx
->Depth
.Mask
==GL_TRUE
1540 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1541 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1542 switch (xmesa
->pixelformat
) {
1544 USE(smooth_TRUECOLOR_z_triangle
);
1546 USE(smooth_8A8B8G8R_z_triangle
);
1548 USE(smooth_8R8G8B_z_triangle
);
1550 USE(smooth_8R8G8B24_z_triangle
);
1552 USE(smooth_TRUEDITHER_z_triangle
);
1554 USE(smooth_5R6G5B_z_triangle
);
1555 case PF_DITHER_5R6G5B
:
1556 USE(smooth_DITHER_5R6G5B_z_triangle
);
1558 USE(smooth_HPCR_z_triangle
);
1561 USE(smooth_DITHER8_z_triangle
);
1563 USE(smooth_DITHER_z_triangle
);
1567 USE(smooth_LOOKUP8_z_triangle
);
1569 return (swrast_tri_func
) NULL
;
1571 return (swrast_tri_func
) NULL
;
1574 if ( ctx
->Light
.ShadeModel
==GL_FLAT
1575 && swrast
->_RasterMask
==DEPTH_BIT
1576 && ctx
->Depth
.Func
==GL_LESS
1577 && ctx
->Depth
.Mask
==GL_TRUE
1578 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1579 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1580 switch (xmesa
->pixelformat
) {
1582 USE(flat_TRUECOLOR_z_triangle
);
1584 USE(flat_8A8B8G8R_z_triangle
);
1586 USE(flat_8R8G8B_z_triangle
);
1588 USE(flat_8R8G8B24_z_triangle
);
1590 USE(flat_TRUEDITHER_z_triangle
);
1592 USE(flat_5R6G5B_z_triangle
);
1593 case PF_DITHER_5R6G5B
:
1594 USE(flat_DITHER_5R6G5B_z_triangle
);
1596 USE(flat_HPCR_z_triangle
);
1599 USE(flat_DITHER8_z_triangle
);
1601 USE(flat_DITHER_z_triangle
);
1605 USE(flat_LOOKUP8_z_triangle
);
1607 return (swrast_tri_func
) NULL
;
1609 return (swrast_tri_func
) NULL
;
1612 if ( swrast
->_RasterMask
==0 /* no depth test */
1613 && ctx
->Light
.ShadeModel
==GL_SMOOTH
1614 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1615 switch (xmesa
->pixelformat
) {
1617 USE(smooth_TRUECOLOR_triangle
);
1619 USE(smooth_8A8B8G8R_triangle
);
1621 USE(smooth_8R8G8B_triangle
);
1623 USE(smooth_8R8G8B24_triangle
);
1625 USE(smooth_TRUEDITHER_triangle
);
1627 USE(smooth_5R6G5B_triangle
);
1628 case PF_DITHER_5R6G5B
:
1629 USE(smooth_DITHER_5R6G5B_triangle
);
1631 USE(smooth_HPCR_triangle
);
1634 USE(smooth_DITHER8_triangle
);
1636 USE(smooth_DITHER_triangle
);
1640 USE(smooth_LOOKUP8_triangle
);
1642 return (swrast_tri_func
) NULL
;
1644 return (swrast_tri_func
) NULL
;
1648 if ( swrast
->_RasterMask
==0 /* no depth test */
1649 && ctx
->Light
.ShadeModel
==GL_FLAT
1650 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1651 switch (xmesa
->pixelformat
) {
1653 USE(flat_TRUECOLOR_triangle
);
1655 USE(flat_TRUEDITHER_triangle
);
1657 USE(flat_8A8B8G8R_triangle
);
1659 USE(flat_8R8G8B_triangle
);
1661 USE(flat_8R8G8B24_triangle
);
1663 USE(flat_5R6G5B_triangle
);
1664 case PF_DITHER_5R6G5B
:
1665 USE(flat_DITHER_5R6G5B_triangle
);
1667 USE(flat_HPCR_triangle
);
1670 USE(flat_DITHER8_triangle
);
1672 USE(flat_DITHER_triangle
);
1676 USE(flat_LOOKUP8_triangle
);
1678 return (swrast_tri_func
) NULL
;
1680 return (swrast_tri_func
) NULL
;
1684 return (swrast_tri_func
) NULL
;
1687 /* draw to pixmap */
1688 return (swrast_tri_func
) NULL
;
1693 /* Override for the swrast tri-selection function. Try to use one
1694 * of our internal tri functions, otherwise fall back to the
1695 * standard swrast functions.
1697 void xmesa_choose_triangle( GLcontext
*ctx
)
1699 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1701 if (!(swrast
->Triangle
= get_triangle_func( ctx
)))
1702 _swrast_choose_triangle( ctx
);