1 /* $Id: xm_tri.c,v 1.8 2000/11/06 17:28:20 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"
42 /* Internal swrast includes:
44 #include "swrast/s_context.h"
45 #include "swrast/s_depth.h"
46 #include "swrast/s_triangle.h"
51 /**********************************************************************/
52 /*** Triangle rendering ***/
53 /**********************************************************************/
58 * Render a triangle into a pixmap, any pixel format, flat shaded and
61 static void flat_pixmap_triangle( GLcontext
*ctx
,
66 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
72 if (xmesa
->xm_visual
->gl_visual
->RGBAflag
) {
73 pixel
= xmesa_color_to_pixel( xmesa
,
74 v0
->color
[0], v0
->color
[1],
75 v0
->color
[2], v0
->color
[3],
81 gc
= xmesa
->xm_buffer
->gc2
;
82 XMesaSetForeground( xmesa
->display
, gc
, pixel
);
84 p
[0].x
= (GLint
) (v0
->win
[0] + 0.5f
);
85 p
[0].y
= FLIP( xmesa
->xm_buffer
, (GLint
) (v0
->win
[1] - 0.5f
) );
86 p
[1].x
= (GLint
) (v1
->win
[0] + 0.5f
);
87 p
[1].y
= FLIP( xmesa
->xm_buffer
, (GLint
) (v1
->win
[1] - 0.5f
) );
88 p
[2].x
= (GLint
) (v2
->win
[0] + 0.5f
);
89 p
[2].y
= FLIP( xmesa
->xm_buffer
, (GLint
) (v2
->win
[1] - 0.5f
) );
90 XMesaFillPolygon( xmesa
->display
, xmesa
->xm_buffer
->buffer
, gc
,
91 p
, 3, Convex
, CoordModeOrigin
);
97 * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
99 static void smooth_TRUECOLOR_z_triangle( GLcontext
*ctx
,
104 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
105 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
107 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
109 #define INNER_LOOP( LEFT, RIGHT, Y ) \
111 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer, Y); \
112 GLint len = RIGHT-LEFT; \
114 for (i=0;i<len;i++,xx++) { \
115 GLdepth z = FixedToDepth(ffz); \
118 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
119 XMesaPutPixel( img, xx, yy, p ); \
122 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
126 #include "swrast/s_tritemp.h"
132 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
134 static void smooth_8A8B8G8R_z_triangle( GLcontext
*ctx
,
139 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
141 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
143 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
144 #define PIXEL_TYPE GLuint
145 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
146 #define INNER_LOOP( LEFT, RIGHT, Y ) \
148 GLint i, len = RIGHT-LEFT; \
150 for (i=0;i<len;i++) { \
151 GLdepth z = FixedToDepth(ffz); \
153 pRow[i] = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
157 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
161 #include "swrast/s_tritemp.h"
166 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
168 static void smooth_8R8G8B_z_triangle( GLcontext
*ctx
,
173 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
175 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
177 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
178 #define PIXEL_TYPE GLuint
179 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
180 #define INNER_LOOP( LEFT, RIGHT, Y ) \
182 GLint i, len = RIGHT-LEFT; \
184 for (i=0;i<len;i++) { \
185 GLdepth z = FixedToDepth(ffz); \
187 pRow[i] = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
191 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
195 #include "swrast/s_tritemp.h"
200 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
202 static void smooth_8R8G8B24_z_triangle( GLcontext
*ctx
,
207 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
209 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
211 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
212 #define PIXEL_TYPE bgr_t
213 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
214 #define INNER_LOOP( LEFT, RIGHT, Y ) \
216 GLint i, len = RIGHT-LEFT; \
218 for (i=0;i<len;i++) { \
219 GLdepth z = FixedToDepth(ffz); \
221 PIXEL_TYPE *ptr = pRow + i; \
222 ptr->r = FixedToInt(ffr); \
223 ptr->g = FixedToInt(ffg); \
224 ptr->b = FixedToInt(ffb); \
227 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
231 #include "swrast/s_tritemp.h"
236 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
238 static void smooth_TRUEDITHER_z_triangle( GLcontext
*ctx
,
243 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
244 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
246 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
248 #define INNER_LOOP( LEFT, RIGHT, Y ) \
250 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
252 for (i=0;i<len;i++,xx++) { \
253 GLdepth z = FixedToDepth(ffz); \
256 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), \
257 FixedToInt(ffg), FixedToInt(ffb) ); \
258 XMesaPutPixel( img, xx, yy, p ); \
261 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
265 #include "swrast/s_tritemp.h"
270 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
272 static void smooth_5R6G5B_z_triangle( GLcontext
*ctx
,
277 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
279 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
281 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
282 #define PIXEL_TYPE GLushort
283 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
284 #define INNER_LOOP( LEFT, RIGHT, Y ) \
286 GLint i, len = RIGHT-LEFT; \
288 for (i=0;i<len;i++) { \
289 DEPTH_TYPE z = FixedToDepth(ffz); \
291 pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
295 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
299 #include "swrast/s_tritemp.h"
304 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
306 static void smooth_DITHER_5R6G5B_z_triangle( GLcontext
*ctx
,
311 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
313 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
315 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
316 #define PIXEL_TYPE GLushort
317 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
318 #define INNER_LOOP( LEFT, RIGHT, Y ) \
320 GLint i, len = RIGHT-LEFT; \
322 for (i=0;i<len;i++) { \
323 GLdepth z = FixedToDepth(ffz); \
325 PACK_TRUEDITHER(pRow[i], LEFT+i, Y, FixedToInt(ffr), \
326 FixedToInt(ffg), FixedToInt(ffb) ); \
329 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
333 #include "swrast/s_tritemp.h"
338 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
340 static void smooth_DITHER8_z_triangle( GLcontext
*ctx
,
345 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
347 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
349 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
350 #define PIXEL_TYPE GLubyte
351 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
352 #define INNER_LOOP( LEFT, RIGHT, Y ) \
354 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
357 for (i=0;i<len;i++,xx++) { \
358 GLdepth z = FixedToDepth(ffz); \
360 pRow[i] = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
361 FixedToInt(ffg), FixedToInt(ffb) ); \
364 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
368 #include "swrast/s_tritemp.h"
373 * XImage, smooth, depth-buffered, PF_DITHER triangle.
375 static void smooth_DITHER_z_triangle( GLcontext
*ctx
,
380 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
381 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
383 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
385 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
386 #define PIXEL_TYPE GLubyte
387 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
388 #define INNER_LOOP( LEFT, RIGHT, Y ) \
390 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
393 for (i=0;i<len;i++,xx++) { \
394 GLdepth z = FixedToDepth(ffz); \
396 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
397 FixedToInt(ffg), FixedToInt(ffb) ); \
398 XMesaPutPixel( img, xx, yy, p ); \
401 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
405 #include "swrast/s_tritemp.h"
410 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
412 static void smooth_LOOKUP8_z_triangle( GLcontext
*ctx
,
417 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
419 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
421 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
422 #define PIXEL_TYPE GLubyte
423 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
424 #define INNER_LOOP( LEFT, RIGHT, Y ) \
426 GLint i, len = RIGHT-LEFT; \
429 for (i=0;i<len;i++) { \
430 GLdepth z = FixedToDepth(ffz); \
432 pRow[i] = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
436 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
440 #include "swrast/s_tritemp.h"
446 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
448 static void smooth_HPCR_z_triangle( GLcontext
*ctx
,
453 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
455 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
457 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
458 #define PIXEL_TYPE GLubyte
459 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
460 #define INNER_LOOP( LEFT, RIGHT, Y ) \
462 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
464 for (i=0;i<len;i++,xx++) { \
465 GLdepth z = FixedToDepth(ffz); \
467 pRow[i] = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
468 FixedToInt(ffg), FixedToInt(ffb) ); \
471 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
475 #include "swrast/s_tritemp.h"
480 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
482 static void flat_TRUECOLOR_z_triangle( GLcontext
*ctx
,
487 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
488 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
490 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
492 unsigned long pixel; \
493 PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
495 #define INNER_LOOP( LEFT, RIGHT, Y ) \
497 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
499 for (i=0;i<len;i++,xx++) { \
500 GLdepth z = FixedToDepth(ffz); \
502 XMesaPutPixel( img, xx, yy, pixel ); \
508 #include "swrast/s_tritemp.h"
513 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
515 static void flat_8A8B8G8R_z_triangle( GLcontext
*ctx
,
520 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
522 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
523 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
524 #define PIXEL_TYPE GLuint
525 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
527 unsigned long p = PACK_8B8G8R( v0->color[0], \
528 v0->color[1], v0->color[2] );
529 #define INNER_LOOP( LEFT, RIGHT, Y ) \
531 GLint i, len = RIGHT-LEFT; \
533 for (i=0;i<len;i++) { \
534 GLdepth z = FixedToDepth(ffz); \
536 pRow[i] = (PIXEL_TYPE) p; \
542 #include "swrast/s_tritemp.h"
547 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
549 static void flat_8R8G8B_z_triangle( GLcontext
*ctx
,
554 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
556 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
557 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
558 #define PIXEL_TYPE GLuint
559 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
561 unsigned long p = PACK_8R8G8B( v0->color[0], \
562 v0->color[1], v0->color[2] );
563 #define INNER_LOOP( LEFT, RIGHT, Y ) \
565 GLint i, len = RIGHT-LEFT; \
567 for (i=0;i<len;i++) { \
568 GLdepth z = FixedToDepth(ffz); \
570 pRow[i] = (PIXEL_TYPE) p; \
576 #include "swrast/s_tritemp.h"
581 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
583 static void flat_8R8G8B24_z_triangle( GLcontext
*ctx
,
588 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
589 const GLubyte
*color
= v0
->color
;
591 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
592 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
593 #define PIXEL_TYPE bgr_t
594 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
595 #define INNER_LOOP( LEFT, RIGHT, Y ) \
597 GLint i, len = RIGHT-LEFT; \
599 for (i=0;i<len;i++) { \
600 GLdepth z = FixedToDepth(ffz); \
602 PIXEL_TYPE *ptr = pRow+i; \
603 ptr->r = color[RCOMP]; \
604 ptr->g = color[GCOMP]; \
605 ptr->b = color[BCOMP]; \
611 #include "swrast/s_tritemp.h"
616 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
618 static void flat_TRUEDITHER_z_triangle( GLcontext
*ctx
,
623 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
624 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
626 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
627 #define INNER_LOOP( LEFT, RIGHT, Y ) \
629 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
631 for (i=0;i<len;i++,xx++) { \
632 GLdepth z = FixedToDepth(ffz); \
635 PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
636 v0->color[1], v0->color[2] ); \
637 XMesaPutPixel( img, xx, yy, p ); \
643 #include "swrast/s_tritemp.h"
648 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
650 static void flat_5R6G5B_z_triangle( GLcontext
*ctx
,
655 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
657 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
658 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
659 #define PIXEL_TYPE GLushort
660 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
662 unsigned long p = PACK_5R6G5B( v0->color[0], \
663 v0->color[1], v0->color[2] );
664 #define INNER_LOOP( LEFT, RIGHT, Y ) \
666 GLint i, len = RIGHT-LEFT; \
668 for (i=0;i<len;i++) { \
669 DEPTH_TYPE z = FixedToDepth(ffz); \
671 pRow[i] = (PIXEL_TYPE) p; \
677 #include "swrast/s_tritemp.h"
682 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
684 static void flat_DITHER_5R6G5B_z_triangle( GLcontext
*ctx
,
689 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
690 const GLubyte
*color
= v0
->color
;
692 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
693 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
694 #define PIXEL_TYPE GLushort
695 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
696 #define INNER_LOOP( LEFT, RIGHT, Y ) \
698 GLint i, len = RIGHT-LEFT; \
700 for (i=0;i<len;i++) { \
701 DEPTH_TYPE z = FixedToDepth(ffz); \
703 PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \
704 color[GCOMP], color[BCOMP]); \
710 #include "swrast/s_tritemp.h"
715 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
717 static void flat_DITHER8_z_triangle( GLcontext
*ctx
,
722 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
724 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
725 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
726 #define PIXEL_TYPE GLubyte
727 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
729 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
731 #define INNER_LOOP( LEFT, RIGHT, Y ) \
733 GLint i, xx = LEFT, len = RIGHT-LEFT; \
734 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
736 for (i=0;i<len;i++,xx++) { \
737 GLdepth z = FixedToDepth(ffz); \
739 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(xx); \
745 #include "swrast/s_tritemp.h"
750 * XImage, flat, depth-buffered, PF_DITHER triangle.
752 static void flat_DITHER_z_triangle( GLcontext
*ctx
,
757 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
758 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
760 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
762 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
764 #define INNER_LOOP( LEFT, RIGHT, Y ) \
766 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
767 FLAT_DITHER_ROW_SETUP(yy); \
769 for (i=0;i<len;i++,xx++) { \
770 GLdepth z = FixedToDepth(ffz); \
772 unsigned long p = FLAT_DITHER(xx); \
773 XMesaPutPixel( img, xx, yy, p ); \
779 #include "swrast/s_tritemp.h"
784 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
786 static void flat_HPCR_z_triangle( GLcontext
*ctx
,
791 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
793 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
794 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
795 #define PIXEL_TYPE GLubyte
796 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
798 GLubyte r = v0->color[0]; \
799 GLubyte g = v0->color[1]; \
800 GLubyte b = v0->color[2];
801 #define INNER_LOOP( LEFT, RIGHT, Y ) \
803 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
805 for (i=0;i<len;i++,xx++) { \
806 GLdepth z = FixedToDepth(ffz); \
808 pRow[i] = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
814 #include "swrast/s_tritemp.h"
819 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
821 static void flat_LOOKUP8_z_triangle( GLcontext
*ctx
,
826 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
828 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
829 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
830 #define PIXEL_TYPE GLubyte
831 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
834 GLubyte r = v0->color[0]; \
835 GLubyte g = v0->color[1]; \
836 GLubyte b = v0->color[2]; \
837 GLubyte p = LOOKUP(r,g,b);
838 #define INNER_LOOP( LEFT, RIGHT, Y ) \
840 GLint i, len = RIGHT-LEFT; \
842 for (i=0;i<len;i++) { \
843 GLdepth z = FixedToDepth(ffz); \
851 #include "swrast/s_tritemp.h"
857 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
859 static void smooth_TRUECOLOR_triangle( GLcontext
*ctx
,
864 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
865 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
867 #define INNER_LOOP( LEFT, RIGHT, Y ) \
869 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
870 for (xx=LEFT;xx<RIGHT;xx++) { \
872 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
873 XMesaPutPixel( img, xx, yy, p ); \
874 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
877 #include "swrast/s_tritemp.h"
882 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
884 static void smooth_8A8B8G8R_triangle( GLcontext
*ctx
,
889 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
891 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
892 #define PIXEL_TYPE GLuint
893 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
894 #define INNER_LOOP( LEFT, RIGHT, Y ) \
897 PIXEL_TYPE *pixel = pRow; \
898 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
899 *pixel = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
901 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
904 #include "swrast/s_tritemp.h"
909 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
911 static void smooth_8R8G8B_triangle( GLcontext
*ctx
,
916 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
918 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
919 #define PIXEL_TYPE GLuint
920 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
921 #define INNER_LOOP( LEFT, RIGHT, Y ) \
924 PIXEL_TYPE *pixel = pRow; \
925 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
926 *pixel = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
928 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
931 #include "swrast/s_tritemp.h"
936 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
938 static void smooth_8R8G8B24_triangle( GLcontext
*ctx
,
943 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
945 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
946 #define PIXEL_TYPE bgr_t
947 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
948 #define INNER_LOOP( LEFT, RIGHT, Y ) \
951 PIXEL_TYPE *pixel = pRow; \
952 for (xx=LEFT;xx<RIGHT;xx++) { \
953 pixel->r = FixedToInt(ffr); \
954 pixel->g = FixedToInt(ffg); \
955 pixel->b = FixedToInt(ffb); \
956 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
960 #include "swrast/s_tritemp.h"
965 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
967 static void smooth_TRUEDITHER_triangle( GLcontext
*ctx
,
972 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
973 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
975 #define INNER_LOOP( LEFT, RIGHT, Y ) \
977 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
978 for (xx=LEFT;xx<RIGHT;xx++) { \
980 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), FixedToInt(ffg), \
982 XMesaPutPixel( img, xx, yy, p ); \
983 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
986 #include "swrast/s_tritemp.h"
991 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
993 static void smooth_5R6G5B_triangle( GLcontext
*ctx
,
998 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1000 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1001 #define PIXEL_TYPE GLushort
1002 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1003 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1006 PIXEL_TYPE *pixel = pRow; \
1007 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1008 *pixel = (PIXEL_TYPE) PACK_5R6G5B( FixedToInt(ffr), \
1009 FixedToInt(ffg), FixedToInt(ffb) ); \
1010 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1013 #include "swrast/s_tritemp.h"
1018 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1020 static void smooth_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
1025 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1026 #define INTERP_RGB 1
1027 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1028 #define PIXEL_TYPE GLushort
1029 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1030 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1033 PIXEL_TYPE *pixel = pRow; \
1034 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1035 PACK_TRUEDITHER(*pixel, xx, Y, FixedToInt(ffr), \
1036 FixedToInt(ffg), FixedToInt(ffb) ); \
1037 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1040 #include "swrast/s_tritemp.h"
1045 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
1047 static void smooth_DITHER8_triangle( GLcontext
*ctx
,
1052 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1053 #define INTERP_RGB 1
1054 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1055 #define PIXEL_TYPE GLubyte
1056 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1057 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1059 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1060 PIXEL_TYPE *pixel = pRow; \
1061 XDITHER_SETUP(yy); \
1062 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1063 *pixel = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
1064 FixedToInt(ffg), FixedToInt(ffb) ); \
1065 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1068 #include "swrast/s_tritemp.h"
1073 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
1075 static void smooth_DITHER_triangle( GLcontext
*ctx
,
1080 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1081 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1083 #define INTERP_RGB 1
1084 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1086 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1087 XDITHER_SETUP(yy); \
1088 for (xx=LEFT;xx<RIGHT;xx++) { \
1089 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
1090 FixedToInt(ffg), FixedToInt(ffb) ); \
1091 XMesaPutPixel( img, xx, yy, p ); \
1092 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1095 #include "swrast/s_tritemp.h"
1100 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1102 static void smooth_LOOKUP8_triangle( GLcontext
*ctx
,
1107 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1109 #define INTERP_RGB 1
1110 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1111 #define PIXEL_TYPE GLubyte
1112 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1113 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1116 PIXEL_TYPE *pixel = pRow; \
1118 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1119 *pixel = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
1120 FixedToInt(ffb) ); \
1121 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1124 #include "swrast/s_tritemp.h"
1130 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
1132 static void smooth_HPCR_triangle( GLcontext
*ctx
,
1137 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1139 #define INTERP_RGB 1
1140 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1141 #define PIXEL_TYPE GLubyte
1142 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1143 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1145 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1146 PIXEL_TYPE *pixel = pRow; \
1147 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1148 *pixel = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
1149 FixedToInt(ffg), FixedToInt(ffb) ); \
1150 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1153 #include "swrast/s_tritemp.h"
1158 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
1160 static void flat_TRUECOLOR_triangle( GLcontext
*ctx
,
1165 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1166 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1167 #define SETUP_CODE \
1168 unsigned long pixel; \
1169 PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
1171 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1173 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1174 for (xx=LEFT;xx<RIGHT;xx++) { \
1175 XMesaPutPixel( img, xx, yy, pixel ); \
1178 #include "swrast/s_tritemp.h"
1183 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
1185 static void flat_8A8B8G8R_triangle( GLcontext
*ctx
,
1190 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1191 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1192 #define PIXEL_TYPE GLuint
1193 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1194 #define SETUP_CODE \
1195 unsigned long p = PACK_8B8G8R( v0->color[0], \
1196 v0->color[1], v0->color[2] );
1197 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1200 PIXEL_TYPE *pixel = pRow; \
1201 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1202 *pixel = (PIXEL_TYPE) p; \
1205 #include "swrast/s_tritemp.h"
1210 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1212 static void flat_8R8G8B_triangle( GLcontext
*ctx
,
1217 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1218 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1219 #define PIXEL_TYPE GLuint
1220 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1221 #define SETUP_CODE \
1222 unsigned long p = PACK_8R8G8B( v0->color[0], \
1223 v0->color[1], v0->color[2] );
1224 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1227 PIXEL_TYPE *pixel = pRow; \
1228 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1229 *pixel = (PIXEL_TYPE) p; \
1232 #include "swrast/s_tritemp.h"
1237 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1239 static void flat_8R8G8B24_triangle( GLcontext
*ctx
,
1244 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1245 const GLubyte
*color
= v0
->color
;
1246 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1247 #define PIXEL_TYPE bgr_t
1248 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1249 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1252 PIXEL_TYPE *pixel = pRow; \
1253 for (xx=LEFT;xx<RIGHT;xx++) { \
1254 pixel->r = color[RCOMP]; \
1255 pixel->g = color[GCOMP]; \
1256 pixel->b = color[BCOMP]; \
1260 #include "swrast/s_tritemp.h"
1264 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1266 static void flat_TRUEDITHER_triangle( GLcontext
*ctx
,
1271 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1272 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1273 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1275 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1276 for (xx=LEFT;xx<RIGHT;xx++) { \
1278 PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
1279 v0->color[1], v0->color[2] ); \
1280 XMesaPutPixel( img, xx, yy, p ); \
1283 #include "swrast/s_tritemp.h"
1289 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1291 static void flat_5R6G5B_triangle( GLcontext
*ctx
,
1296 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1297 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1298 #define PIXEL_TYPE GLushort
1299 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1300 #define SETUP_CODE \
1301 unsigned long p = PACK_5R6G5B( v0->color[0], \
1302 v0->color[1], v0->color[2] );
1303 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1306 PIXEL_TYPE *pixel = pRow; \
1307 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1308 *pixel = (PIXEL_TYPE) p; \
1311 #include "swrast/s_tritemp.h"
1316 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1318 static void flat_DITHER_5R6G5B_triangle( GLcontext
*ctx
,
1323 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1324 const GLubyte
*color
= v0
->color
;
1325 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1326 #define PIXEL_TYPE GLushort
1327 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1328 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1331 PIXEL_TYPE *pixel = pRow; \
1332 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1333 PACK_TRUEDITHER(*pixel, xx, Y, color[RCOMP], \
1334 color[GCOMP], color[BCOMP]); \
1337 #include "swrast/s_tritemp.h"
1342 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1344 static void flat_DITHER8_triangle( GLcontext
*ctx
,
1349 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1350 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1351 #define PIXEL_TYPE GLubyte
1352 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1353 #define SETUP_CODE \
1354 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
1356 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1359 PIXEL_TYPE *pixel = pRow; \
1360 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
1361 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1362 *pixel = (PIXEL_TYPE) FLAT_DITHER(xx); \
1365 #include "swrast/s_tritemp.h"
1370 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1372 static void flat_DITHER_triangle( GLcontext
*ctx
,
1377 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1378 XMesaImage
*img
= xmesa
->xm_buffer
->backimage
;
1379 #define SETUP_CODE \
1380 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
1382 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1384 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1385 FLAT_DITHER_ROW_SETUP(yy); \
1386 for (xx=LEFT;xx<RIGHT;xx++) { \
1387 unsigned long p = FLAT_DITHER(xx); \
1388 XMesaPutPixel( img, xx, yy, p ); \
1391 #include "swrast/s_tritemp.h"
1396 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1398 static void flat_HPCR_triangle( GLcontext
*ctx
,
1403 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1404 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1405 #define PIXEL_TYPE GLubyte
1406 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1407 #define SETUP_CODE \
1408 GLubyte r = v0->color[0]; \
1409 GLubyte g = v0->color[1]; \
1410 GLubyte b = v0->color[2];
1411 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1413 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1414 PIXEL_TYPE *pixel = pRow; \
1415 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1416 *pixel = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
1419 #include "swrast/s_tritemp.h"
1424 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1426 static void flat_LOOKUP8_triangle( GLcontext
*ctx
,
1431 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1432 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1433 #define PIXEL_TYPE GLubyte
1434 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1435 #define SETUP_CODE \
1437 GLubyte r = v0->color[0]; \
1438 GLubyte g = v0->color[1]; \
1439 GLubyte b = v0->color[2]; \
1440 GLubyte p = LOOKUP(r,g,b);
1441 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1444 PIXEL_TYPE *pixel = pRow; \
1445 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1449 #include "swrast/s_tritemp.h"
1455 _xmesa_print_triangle_func( swrast_tri_func triFunc
)
1457 printf("XMesa tri func = ");
1458 if (triFunc
==smooth_TRUECOLOR_z_triangle
)
1459 printf("smooth_TRUECOLOR_z_triangle\n");
1460 else if (triFunc
==smooth_8A8B8G8R_z_triangle
)
1461 printf("smooth_8A8B8G8R_z_triangle\n");
1462 else if (triFunc
==smooth_8R8G8B_z_triangle
)
1463 printf("smooth_8R8G8B_z_triangle\n");
1464 else if (triFunc
==smooth_8R8G8B24_z_triangle
)
1465 printf("smooth_8R8G8B24_z_triangle\n");
1466 else if (triFunc
==smooth_TRUEDITHER_z_triangle
)
1467 printf("smooth_TRUEDITHER_z_triangle\n");
1468 else if (triFunc
==smooth_5R6G5B_z_triangle
)
1469 printf("smooth_5R6G5B_z_triangle\n");
1470 else if (triFunc
==smooth_DITHER_5R6G5B_z_triangle
)
1471 printf("smooth_DITHER_5R6G5B_z_triangle\n");
1472 else if (triFunc
==smooth_HPCR_z_triangle
)
1473 printf("smooth_HPCR_z_triangle\n");
1474 else if (triFunc
==smooth_DITHER8_z_triangle
)
1475 printf("smooth_DITHER8_z_triangle\n");
1476 else if (triFunc
==smooth_LOOKUP8_z_triangle
)
1477 printf("smooth_LOOKUP8_z_triangle\n");
1478 else if (triFunc
==flat_TRUECOLOR_z_triangle
)
1479 printf("flat_TRUECOLOR_z_triangle\n");
1480 else if (triFunc
==flat_8A8B8G8R_z_triangle
)
1481 printf("flat_8A8B8G8R_z_triangle\n");
1482 else if (triFunc
==flat_8R8G8B_z_triangle
)
1483 printf("flat_8R8G8B_z_triangle\n");
1484 else if (triFunc
==flat_8R8G8B24_z_triangle
)
1485 printf("flat_8R8G8B24_z_triangle\n");
1486 else if (triFunc
==flat_TRUEDITHER_z_triangle
)
1487 printf("flat_TRUEDITHER_z_triangle\n");
1488 else if (triFunc
==flat_5R6G5B_z_triangle
)
1489 printf("flat_5R6G5B_z_triangle\n");
1490 else if (triFunc
==flat_DITHER_5R6G5B_z_triangle
)
1491 printf("flat_DITHER_5R6G5B_z_triangle\n");
1492 else if (triFunc
==flat_HPCR_z_triangle
)
1493 printf("flat_HPCR_z_triangle\n");
1494 else if (triFunc
==flat_DITHER8_z_triangle
)
1495 printf("flat_DITHER8_z_triangle\n");
1496 else if (triFunc
==flat_LOOKUP8_z_triangle
)
1497 printf("flat_LOOKUP8_z_triangle\n");
1498 else if (triFunc
==smooth_TRUECOLOR_triangle
)
1499 printf("smooth_TRUECOLOR_triangle\n");
1500 else if (triFunc
==smooth_8A8B8G8R_triangle
)
1501 printf("smooth_8A8B8G8R_triangle\n");
1502 else if (triFunc
==smooth_8R8G8B_triangle
)
1503 printf("smooth_8R8G8B_triangle\n");
1504 else if (triFunc
==smooth_8R8G8B24_triangle
)
1505 printf("smooth_8R8G8B24_triangle\n");
1506 else if (triFunc
==smooth_TRUEDITHER_triangle
)
1507 printf("smooth_TRUEDITHER_triangle\n");
1508 else if (triFunc
==smooth_5R6G5B_triangle
)
1509 printf("smooth_5R6G5B_triangle\n");
1510 else if (triFunc
==smooth_DITHER_5R6G5B_triangle
)
1511 printf("smooth_DITHER_5R6G5B_triangle\n");
1512 else if (triFunc
==smooth_HPCR_triangle
)
1513 printf("smooth_HPCR_triangle\n");
1514 else if (triFunc
==smooth_DITHER8_triangle
)
1515 printf("smooth_DITHER8_triangle\n");
1516 else if (triFunc
==smooth_LOOKUP8_triangle
)
1517 printf("smooth_LOOKUP8_triangle\n");
1518 else if (triFunc
==flat_TRUECOLOR_triangle
)
1519 printf("flat_TRUECOLOR_triangle\n");
1520 else if (triFunc
==flat_TRUEDITHER_triangle
)
1521 printf("flat_TRUEDITHER_triangle\n");
1522 else if (triFunc
==flat_8A8B8G8R_triangle
)
1523 printf("flat_8A8B8G8R_triangle\n");
1524 else if (triFunc
==flat_8R8G8B_triangle
)
1525 printf("flat_8R8G8B_triangle\n");
1526 else if (triFunc
==flat_8R8G8B24_triangle
)
1527 printf("flat_8R8G8B24_triangle\n");
1528 else if (triFunc
==flat_5R6G5B_triangle
)
1529 printf("flat_5R6G5B_triangle\n");
1530 else if (triFunc
==flat_DITHER_5R6G5B_triangle
)
1531 printf("flat_DITHER_5R6G5B_triangle\n");
1532 else if (triFunc
==flat_HPCR_triangle
)
1533 printf("flat_HPCR_triangle\n");
1534 else if (triFunc
==flat_DITHER8_triangle
)
1535 printf("flat_DITHER8_triangle\n");
1536 else if (triFunc
==flat_LOOKUP8_triangle
)
1537 printf("flat_LOOKUP8_triangle\n");
1544 static swrast_tri_func
get_triangle_func( GLcontext
*ctx
)
1546 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1547 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1548 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
1552 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1553 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1554 if (ctx
->Texture
._ReallyEnabled
) return (swrast_tri_func
) NULL
;
1556 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
1557 if ( ctx
->Light
.ShadeModel
==GL_SMOOTH
1558 && swrast
->_RasterMask
==DEPTH_BIT
1559 && ctx
->Depth
.Func
==GL_LESS
1560 && ctx
->Depth
.Mask
==GL_TRUE
1561 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1562 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1563 switch (xmesa
->pixelformat
) {
1565 return smooth_TRUECOLOR_z_triangle
;
1567 return smooth_8A8B8G8R_z_triangle
;
1569 return smooth_8R8G8B_z_triangle
;
1571 return smooth_8R8G8B24_z_triangle
;
1573 return smooth_TRUEDITHER_z_triangle
;
1575 return smooth_5R6G5B_z_triangle
;
1576 case PF_DITHER_5R6G5B
:
1577 return smooth_DITHER_5R6G5B_z_triangle
;
1579 return smooth_HPCR_z_triangle
;
1581 return (depth
==8) ? smooth_DITHER8_z_triangle
1582 : smooth_DITHER_z_triangle
;
1584 return (depth
==8) ? smooth_LOOKUP8_z_triangle
: (swrast_tri_func
)NULL
;
1586 return (swrast_tri_func
)NULL
;
1589 if ( ctx
->Light
.ShadeModel
==GL_FLAT
1590 && swrast
->_RasterMask
==DEPTH_BIT
1591 && ctx
->Depth
.Func
==GL_LESS
1592 && ctx
->Depth
.Mask
==GL_TRUE
1593 && ctx
->Visual
.DepthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1594 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1595 switch (xmesa
->pixelformat
) {
1597 return flat_TRUECOLOR_z_triangle
;
1599 return flat_8A8B8G8R_z_triangle
;
1601 return flat_8R8G8B_z_triangle
;
1603 return flat_8R8G8B24_z_triangle
;
1605 return flat_TRUEDITHER_z_triangle
;
1607 return flat_5R6G5B_z_triangle
;
1608 case PF_DITHER_5R6G5B
:
1609 return flat_DITHER_5R6G5B_z_triangle
;
1611 return flat_HPCR_z_triangle
;
1613 return (depth
==8) ? flat_DITHER8_z_triangle
1614 : flat_DITHER_z_triangle
;
1616 return (depth
==8) ? flat_LOOKUP8_z_triangle
: (swrast_tri_func
)NULL
;
1618 return (swrast_tri_func
)NULL
;
1621 if ( swrast
->_RasterMask
==0 /* no depth test */
1622 && ctx
->Light
.ShadeModel
==GL_SMOOTH
1623 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1624 switch (xmesa
->pixelformat
) {
1626 return smooth_TRUECOLOR_triangle
;
1628 return smooth_8A8B8G8R_triangle
;
1630 return smooth_8R8G8B_triangle
;
1632 return smooth_8R8G8B24_triangle
;
1634 return smooth_TRUEDITHER_triangle
;
1636 return smooth_5R6G5B_triangle
;
1637 case PF_DITHER_5R6G5B
:
1638 return smooth_DITHER_5R6G5B_triangle
;
1640 return smooth_HPCR_triangle
;
1642 return (depth
==8) ? smooth_DITHER8_triangle
1643 : smooth_DITHER_triangle
;
1645 return (depth
==8) ? smooth_LOOKUP8_triangle
: (swrast_tri_func
)NULL
;
1647 return (swrast_tri_func
)NULL
;
1651 if ( swrast
->_RasterMask
==0 /* no depth test */
1652 && ctx
->Light
.ShadeModel
==GL_FLAT
1653 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1654 switch (xmesa
->pixelformat
) {
1656 return flat_TRUECOLOR_triangle
;
1658 return flat_TRUEDITHER_triangle
;
1660 return flat_8A8B8G8R_triangle
;
1662 return flat_8R8G8B_triangle
;
1664 return flat_8R8G8B24_triangle
;
1666 return flat_5R6G5B_triangle
;
1667 case PF_DITHER_5R6G5B
:
1668 return flat_DITHER_5R6G5B_triangle
;
1670 return flat_HPCR_triangle
;
1672 return (depth
==8) ? flat_DITHER8_triangle
1673 : flat_DITHER_triangle
;
1675 return (depth
==8) ? flat_LOOKUP8_triangle
: (swrast_tri_func
)NULL
;
1677 return (swrast_tri_func
)NULL
;
1681 return (swrast_tri_func
)NULL
;
1684 /* draw to pixmap */
1685 return (swrast_tri_func
) NULL
;
1690 /* Override for the swrast tri-selection function. Try to use one
1691 * of our internal tri functions, otherwise fall back to the
1692 * standard swrast functions.
1694 void xmesa_choose_triangle( GLcontext
*ctx
)
1696 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1698 if (!(swrast
->Triangle
= get_triangle_func( ctx
)))
1699 _swrast_choose_triangle( ctx
);