1 /* $Id: xm_tri.c,v 1.29 2002/10/30 20:24:47 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 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
;
1047 #define INTERP_RGB 1
1048 #define RENDER_SPAN( span ) \
1050 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1052 for (i = 0; i < span.end; i++, x++) { \
1053 unsigned long p = XDITHER(x, FixedToInt(span.red), \
1054 FixedToInt(span.green), FixedToInt(span.blue) ); \
1055 XMesaPutPixel(img, x, y, p); \
1056 span.red += span.redStep; \
1057 span.green += span.greenStep; \
1058 span.blue += span.blueStep; \
1061 #include "swrast/s_tritemp.h"
1066 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1068 static void smooth_LOOKUP8_triangle( GLcontext
*ctx
,
1071 const SWvertex
*v2
)
1073 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1074 #define INTERP_RGB 1
1075 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1076 #define PIXEL_TYPE GLubyte
1077 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1078 #define RENDER_SPAN( span ) \
1081 for (i = 0; i < span.end; i++) { \
1082 pRow[i] = LOOKUP(FixedToInt(span.red), \
1083 FixedToInt(span.green), FixedToInt(span.blue));\
1084 span.red += span.redStep; \
1085 span.green += span.greenStep; \
1086 span.blue += span.blueStep; \
1089 #include "swrast/s_tritemp.h"
1095 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
1097 static void smooth_HPCR_triangle( GLcontext
*ctx
,
1100 const SWvertex
*v2
)
1102 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1103 #define INTERP_RGB 1
1104 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1105 #define PIXEL_TYPE GLubyte
1106 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1107 #define RENDER_SPAN( span ) \
1109 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1110 for (i = 0; i < span.end; i++, x++) { \
1111 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
1112 FixedToInt(span.green), FixedToInt(span.blue)); \
1113 span.red += span.redStep; \
1114 span.green += span.greenStep; \
1115 span.blue += span.blueStep; \
1118 #include "swrast/s_tritemp.h"
1123 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
1125 static void flat_TRUECOLOR_triangle( GLcontext
*ctx
,
1128 const SWvertex
*v2
)
1130 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1131 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1132 #define SETUP_CODE \
1133 unsigned long pixel; \
1134 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
1136 #define RENDER_SPAN( span ) \
1138 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1139 for (i = 0; i < span.end; i++, x++) { \
1140 XMesaPutPixel(img, x, y, pixel); \
1143 #include "swrast/s_tritemp.h"
1148 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
1150 static void flat_8A8B8G8R_triangle( GLcontext
*ctx
,
1153 const SWvertex
*v2
)
1155 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1156 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1157 #define PIXEL_TYPE GLuint
1158 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1159 #define SETUP_CODE \
1160 unsigned long p = PACK_8B8G8R( v2->color[0], \
1161 v2->color[1], v2->color[2] );
1162 #define RENDER_SPAN( span ) \
1164 for (i = 0; i < span.end; i++) { \
1165 pRow[i] = (PIXEL_TYPE) p; \
1168 #include "swrast/s_tritemp.h"
1173 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1175 static void flat_8R8G8B_triangle( GLcontext
*ctx
,
1178 const SWvertex
*v2
)
1180 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1181 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1182 #define PIXEL_TYPE GLuint
1183 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1184 #define SETUP_CODE \
1185 unsigned long p = PACK_8R8G8B( v2->color[0], \
1186 v2->color[1], v2->color[2] );
1187 #define RENDER_SPAN( span ) \
1189 for (i = 0; i < span.end; i++) { \
1190 pRow[i] = (PIXEL_TYPE) p; \
1193 #include "swrast/s_tritemp.h"
1198 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1200 static void flat_8R8G8B24_triangle( GLcontext
*ctx
,
1203 const SWvertex
*v2
)
1205 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1206 const GLubyte
*color
= v2
->color
;
1207 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1208 #define PIXEL_TYPE bgr_t
1209 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1210 #define RENDER_SPAN( span ) \
1212 PIXEL_TYPE *pixel = pRow; \
1213 for (i = 0; i < span.end; i++, pixel++) { \
1214 pixel->r = color[RCOMP]; \
1215 pixel->g = color[GCOMP]; \
1216 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 RENDER_SPAN( span ) \
1234 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1235 for (i = 0; i < span.end; i++, x++) { \
1237 PACK_TRUEDITHER(p, x, y, v2->color[0], \
1238 v2->color[1], v2->color[2] ); \
1239 XMesaPutPixel(img, x, y, 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( v2->color[0], \
1261 v2->color[1], v2->color[2] );
1262 #define RENDER_SPAN( span ) \
1264 for (i = 0; i < span.end; i++) { \
1265 pRow[i] = (PIXEL_TYPE) p; \
1268 #include "swrast/s_tritemp.h"
1273 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1275 static void flat_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
1278 const SWvertex
*v2
)
1280 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1281 const GLubyte
*color
= v2
->color
;
1282 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1283 #define PIXEL_TYPE GLushort
1284 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1285 #define RENDER_SPAN( span ) \
1287 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1288 for (i = 0; i < span.end; i++, x++) { \
1289 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
1290 color[GCOMP], color[BCOMP]); \
1293 #include "swrast/s_tritemp.h"
1298 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1300 static void flat_DITHER8_triangle( GLcontext
*ctx
,
1303 const SWvertex
*v2
)
1305 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1306 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1307 #define PIXEL_TYPE GLubyte
1308 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1309 #define SETUP_CODE \
1310 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1312 #define RENDER_SPAN( span ) \
1314 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1315 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
1316 for (i = 0; i < span.end; i++, x++) { \
1317 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
1320 #include "swrast/s_tritemp.h"
1325 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1327 static void flat_DITHER_triangle( GLcontext
*ctx
,
1330 const SWvertex
*v2
)
1332 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1333 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1334 #define SETUP_CODE \
1335 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1337 #define RENDER_SPAN( span ) \
1339 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1340 FLAT_DITHER_ROW_SETUP(y); \
1341 for (i = 0; i < span.end; i++, x++) { \
1342 unsigned long p = FLAT_DITHER(x); \
1343 XMesaPutPixel(img, x, y, p ); \
1346 #include "swrast/s_tritemp.h"
1351 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1353 static void flat_HPCR_triangle( GLcontext
*ctx
,
1356 const SWvertex
*v2
)
1358 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1359 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1360 #define PIXEL_TYPE GLubyte
1361 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1362 #define SETUP_CODE \
1363 GLubyte r = v2->color[0]; \
1364 GLubyte g = v2->color[1]; \
1365 GLubyte b = v2->color[2];
1366 #define RENDER_SPAN( span ) \
1368 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1369 for (i = 0; i < span.end; i++, x++) { \
1370 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
1373 #include "swrast/s_tritemp.h"
1378 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1380 static void flat_LOOKUP8_triangle( GLcontext
*ctx
,
1383 const SWvertex
*v2
)
1385 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1386 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1387 #define PIXEL_TYPE GLubyte
1388 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1389 #define SETUP_CODE \
1391 GLubyte r = v2->color[0]; \
1392 GLubyte g = v2->color[1]; \
1393 GLubyte b = v2->color[2]; \
1394 GLubyte p = LOOKUP(r,g,b);
1395 #define RENDER_SPAN( span ) \
1397 for (i = 0; i < span.end; i++) { \
1398 pRow[i] = (PIXEL_TYPE) p; \
1401 #include "swrast/s_tritemp.h"
1406 extern void _xmesa_print_triangle_func( swrast_tri_func triFunc
);
1407 void _xmesa_print_triangle_func( swrast_tri_func triFunc
)
1409 _mesa_printf("XMesa tri func = ");
1410 if (triFunc
==smooth_TRUECOLOR_z_triangle
)
1411 _mesa_printf("smooth_TRUECOLOR_z_triangle\n");
1412 else if (triFunc
==smooth_8A8B8G8R_z_triangle
)
1413 _mesa_printf("smooth_8A8B8G8R_z_triangle\n");
1414 else if (triFunc
==smooth_8R8G8B_z_triangle
)
1415 _mesa_printf("smooth_8R8G8B_z_triangle\n");
1416 else if (triFunc
==smooth_8R8G8B24_z_triangle
)
1417 _mesa_printf("smooth_8R8G8B24_z_triangle\n");
1418 else if (triFunc
==smooth_TRUEDITHER_z_triangle
)
1419 _mesa_printf("smooth_TRUEDITHER_z_triangle\n");
1420 else if (triFunc
==smooth_5R6G5B_z_triangle
)
1421 _mesa_printf("smooth_5R6G5B_z_triangle\n");
1422 else if (triFunc
==smooth_DITHER_5R6G5B_z_triangle
)
1423 _mesa_printf("smooth_DITHER_5R6G5B_z_triangle\n");
1424 else if (triFunc
==smooth_HPCR_z_triangle
)
1425 _mesa_printf("smooth_HPCR_z_triangle\n");
1426 else if (triFunc
==smooth_DITHER8_z_triangle
)
1427 _mesa_printf("smooth_DITHER8_z_triangle\n");
1428 else if (triFunc
==smooth_LOOKUP8_z_triangle
)
1429 _mesa_printf("smooth_LOOKUP8_z_triangle\n");
1430 else if (triFunc
==flat_TRUECOLOR_z_triangle
)
1431 _mesa_printf("flat_TRUECOLOR_z_triangle\n");
1432 else if (triFunc
==flat_8A8B8G8R_z_triangle
)
1433 _mesa_printf("flat_8A8B8G8R_z_triangle\n");
1434 else if (triFunc
==flat_8R8G8B_z_triangle
)
1435 _mesa_printf("flat_8R8G8B_z_triangle\n");
1436 else if (triFunc
==flat_8R8G8B24_z_triangle
)
1437 _mesa_printf("flat_8R8G8B24_z_triangle\n");
1438 else if (triFunc
==flat_TRUEDITHER_z_triangle
)
1439 _mesa_printf("flat_TRUEDITHER_z_triangle\n");
1440 else if (triFunc
==flat_5R6G5B_z_triangle
)
1441 _mesa_printf("flat_5R6G5B_z_triangle\n");
1442 else if (triFunc
==flat_DITHER_5R6G5B_z_triangle
)
1443 _mesa_printf("flat_DITHER_5R6G5B_z_triangle\n");
1444 else if (triFunc
==flat_HPCR_z_triangle
)
1445 _mesa_printf("flat_HPCR_z_triangle\n");
1446 else if (triFunc
==flat_DITHER8_z_triangle
)
1447 _mesa_printf("flat_DITHER8_z_triangle\n");
1448 else if (triFunc
==flat_LOOKUP8_z_triangle
)
1449 _mesa_printf("flat_LOOKUP8_z_triangle\n");
1450 else if (triFunc
==smooth_TRUECOLOR_triangle
)
1451 _mesa_printf("smooth_TRUECOLOR_triangle\n");
1452 else if (triFunc
==smooth_8A8B8G8R_triangle
)
1453 _mesa_printf("smooth_8A8B8G8R_triangle\n");
1454 else if (triFunc
==smooth_8R8G8B_triangle
)
1455 _mesa_printf("smooth_8R8G8B_triangle\n");
1456 else if (triFunc
==smooth_8R8G8B24_triangle
)
1457 _mesa_printf("smooth_8R8G8B24_triangle\n");
1458 else if (triFunc
==smooth_TRUEDITHER_triangle
)
1459 _mesa_printf("smooth_TRUEDITHER_triangle\n");
1460 else if (triFunc
==smooth_5R6G5B_triangle
)
1461 _mesa_printf("smooth_5R6G5B_triangle\n");
1462 else if (triFunc
==smooth_DITHER_5R6G5B_triangle
)
1463 _mesa_printf("smooth_DITHER_5R6G5B_triangle\n");
1464 else if (triFunc
==smooth_HPCR_triangle
)
1465 _mesa_printf("smooth_HPCR_triangle\n");
1466 else if (triFunc
==smooth_DITHER8_triangle
)
1467 _mesa_printf("smooth_DITHER8_triangle\n");
1468 else if (triFunc
==smooth_LOOKUP8_triangle
)
1469 _mesa_printf("smooth_LOOKUP8_triangle\n");
1470 else if (triFunc
==flat_TRUECOLOR_triangle
)
1471 _mesa_printf("flat_TRUECOLOR_triangle\n");
1472 else if (triFunc
==flat_TRUEDITHER_triangle
)
1473 _mesa_printf("flat_TRUEDITHER_triangle\n");
1474 else if (triFunc
==flat_8A8B8G8R_triangle
)
1475 _mesa_printf("flat_8A8B8G8R_triangle\n");
1476 else if (triFunc
==flat_8R8G8B_triangle
)
1477 _mesa_printf("flat_8R8G8B_triangle\n");
1478 else if (triFunc
==flat_8R8G8B24_triangle
)
1479 _mesa_printf("flat_8R8G8B24_triangle\n");
1480 else if (triFunc
==flat_5R6G5B_triangle
)
1481 _mesa_printf("flat_5R6G5B_triangle\n");
1482 else if (triFunc
==flat_DITHER_5R6G5B_triangle
)
1483 _mesa_printf("flat_DITHER_5R6G5B_triangle\n");
1484 else if (triFunc
==flat_HPCR_triangle
)
1485 _mesa_printf("flat_HPCR_triangle\n");
1486 else if (triFunc
==flat_DITHER8_triangle
)
1487 _mesa_printf("flat_DITHER8_triangle\n");
1488 else if (triFunc
==flat_LOOKUP8_triangle
)
1489 _mesa_printf("flat_LOOKUP8_triangle\n");
1491 _mesa_printf("???\n");
1498 /* record the current triangle function name */
1499 static const char *triFuncName
= NULL
;
1501 #define USE(triFunc) \
1503 triFuncName = #triFunc; \
1509 #define USE(triFunc) return triFunc
1514 static swrast_tri_func
get_triangle_func( GLcontext
*ctx
)
1516 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1517 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1518 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
1526 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1527 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1528 if (ctx
->Texture
._EnabledUnits
) return (swrast_tri_func
) NULL
;
1529 if (swrast
->_RasterMask
& MULTI_DRAW_BIT
) return (swrast_tri_func
) NULL
;
1530 if (ctx
->Polygon
.CullFlag
&&
1531 ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
1532 return (swrast_tri_func
) NULL
;
1534 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
1535 if ( ctx
->Light
.ShadeModel
==GL_SMOOTH
1536 && swrast
->_RasterMask
==DEPTH_BIT
1537 && ctx
->Depth
.Func
==GL_LESS
1538 && ctx
->Depth
.Mask
==GL_TRUE
1539 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1540 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1541 switch (xmesa
->pixelformat
) {
1543 USE(smooth_TRUECOLOR_z_triangle
);
1545 USE(smooth_8A8B8G8R_z_triangle
);
1547 USE(smooth_8R8G8B_z_triangle
);
1549 USE(smooth_8R8G8B24_z_triangle
);
1551 USE(smooth_TRUEDITHER_z_triangle
);
1553 USE(smooth_5R6G5B_z_triangle
);
1554 case PF_DITHER_5R6G5B
:
1555 USE(smooth_DITHER_5R6G5B_z_triangle
);
1557 USE(smooth_HPCR_z_triangle
);
1560 USE(smooth_DITHER8_z_triangle
);
1562 USE(smooth_DITHER_z_triangle
);
1566 USE(smooth_LOOKUP8_z_triangle
);
1568 return (swrast_tri_func
) NULL
;
1570 return (swrast_tri_func
) NULL
;
1573 if ( ctx
->Light
.ShadeModel
==GL_FLAT
1574 && swrast
->_RasterMask
==DEPTH_BIT
1575 && ctx
->Depth
.Func
==GL_LESS
1576 && ctx
->Depth
.Mask
==GL_TRUE
1577 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1578 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1579 switch (xmesa
->pixelformat
) {
1581 USE(flat_TRUECOLOR_z_triangle
);
1583 USE(flat_8A8B8G8R_z_triangle
);
1585 USE(flat_8R8G8B_z_triangle
);
1587 USE(flat_8R8G8B24_z_triangle
);
1589 USE(flat_TRUEDITHER_z_triangle
);
1591 USE(flat_5R6G5B_z_triangle
);
1592 case PF_DITHER_5R6G5B
:
1593 USE(flat_DITHER_5R6G5B_z_triangle
);
1595 USE(flat_HPCR_z_triangle
);
1598 USE(flat_DITHER8_z_triangle
);
1600 USE(flat_DITHER_z_triangle
);
1604 USE(flat_LOOKUP8_z_triangle
);
1606 return (swrast_tri_func
) NULL
;
1608 return (swrast_tri_func
) NULL
;
1611 if ( swrast
->_RasterMask
==0 /* no depth test */
1612 && ctx
->Light
.ShadeModel
==GL_SMOOTH
1613 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1614 switch (xmesa
->pixelformat
) {
1616 USE(smooth_TRUECOLOR_triangle
);
1618 USE(smooth_8A8B8G8R_triangle
);
1620 USE(smooth_8R8G8B_triangle
);
1622 USE(smooth_8R8G8B24_triangle
);
1624 USE(smooth_TRUEDITHER_triangle
);
1626 USE(smooth_5R6G5B_triangle
);
1627 case PF_DITHER_5R6G5B
:
1628 USE(smooth_DITHER_5R6G5B_triangle
);
1630 USE(smooth_HPCR_triangle
);
1633 USE(smooth_DITHER8_triangle
);
1635 USE(smooth_DITHER_triangle
);
1639 USE(smooth_LOOKUP8_triangle
);
1641 return (swrast_tri_func
) NULL
;
1643 return (swrast_tri_func
) NULL
;
1647 if ( swrast
->_RasterMask
==0 /* no depth test */
1648 && ctx
->Light
.ShadeModel
==GL_FLAT
1649 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1650 switch (xmesa
->pixelformat
) {
1652 USE(flat_TRUECOLOR_triangle
);
1654 USE(flat_TRUEDITHER_triangle
);
1656 USE(flat_8A8B8G8R_triangle
);
1658 USE(flat_8R8G8B_triangle
);
1660 USE(flat_8R8G8B24_triangle
);
1662 USE(flat_5R6G5B_triangle
);
1663 case PF_DITHER_5R6G5B
:
1664 USE(flat_DITHER_5R6G5B_triangle
);
1666 USE(flat_HPCR_triangle
);
1669 USE(flat_DITHER8_triangle
);
1671 USE(flat_DITHER_triangle
);
1675 USE(flat_LOOKUP8_triangle
);
1677 return (swrast_tri_func
) NULL
;
1679 return (swrast_tri_func
) NULL
;
1683 return (swrast_tri_func
) NULL
;
1686 /* draw to pixmap */
1687 return (swrast_tri_func
) NULL
;
1692 /* Override for the swrast tri-selection function. Try to use one
1693 * of our internal tri functions, otherwise fall back to the
1694 * standard swrast functions.
1696 void xmesa_choose_triangle( GLcontext
*ctx
)
1698 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1700 if (!(swrast
->Triangle
= get_triangle_func( ctx
)))
1701 _swrast_choose_triangle( ctx
);