2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * This file contains "accelerated" triangle functions. It should be
28 * fairly easy to write new special-purpose triangle functions and hook
29 * them into this module.
33 #include "glxheader.h"
40 /* Internal swrast includes:
42 #include "swrast/s_context.h"
43 #include "swrast/s_depth.h"
44 #include "swrast/s_triangle.h"
48 /**********************************************************************/
49 /*** Triangle rendering ***/
50 /**********************************************************************/
54 * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
56 #define NAME smooth_TRUECOLOR_z_triangle
58 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
61 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
62 XMesaImage *img = xmesa->xm_buffer->backimage;
64 #define RENDER_SPAN( span ) \
65 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
67 for (i = 0; i < span.end; i++, x++) { \
68 const DEPTH_TYPE z = FixedToDepth(span.z); \
71 PACK_TRUECOLOR(p, FixedToInt(span.red), \
72 FixedToInt(span.green), FixedToInt(span.blue)); \
73 XMesaPutPixel(img, x, y, p); \
76 span.red += span.redStep; \
77 span.green += span.greenStep; \
78 span.blue += span.blueStep; \
79 span.z += span.zStep; \
82 #include "swrast/s_tritemp.h"
88 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
90 #define NAME smooth_8A8B8G8R_z_triangle
92 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
94 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
95 #define PIXEL_TYPE GLuint
96 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
98 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
100 #define RENDER_SPAN( span ) \
102 for (i = 0; i < span.end; i++) { \
103 const DEPTH_TYPE z = FixedToDepth(span.z); \
105 pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
106 FixedToInt(span.green), FixedToInt(span.blue)); \
109 span.red += span.redStep; \
110 span.green += span.greenStep; \
111 span.blue += span.blueStep; \
112 span.z += span.zStep; \
115 #include "swrast/s_tritemp.h"
120 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
122 #define NAME smooth_8R8G8B_z_triangle
124 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
126 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
127 #define PIXEL_TYPE GLuint
128 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
130 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
132 #define RENDER_SPAN( span ) \
134 for (i = 0; i < span.end; i++) { \
135 const DEPTH_TYPE z = FixedToDepth(span.z); \
137 pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
138 FixedToInt(span.green), FixedToInt(span.blue)); \
141 span.red += span.redStep; \
142 span.green += span.greenStep; \
143 span.blue += span.blueStep; \
144 span.z += span.zStep; \
147 #include "swrast/s_tritemp.h"
152 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
154 #define NAME smooth_8R8G8B24_z_triangle
156 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
158 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
159 #define PIXEL_TYPE bgr_t
160 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
162 XMesaContext xmesa = XMESA_CONTEXT(ctx);
163 #define RENDER_SPAN( span ) \
165 for (i = 0; i < span.end; i++) { \
166 const DEPTH_TYPE z = FixedToDepth(span.z); \
168 PIXEL_TYPE *ptr = pRow + i; \
169 ptr->r = FixedToInt(span.red); \
170 ptr->g = FixedToInt(span.green); \
171 ptr->b = FixedToInt(span.blue); \
174 span.red += span.redStep; \
175 span.green += span.greenStep; \
176 span.blue += span.blueStep; \
177 span.z += span.zStep; \
179 #include "swrast/s_tritemp.h"
184 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
186 #define NAME smooth_TRUEDITHER_z_triangle
188 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
191 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
192 XMesaImage *img = xmesa->xm_buffer->backimage;
193 #define RENDER_SPAN( span ) \
195 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
196 for (i = 0; i < span.end; i++, x++) { \
197 const DEPTH_TYPE z = FixedToDepth(span.z); \
200 PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
201 FixedToInt(span.green), FixedToInt(span.blue)); \
202 XMesaPutPixel(img, x, y, p); \
205 span.red += span.redStep; \
206 span.green += span.greenStep; \
207 span.blue += span.blueStep; \
208 span.z += span.zStep; \
210 #include "swrast/s_tritemp.h"
215 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
217 #define NAME smooth_5R6G5B_z_triangle
219 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
221 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
222 #define PIXEL_TYPE GLushort
223 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
225 XMesaContext xmesa = XMESA_CONTEXT(ctx);
226 #define RENDER_SPAN( span ) \
228 for (i = 0; i < span.end; i++) { \
229 const DEPTH_TYPE z = FixedToDepth(span.z); \
231 pRow[i] = PACK_5R6G5B(FixedToInt(span.red), \
232 FixedToInt(span.green), FixedToInt(span.blue)); \
235 span.red += span.redStep; \
236 span.green += span.greenStep; \
237 span.blue += span.blueStep; \
238 span.z += span.zStep; \
240 #include "swrast/s_tritemp.h"
245 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
247 #define NAME smooth_DITHER_5R6G5B_z_triangle
249 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
251 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
252 #define PIXEL_TYPE GLushort
253 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
255 XMesaContext xmesa = XMESA_CONTEXT(ctx);
256 #define RENDER_SPAN( span ) \
258 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
259 for (i = 0; i < span.end; i++, x++) { \
260 const DEPTH_TYPE z = FixedToDepth(span.z); \
262 PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
263 FixedToInt(span.green), FixedToInt(span.blue)); \
266 span.red += span.redStep; \
267 span.green += span.greenStep; \
268 span.blue += span.blueStep; \
269 span.z += span.zStep; \
271 #include "swrast/s_tritemp.h"
276 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
278 #define NAME smooth_DITHER8_z_triangle
280 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
282 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
283 #define PIXEL_TYPE GLubyte
284 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
286 XMesaContext xmesa = XMESA_CONTEXT(ctx);
287 #define RENDER_SPAN( span ) \
289 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
291 for (i = 0; i < span.end; i++, x++) { \
292 const DEPTH_TYPE z = FixedToDepth(span.z); \
294 pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red),\
295 FixedToInt(span.green), FixedToInt(span.blue) ); \
298 span.red += span.redStep; \
299 span.green += span.greenStep; \
300 span.blue += span.blueStep; \
301 span.z += span.zStep; \
303 #include "swrast/s_tritemp.h"
308 * XImage, smooth, depth-buffered, PF_DITHER triangle.
310 #define NAME smooth_DITHER_z_triangle
312 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
315 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
316 XMesaImage *img = xmesa->xm_buffer->backimage;
317 #define RENDER_SPAN( span ) \
319 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
321 for (i = 0; i < span.end; i++, x++) { \
322 const DEPTH_TYPE z = FixedToDepth(span.z); \
324 unsigned long p = XDITHER(x, FixedToInt(span.red), \
325 FixedToInt(span.green), FixedToInt(span.blue)); \
326 XMesaPutPixel(img, x, y, p); \
329 span.red += span.redStep; \
330 span.green += span.greenStep; \
331 span.blue += span.blueStep; \
332 span.z += span.zStep; \
334 #include "swrast/s_tritemp.h"
339 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
341 #define NAME smooth_LOOKUP8_z_triangle
343 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
345 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
346 #define PIXEL_TYPE GLubyte
347 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
349 XMesaContext xmesa = XMESA_CONTEXT(ctx);
350 #define RENDER_SPAN( span ) \
353 for (i = 0; i < span.end; i++) { \
354 const DEPTH_TYPE z = FixedToDepth(span.z); \
356 pRow[i] = LOOKUP(FixedToInt(span.red), \
357 FixedToInt(span.green), FixedToInt(span.blue)); \
360 span.red += span.redStep; \
361 span.green += span.greenStep; \
362 span.blue += span.blueStep; \
363 span.z += span.zStep; \
365 #include "swrast/s_tritemp.h"
370 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
372 #define NAME smooth_HPCR_z_triangle
374 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
376 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
377 #define PIXEL_TYPE GLubyte
378 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
380 XMesaContext xmesa = XMESA_CONTEXT(ctx);
381 #define RENDER_SPAN( span ) \
383 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
384 for (i = 0; i < span.end; i++, x++) { \
385 const DEPTH_TYPE z = FixedToDepth(span.z); \
387 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
388 FixedToInt(span.green), FixedToInt(span.blue) ); \
391 span.red += span.redStep; \
392 span.green += span.greenStep; \
393 span.blue += span.blueStep; \
394 span.z += span.zStep; \
396 #include "swrast/s_tritemp.h"
401 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
403 #define NAME flat_TRUECOLOR_z_triangle
405 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
407 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
408 XMesaImage *img = xmesa->xm_buffer->backimage; \
409 unsigned long pixel; \
410 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
411 #define RENDER_SPAN( span ) \
413 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
414 for (i = 0; i < span.end; i++, x++) { \
415 const DEPTH_TYPE z = FixedToDepth(span.z); \
417 XMesaPutPixel(img, x, y, pixel); \
420 span.z += span.zStep; \
422 #include "swrast/s_tritemp.h"
427 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
429 #define NAME flat_8A8B8G8R_z_triangle
431 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
432 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
433 #define PIXEL_TYPE GLuint
434 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
436 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
437 unsigned long p = PACK_8B8G8R( v2->color[0], \
438 v2->color[1], v2->color[2] );
439 #define RENDER_SPAN( span ) \
441 for (i = 0; i < span.end; i++) { \
442 const DEPTH_TYPE z = FixedToDepth(span.z); \
444 pRow[i] = (PIXEL_TYPE) p; \
447 span.z += span.zStep; \
449 #include "swrast/s_tritemp.h"
454 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
456 #define NAME flat_8R8G8B_z_triangle
458 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
459 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
460 #define PIXEL_TYPE GLuint
461 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
463 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
464 unsigned long p = PACK_8R8G8B( v2->color[0], \
465 v2->color[1], v2->color[2] );
466 #define RENDER_SPAN( span ) \
468 for (i = 0; i < span.end; i++) { \
469 DEPTH_TYPE z = FixedToDepth(span.z); \
471 pRow[i] = (PIXEL_TYPE) p; \
474 span.z += span.zStep; \
476 #include "swrast/s_tritemp.h"
481 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
483 #define NAME flat_8R8G8B24_z_triangle
485 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
486 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
487 #define PIXEL_TYPE bgr_t
488 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
490 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
491 const GLubyte *color = v2->color;
492 #define RENDER_SPAN( span ) \
494 for (i = 0; i < span.end; i++) { \
495 const DEPTH_TYPE z = FixedToDepth(span.z); \
497 PIXEL_TYPE *ptr = pRow + i; \
498 ptr->r = color[RCOMP]; \
499 ptr->g = color[GCOMP]; \
500 ptr->b = color[BCOMP]; \
503 span.z += span.zStep; \
505 #include "swrast/s_tritemp.h"
510 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
512 #define NAME flat_TRUEDITHER_z_triangle
514 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
516 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
517 XMesaImage *img = xmesa->xm_buffer->backimage;
518 #define RENDER_SPAN( span ) \
520 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
521 for (i = 0; i < span.end; i++, x++) { \
522 const DEPTH_TYPE z = FixedToDepth(span.z); \
525 PACK_TRUEDITHER(p, x, y, v2->color[0], \
526 v2->color[1], v2->color[2]); \
527 XMesaPutPixel(img, x, y, p); \
530 span.z += span.zStep; \
532 #include "swrast/s_tritemp.h"
537 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
539 #define NAME flat_5R6G5B_z_triangle
541 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
542 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
543 #define PIXEL_TYPE GLushort
544 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
546 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
547 unsigned long p = PACK_5R6G5B( v2->color[0], \
548 v2->color[1], v2->color[2] );
549 #define RENDER_SPAN( span ) \
551 for (i = 0; i < span.end; i++) { \
552 const DEPTH_TYPE z = FixedToDepth(span.z); \
554 pRow[i] = (PIXEL_TYPE) p; \
557 span.z += span.zStep; \
559 #include "swrast/s_tritemp.h"
564 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
566 #define NAME flat_DITHER_5R6G5B_z_triangle
568 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
569 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
570 #define PIXEL_TYPE GLushort
571 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
573 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
574 const GLubyte *color = v2->color;
575 #define RENDER_SPAN( span ) \
577 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
578 for (i = 0; i < span.end; i++, x++) { \
579 const DEPTH_TYPE z = FixedToDepth(span.z); \
581 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
582 color[GCOMP], color[BCOMP]); \
585 span.z += span.zStep; \
587 #include "swrast/s_tritemp.h"
592 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
594 #define NAME flat_DITHER8_z_triangle
596 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
597 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
598 #define PIXEL_TYPE GLubyte
599 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
601 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
602 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
603 #define RENDER_SPAN( span ) \
605 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
606 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
607 for (i = 0; i < span.end; i++, x++) { \
608 const DEPTH_TYPE z = FixedToDepth(span.z); \
610 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
613 span.z += span.zStep; \
615 #include "swrast/s_tritemp.h"
620 * XImage, flat, depth-buffered, PF_DITHER triangle.
622 #define NAME flat_DITHER_z_triangle
624 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
626 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
627 XMesaImage *img = xmesa->xm_buffer->backimage; \
628 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
629 #define RENDER_SPAN( span ) \
631 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
632 FLAT_DITHER_ROW_SETUP(y); \
633 for (i = 0; i < span.end; i++, x++) { \
634 const DEPTH_TYPE z = FixedToDepth(span.z); \
636 unsigned long p = FLAT_DITHER(x); \
637 XMesaPutPixel(img, x, y, p); \
640 span.z += span.zStep; \
642 #include "swrast/s_tritemp.h"
647 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
649 #define NAME flat_HPCR_z_triangle
651 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
652 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
653 #define PIXEL_TYPE GLubyte
654 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
656 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
657 GLubyte r = v2->color[0]; \
658 GLubyte g = v2->color[1]; \
659 GLubyte b = v2->color[2];
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 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
669 span.z += span.zStep; \
671 #include "swrast/s_tritemp.h"
676 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
678 #define NAME flat_LOOKUP8_z_triangle
680 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
681 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
682 #define PIXEL_TYPE GLubyte
683 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
685 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
687 GLubyte r = v2->color[0]; \
688 GLubyte g = v2->color[1]; \
689 GLubyte b = v2->color[2]; \
690 GLubyte p = LOOKUP(r,g,b);
691 #define RENDER_SPAN( span ) \
693 for (i = 0; i < span.end; i++) { \
694 const DEPTH_TYPE z = FixedToDepth(span.z); \
699 span.z += span.zStep; \
701 #include "swrast/s_tritemp.h"
706 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
708 #define NAME smooth_TRUECOLOR_triangle
711 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
712 XMesaImage *img = xmesa->xm_buffer->backimage;
713 #define RENDER_SPAN( span ) \
715 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
716 for (i = 0; i < span.end; i++, x++) { \
718 PACK_TRUECOLOR(p, FixedToInt(span.red), \
719 FixedToInt(span.green), FixedToInt(span.blue)); \
720 XMesaPutPixel(img, x, y, p); \
721 span.red += span.redStep; \
722 span.green += span.greenStep; \
723 span.blue += span.blueStep; \
725 #include "swrast/s_tritemp.h"
730 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
732 #define NAME smooth_8A8B8G8R_triangle
734 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
735 #define PIXEL_TYPE GLuint
736 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
738 XMesaContext xmesa = XMESA_CONTEXT(ctx);
739 #define RENDER_SPAN( span ) \
741 for (i = 0; i < span.end; i++) { \
742 pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
743 FixedToInt(span.green), FixedToInt(span.blue) ); \
744 span.red += span.redStep; \
745 span.green += span.greenStep; \
746 span.blue += span.blueStep; \
748 #include "swrast/s_tritemp.h"
753 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
755 #define NAME smooth_8R8G8B_triangle
757 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
758 #define PIXEL_TYPE GLuint
759 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
761 XMesaContext xmesa = XMESA_CONTEXT(ctx);
762 #define RENDER_SPAN( span ) \
764 for (i = 0; i < span.end; i++) { \
765 pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
766 FixedToInt(span.green), FixedToInt(span.blue) ); \
767 span.red += span.redStep; \
768 span.green += span.greenStep; \
769 span.blue += span.blueStep; \
771 #include "swrast/s_tritemp.h"
776 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
778 #define NAME smooth_8R8G8B24_triangle
780 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
781 #define PIXEL_TYPE bgr_t
782 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
784 XMesaContext xmesa = XMESA_CONTEXT(ctx);
785 #define RENDER_SPAN( span ) \
787 PIXEL_TYPE *pixel = pRow; \
788 for (i = 0; i < span.end; i++, pixel++) { \
789 pixel->r = FixedToInt(span.red); \
790 pixel->g = FixedToInt(span.green); \
791 pixel->b = FixedToInt(span.blue); \
792 span.red += span.redStep; \
793 span.green += span.greenStep; \
794 span.blue += span.blueStep; \
796 #include "swrast/s_tritemp.h"
801 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
803 #define NAME smooth_TRUEDITHER_triangle
806 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
807 XMesaImage *img = xmesa->xm_buffer->backimage;
808 #define RENDER_SPAN( span ) \
810 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
811 for (i = 0; i < span.end; i++, x++) { \
813 PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
814 FixedToInt(span.green), FixedToInt(span.blue)); \
815 XMesaPutPixel(img, x, y, p ); \
816 span.red += span.redStep; \
817 span.green += span.greenStep; \
818 span.blue += span.blueStep; \
820 #include "swrast/s_tritemp.h"
825 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
827 #define NAME smooth_5R6G5B_triangle
829 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
830 #define PIXEL_TYPE GLushort
831 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
833 XMesaContext xmesa = XMESA_CONTEXT(ctx);
834 #define RENDER_SPAN( span ) \
836 for (i = 0; i < span.end; i++) { \
837 pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span.red), \
838 FixedToInt(span.green), FixedToInt(span.blue)); \
839 span.red += span.redStep; \
840 span.green += span.greenStep; \
841 span.blue += span.blueStep; \
843 #include "swrast/s_tritemp.h"
848 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
850 #define NAME smooth_DITHER_5R6G5B_triangle
852 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
853 #define PIXEL_TYPE GLushort
854 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
856 XMesaContext xmesa = XMESA_CONTEXT(ctx);
857 #define RENDER_SPAN( span ) \
859 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
860 for (i = 0; i < span.end; i++, x++) { \
861 PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
862 FixedToInt(span.green), FixedToInt(span.blue)); \
863 span.red += span.redStep; \
864 span.green += span.greenStep; \
865 span.blue += span.blueStep; \
867 #include "swrast/s_tritemp.h"
872 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
874 #define NAME smooth_DITHER8_triangle
876 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
877 #define PIXEL_TYPE GLubyte
878 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
880 XMesaContext xmesa = XMESA_CONTEXT(ctx);
881 #define RENDER_SPAN( span ) \
883 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
885 for (i = 0; i < span.end; i++, x++) { \
886 pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \
887 FixedToInt(span.green), FixedToInt(span.blue) ); \
888 span.red += span.redStep; \
889 span.green += span.greenStep; \
890 span.blue += span.blueStep; \
892 #include "swrast/s_tritemp.h"
897 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
899 #define NAME smooth_DITHER_triangle
902 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
903 XMesaImage *img = xmesa->xm_buffer->backimage;
904 #define RENDER_SPAN( span ) \
906 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
908 for (i = 0; i < span.end; i++, x++) { \
909 unsigned long p = XDITHER(x, FixedToInt(span.red), \
910 FixedToInt(span.green), FixedToInt(span.blue) ); \
911 XMesaPutPixel(img, x, y, p); \
912 span.red += span.redStep; \
913 span.green += span.greenStep; \
914 span.blue += span.blueStep; \
916 #include "swrast/s_tritemp.h"
921 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
923 #define NAME smooth_LOOKUP8_triangle
925 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
926 #define PIXEL_TYPE GLubyte
927 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
929 XMesaContext xmesa = XMESA_CONTEXT(ctx);
930 #define RENDER_SPAN( span ) \
933 for (i = 0; i < span.end; i++) { \
934 pRow[i] = LOOKUP(FixedToInt(span.red), \
935 FixedToInt(span.green), FixedToInt(span.blue)); \
936 span.red += span.redStep; \
937 span.green += span.greenStep; \
938 span.blue += span.blueStep; \
940 #include "swrast/s_tritemp.h"
945 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
947 #define NAME smooth_HPCR_triangle
949 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
950 #define PIXEL_TYPE GLubyte
951 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
953 XMesaContext xmesa = XMESA_CONTEXT(ctx);
954 #define RENDER_SPAN( span ) \
956 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
957 for (i = 0; i < span.end; i++, x++) { \
958 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
959 FixedToInt(span.green), FixedToInt(span.blue)); \
960 span.red += span.redStep; \
961 span.green += span.greenStep; \
962 span.blue += span.blueStep; \
964 #include "swrast/s_tritemp.h"
969 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
971 #define NAME flat_TRUECOLOR_triangle
973 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
974 XMesaImage *img = xmesa->xm_buffer->backimage; \
975 unsigned long pixel; \
976 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
977 #define RENDER_SPAN( span ) \
979 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
980 for (i = 0; i < span.end; i++, x++) { \
981 XMesaPutPixel(img, x, y, pixel); \
983 #include "swrast/s_tritemp.h"
988 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
990 #define NAME flat_8A8B8G8R_triangle
991 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
992 #define PIXEL_TYPE GLuint
993 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
995 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
996 unsigned long p = PACK_8B8G8R( v2->color[0], \
997 v2->color[1], v2->color[2] );
998 #define RENDER_SPAN( span ) \
1000 for (i = 0; i < span.end; i++) { \
1001 pRow[i] = (PIXEL_TYPE) p; \
1003 #include "swrast/s_tritemp.h"
1008 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1010 #define NAME flat_8R8G8B_triangle
1011 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1012 #define PIXEL_TYPE GLuint
1013 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1014 #define SETUP_CODE \
1015 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1016 unsigned long p = PACK_8R8G8B( v2->color[0], \
1017 v2->color[1], v2->color[2] );
1018 #define RENDER_SPAN( span ) \
1020 for (i = 0; i < span.end; i++) { \
1021 pRow[i] = (PIXEL_TYPE) p; \
1023 #include "swrast/s_tritemp.h"
1028 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1030 #define NAME flat_8R8G8B24_triangle
1031 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1032 #define PIXEL_TYPE bgr_t
1033 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1034 #define SETUP_CODE \
1035 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1036 const GLubyte *color = v2->color;
1037 #define RENDER_SPAN( span ) \
1039 PIXEL_TYPE *pixel = pRow; \
1040 for (i = 0; i < span.end; i++, pixel++) { \
1041 pixel->r = color[RCOMP]; \
1042 pixel->g = color[GCOMP]; \
1043 pixel->b = color[BCOMP]; \
1045 #include "swrast/s_tritemp.h"
1050 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1052 #define NAME flat_TRUEDITHER_triangle
1053 #define SETUP_CODE \
1054 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1055 XMesaImage *img = xmesa->xm_buffer->backimage;
1056 #define RENDER_SPAN( span ) \
1058 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1059 for (i = 0; i < span.end; i++, x++) { \
1061 PACK_TRUEDITHER(p, x, y, v2->color[0], \
1062 v2->color[1], v2->color[2] ); \
1063 XMesaPutPixel(img, x, y, p); \
1065 #include "swrast/s_tritemp.h"
1070 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1072 #define NAME flat_5R6G5B_triangle
1073 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1074 #define PIXEL_TYPE GLushort
1075 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1076 #define SETUP_CODE \
1077 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1078 unsigned long p = PACK_5R6G5B( v2->color[0], \
1079 v2->color[1], v2->color[2] );
1080 #define RENDER_SPAN( span ) \
1082 for (i = 0; i < span.end; i++) { \
1083 pRow[i] = (PIXEL_TYPE) p; \
1085 #include "swrast/s_tritemp.h"
1090 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1092 #define NAME flat_DITHER_5R6G5B_triangle
1093 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1094 #define PIXEL_TYPE GLushort
1095 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1096 #define SETUP_CODE \
1097 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1098 const GLubyte *color = v2->color;
1099 #define RENDER_SPAN( span ) \
1101 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1102 for (i = 0; i < span.end; i++, x++) { \
1103 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
1104 color[GCOMP], color[BCOMP]); \
1106 #include "swrast/s_tritemp.h"
1111 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1113 #define NAME flat_DITHER8_triangle
1114 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1115 #define PIXEL_TYPE GLubyte
1116 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1117 #define SETUP_CODE \
1118 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1119 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1120 #define RENDER_SPAN( span ) \
1122 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1123 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
1124 for (i = 0; i < span.end; i++, x++) { \
1125 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
1127 #include "swrast/s_tritemp.h"
1132 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1134 #define NAME flat_DITHER_triangle
1135 #define SETUP_CODE \
1136 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1137 XMesaImage *img = xmesa->xm_buffer->backimage; \
1138 FLAT_DITHER_SETUP( 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 FLAT_DITHER_ROW_SETUP(y); \
1143 for (i = 0; i < span.end; i++, x++) { \
1144 unsigned long p = FLAT_DITHER(x); \
1145 XMesaPutPixel(img, x, y, p ); \
1147 #include "swrast/s_tritemp.h"
1152 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1154 #define NAME flat_HPCR_triangle
1155 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1156 #define PIXEL_TYPE GLubyte
1157 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1158 #define SETUP_CODE \
1159 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1160 GLubyte r = v2->color[0]; \
1161 GLubyte g = v2->color[1]; \
1162 GLubyte b = v2->color[2];
1163 #define RENDER_SPAN( span ) \
1165 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1166 for (i = 0; i < span.end; i++, x++) { \
1167 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
1169 #include "swrast/s_tritemp.h"
1174 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1176 #define NAME flat_LOOKUP8_triangle
1177 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1178 #define PIXEL_TYPE GLubyte
1179 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1180 #define SETUP_CODE \
1181 XMesaContext xmesa = XMESA_CONTEXT(ctx); \
1183 GLubyte r = v2->color[0]; \
1184 GLubyte g = v2->color[1]; \
1185 GLubyte b = v2->color[2]; \
1186 GLubyte p = LOOKUP(r,g,b);
1187 #define RENDER_SPAN( span ) \
1189 for (i = 0; i < span.end; i++) { \
1190 pRow[i] = (PIXEL_TYPE) p; \
1192 #include "swrast/s_tritemp.h"
1197 extern void _xmesa_print_triangle_func( swrast_tri_func triFunc
);
1198 void _xmesa_print_triangle_func( swrast_tri_func triFunc
)
1200 _mesa_printf("XMesa tri func = ");
1201 if (triFunc
==smooth_TRUECOLOR_z_triangle
)
1202 _mesa_printf("smooth_TRUECOLOR_z_triangle\n");
1203 else if (triFunc
==smooth_8A8B8G8R_z_triangle
)
1204 _mesa_printf("smooth_8A8B8G8R_z_triangle\n");
1205 else if (triFunc
==smooth_8R8G8B_z_triangle
)
1206 _mesa_printf("smooth_8R8G8B_z_triangle\n");
1207 else if (triFunc
==smooth_8R8G8B24_z_triangle
)
1208 _mesa_printf("smooth_8R8G8B24_z_triangle\n");
1209 else if (triFunc
==smooth_TRUEDITHER_z_triangle
)
1210 _mesa_printf("smooth_TRUEDITHER_z_triangle\n");
1211 else if (triFunc
==smooth_5R6G5B_z_triangle
)
1212 _mesa_printf("smooth_5R6G5B_z_triangle\n");
1213 else if (triFunc
==smooth_DITHER_5R6G5B_z_triangle
)
1214 _mesa_printf("smooth_DITHER_5R6G5B_z_triangle\n");
1215 else if (triFunc
==smooth_HPCR_z_triangle
)
1216 _mesa_printf("smooth_HPCR_z_triangle\n");
1217 else if (triFunc
==smooth_DITHER8_z_triangle
)
1218 _mesa_printf("smooth_DITHER8_z_triangle\n");
1219 else if (triFunc
==smooth_LOOKUP8_z_triangle
)
1220 _mesa_printf("smooth_LOOKUP8_z_triangle\n");
1221 else if (triFunc
==flat_TRUECOLOR_z_triangle
)
1222 _mesa_printf("flat_TRUECOLOR_z_triangle\n");
1223 else if (triFunc
==flat_8A8B8G8R_z_triangle
)
1224 _mesa_printf("flat_8A8B8G8R_z_triangle\n");
1225 else if (triFunc
==flat_8R8G8B_z_triangle
)
1226 _mesa_printf("flat_8R8G8B_z_triangle\n");
1227 else if (triFunc
==flat_8R8G8B24_z_triangle
)
1228 _mesa_printf("flat_8R8G8B24_z_triangle\n");
1229 else if (triFunc
==flat_TRUEDITHER_z_triangle
)
1230 _mesa_printf("flat_TRUEDITHER_z_triangle\n");
1231 else if (triFunc
==flat_5R6G5B_z_triangle
)
1232 _mesa_printf("flat_5R6G5B_z_triangle\n");
1233 else if (triFunc
==flat_DITHER_5R6G5B_z_triangle
)
1234 _mesa_printf("flat_DITHER_5R6G5B_z_triangle\n");
1235 else if (triFunc
==flat_HPCR_z_triangle
)
1236 _mesa_printf("flat_HPCR_z_triangle\n");
1237 else if (triFunc
==flat_DITHER8_z_triangle
)
1238 _mesa_printf("flat_DITHER8_z_triangle\n");
1239 else if (triFunc
==flat_LOOKUP8_z_triangle
)
1240 _mesa_printf("flat_LOOKUP8_z_triangle\n");
1241 else if (triFunc
==smooth_TRUECOLOR_triangle
)
1242 _mesa_printf("smooth_TRUECOLOR_triangle\n");
1243 else if (triFunc
==smooth_8A8B8G8R_triangle
)
1244 _mesa_printf("smooth_8A8B8G8R_triangle\n");
1245 else if (triFunc
==smooth_8R8G8B_triangle
)
1246 _mesa_printf("smooth_8R8G8B_triangle\n");
1247 else if (triFunc
==smooth_8R8G8B24_triangle
)
1248 _mesa_printf("smooth_8R8G8B24_triangle\n");
1249 else if (triFunc
==smooth_TRUEDITHER_triangle
)
1250 _mesa_printf("smooth_TRUEDITHER_triangle\n");
1251 else if (triFunc
==smooth_5R6G5B_triangle
)
1252 _mesa_printf("smooth_5R6G5B_triangle\n");
1253 else if (triFunc
==smooth_DITHER_5R6G5B_triangle
)
1254 _mesa_printf("smooth_DITHER_5R6G5B_triangle\n");
1255 else if (triFunc
==smooth_HPCR_triangle
)
1256 _mesa_printf("smooth_HPCR_triangle\n");
1257 else if (triFunc
==smooth_DITHER8_triangle
)
1258 _mesa_printf("smooth_DITHER8_triangle\n");
1259 else if (triFunc
==smooth_LOOKUP8_triangle
)
1260 _mesa_printf("smooth_LOOKUP8_triangle\n");
1261 else if (triFunc
==flat_TRUECOLOR_triangle
)
1262 _mesa_printf("flat_TRUECOLOR_triangle\n");
1263 else if (triFunc
==flat_TRUEDITHER_triangle
)
1264 _mesa_printf("flat_TRUEDITHER_triangle\n");
1265 else if (triFunc
==flat_8A8B8G8R_triangle
)
1266 _mesa_printf("flat_8A8B8G8R_triangle\n");
1267 else if (triFunc
==flat_8R8G8B_triangle
)
1268 _mesa_printf("flat_8R8G8B_triangle\n");
1269 else if (triFunc
==flat_8R8G8B24_triangle
)
1270 _mesa_printf("flat_8R8G8B24_triangle\n");
1271 else if (triFunc
==flat_5R6G5B_triangle
)
1272 _mesa_printf("flat_5R6G5B_triangle\n");
1273 else if (triFunc
==flat_DITHER_5R6G5B_triangle
)
1274 _mesa_printf("flat_DITHER_5R6G5B_triangle\n");
1275 else if (triFunc
==flat_HPCR_triangle
)
1276 _mesa_printf("flat_HPCR_triangle\n");
1277 else if (triFunc
==flat_DITHER8_triangle
)
1278 _mesa_printf("flat_DITHER8_triangle\n");
1279 else if (triFunc
==flat_LOOKUP8_triangle
)
1280 _mesa_printf("flat_LOOKUP8_triangle\n");
1282 _mesa_printf("???\n");
1289 /* record the current triangle function name */
1290 static const char *triFuncName
= NULL
;
1292 #define USE(triFunc) \
1294 triFuncName = #triFunc; \
1300 #define USE(triFunc) return triFunc
1305 static swrast_tri_func
get_triangle_func( GLcontext
*ctx
)
1307 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1308 XMesaContext xmesa
= XMESA_CONTEXT(ctx
);
1309 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
1315 if ((ctx
->Color
._DrawDestMask
[0] & (DD_FRONT_LEFT_BIT
| DD_BACK_LEFT_BIT
)) ==0)
1316 return (swrast_tri_func
) NULL
;
1317 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1318 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1319 if (ctx
->Texture
._EnabledUnits
) return (swrast_tri_func
) NULL
;
1320 if (swrast
->_RasterMask
& MULTI_DRAW_BIT
) return (swrast_tri_func
) NULL
;
1321 if (ctx
->Polygon
.CullFlag
&&
1322 ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
1323 return (swrast_tri_func
) NULL
;
1325 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
1326 if ( ctx
->Light
.ShadeModel
==GL_SMOOTH
1327 && swrast
->_RasterMask
==DEPTH_BIT
1328 && ctx
->Depth
.Func
==GL_LESS
1329 && ctx
->Depth
.Mask
==GL_TRUE
1330 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1331 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1332 switch (xmesa
->pixelformat
) {
1334 USE(smooth_TRUECOLOR_z_triangle
);
1336 USE(smooth_8A8B8G8R_z_triangle
);
1338 USE(smooth_8R8G8B_z_triangle
);
1340 USE(smooth_8R8G8B24_z_triangle
);
1341 case PF_Dither_True
:
1342 USE(smooth_TRUEDITHER_z_triangle
);
1344 USE(smooth_5R6G5B_z_triangle
);
1345 case PF_Dither_5R6G5B
:
1346 USE(smooth_DITHER_5R6G5B_z_triangle
);
1348 USE(smooth_HPCR_z_triangle
);
1351 USE(smooth_DITHER8_z_triangle
);
1353 USE(smooth_DITHER_z_triangle
);
1357 USE(smooth_LOOKUP8_z_triangle
);
1359 return (swrast_tri_func
) NULL
;
1361 return (swrast_tri_func
) NULL
;
1364 if ( ctx
->Light
.ShadeModel
==GL_FLAT
1365 && swrast
->_RasterMask
==DEPTH_BIT
1366 && ctx
->Depth
.Func
==GL_LESS
1367 && ctx
->Depth
.Mask
==GL_TRUE
1368 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1369 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1370 switch (xmesa
->pixelformat
) {
1372 USE(flat_TRUECOLOR_z_triangle
);
1374 USE(flat_8A8B8G8R_z_triangle
);
1376 USE(flat_8R8G8B_z_triangle
);
1378 USE(flat_8R8G8B24_z_triangle
);
1379 case PF_Dither_True
:
1380 USE(flat_TRUEDITHER_z_triangle
);
1382 USE(flat_5R6G5B_z_triangle
);
1383 case PF_Dither_5R6G5B
:
1384 USE(flat_DITHER_5R6G5B_z_triangle
);
1386 USE(flat_HPCR_z_triangle
);
1389 USE(flat_DITHER8_z_triangle
);
1391 USE(flat_DITHER_z_triangle
);
1395 USE(flat_LOOKUP8_z_triangle
);
1397 return (swrast_tri_func
) NULL
;
1399 return (swrast_tri_func
) NULL
;
1402 if ( swrast
->_RasterMask
==0 /* no depth test */
1403 && ctx
->Light
.ShadeModel
==GL_SMOOTH
1404 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1405 switch (xmesa
->pixelformat
) {
1407 USE(smooth_TRUECOLOR_triangle
);
1409 USE(smooth_8A8B8G8R_triangle
);
1411 USE(smooth_8R8G8B_triangle
);
1413 USE(smooth_8R8G8B24_triangle
);
1414 case PF_Dither_True
:
1415 USE(smooth_TRUEDITHER_triangle
);
1417 USE(smooth_5R6G5B_triangle
);
1418 case PF_Dither_5R6G5B
:
1419 USE(smooth_DITHER_5R6G5B_triangle
);
1421 USE(smooth_HPCR_triangle
);
1424 USE(smooth_DITHER8_triangle
);
1426 USE(smooth_DITHER_triangle
);
1430 USE(smooth_LOOKUP8_triangle
);
1432 return (swrast_tri_func
) NULL
;
1434 return (swrast_tri_func
) NULL
;
1438 if ( swrast
->_RasterMask
==0 /* no depth test */
1439 && ctx
->Light
.ShadeModel
==GL_FLAT
1440 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1441 switch (xmesa
->pixelformat
) {
1443 USE(flat_TRUECOLOR_triangle
);
1444 case PF_Dither_True
:
1445 USE(flat_TRUEDITHER_triangle
);
1447 USE(flat_8A8B8G8R_triangle
);
1449 USE(flat_8R8G8B_triangle
);
1451 USE(flat_8R8G8B24_triangle
);
1453 USE(flat_5R6G5B_triangle
);
1454 case PF_Dither_5R6G5B
:
1455 USE(flat_DITHER_5R6G5B_triangle
);
1457 USE(flat_HPCR_triangle
);
1460 USE(flat_DITHER8_triangle
);
1462 USE(flat_DITHER_triangle
);
1466 USE(flat_LOOKUP8_triangle
);
1468 return (swrast_tri_func
) NULL
;
1470 return (swrast_tri_func
) NULL
;
1474 return (swrast_tri_func
) NULL
;
1477 /* draw to pixmap */
1478 return (swrast_tri_func
) NULL
;
1483 /* Override for the swrast tri-selection function. Try to use one
1484 * of our internal tri functions, otherwise fall back to the
1485 * standard swrast functions.
1487 void xmesa_choose_triangle( GLcontext
*ctx
)
1489 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1491 if (!(swrast
->Triangle
= get_triangle_func( ctx
)))
1492 _swrast_choose_triangle( ctx
);