1 /* $Id: xm_tri.c,v 1.31 2003/02/17 16:36:01 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 #define NAME smooth_TRUECOLOR_z_triangle
61 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
64 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
65 XMesaImage *img = xmesa->xm_buffer->backimage;
67 #define RENDER_SPAN( span ) \
68 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
70 for (i = 0; i < span.end; i++, x++) { \
71 const DEPTH_TYPE z = FixedToDepth(span.z); \
74 PACK_TRUECOLOR(p, FixedToInt(span.red), \
75 FixedToInt(span.green), FixedToInt(span.blue)); \
76 XMesaPutPixel(img, x, y, p); \
79 span.red += span.redStep; \
80 span.green += span.greenStep; \
81 span.blue += span.blueStep; \
82 span.z += span.zStep; \
85 #include "swrast/s_tritemp.h"
91 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
93 #define NAME smooth_8A8B8G8R_z_triangle
95 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
97 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
98 #define PIXEL_TYPE GLuint
99 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
101 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
103 #define RENDER_SPAN( span ) \
105 for (i = 0; i < span.end; i++) { \
106 const DEPTH_TYPE z = FixedToDepth(span.z); \
108 pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
109 FixedToInt(span.green), FixedToInt(span.blue)); \
112 span.red += span.redStep; \
113 span.green += span.greenStep; \
114 span.blue += span.blueStep; \
115 span.z += span.zStep; \
118 #include "swrast/s_tritemp.h"
123 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
125 #define NAME smooth_8R8G8B_z_triangle
127 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
129 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
130 #define PIXEL_TYPE GLuint
131 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
133 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
135 #define RENDER_SPAN( span ) \
137 for (i = 0; i < span.end; i++) { \
138 const DEPTH_TYPE z = FixedToDepth(span.z); \
140 pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
141 FixedToInt(span.green), FixedToInt(span.blue)); \
144 span.red += span.redStep; \
145 span.green += span.greenStep; \
146 span.blue += span.blueStep; \
147 span.z += span.zStep; \
150 #include "swrast/s_tritemp.h"
155 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
157 #define NAME smooth_8R8G8B24_z_triangle
159 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
161 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
162 #define PIXEL_TYPE bgr_t
163 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
165 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
166 #define RENDER_SPAN( span ) \
168 for (i = 0; i < span.end; i++) { \
169 const DEPTH_TYPE z = FixedToDepth(span.z); \
171 PIXEL_TYPE *ptr = pRow + i; \
172 ptr->r = FixedToInt(span.red); \
173 ptr->g = FixedToInt(span.green); \
174 ptr->b = FixedToInt(span.blue); \
177 span.red += span.redStep; \
178 span.green += span.greenStep; \
179 span.blue += span.blueStep; \
180 span.z += span.zStep; \
182 #include "swrast/s_tritemp.h"
187 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
189 #define NAME smooth_TRUEDITHER_z_triangle
191 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
194 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
195 XMesaImage *img = xmesa->xm_buffer->backimage;
196 #define RENDER_SPAN( span ) \
198 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
199 for (i = 0; i < span.end; i++, x++) { \
200 const DEPTH_TYPE z = FixedToDepth(span.z); \
203 PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
204 FixedToInt(span.green), FixedToInt(span.blue)); \
205 XMesaPutPixel(img, x, y, p); \
208 span.red += span.redStep; \
209 span.green += span.greenStep; \
210 span.blue += span.blueStep; \
211 span.z += span.zStep; \
213 #include "swrast/s_tritemp.h"
218 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
220 #define NAME smooth_5R6G5B_z_triangle
222 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
224 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
225 #define PIXEL_TYPE GLushort
226 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
228 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
229 #define RENDER_SPAN( span ) \
231 for (i = 0; i < span.end; i++) { \
232 const DEPTH_TYPE z = FixedToDepth(span.z); \
234 pRow[i] = PACK_5R6G5B(FixedToInt(span.red), \
235 FixedToInt(span.green), FixedToInt(span.blue)); \
238 span.red += span.redStep; \
239 span.green += span.greenStep; \
240 span.blue += span.blueStep; \
241 span.z += span.zStep; \
243 #include "swrast/s_tritemp.h"
248 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
250 #define NAME smooth_DITHER_5R6G5B_z_triangle
252 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
254 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
255 #define PIXEL_TYPE GLushort
256 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
258 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
259 #define RENDER_SPAN( span ) \
261 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
262 for (i = 0; i < span.end; i++, x++) { \
263 const DEPTH_TYPE z = FixedToDepth(span.z); \
265 PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
266 FixedToInt(span.green), FixedToInt(span.blue)); \
269 span.red += span.redStep; \
270 span.green += span.greenStep; \
271 span.blue += span.blueStep; \
272 span.z += span.zStep; \
274 #include "swrast/s_tritemp.h"
279 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
281 #define NAME smooth_DITHER8_z_triangle
283 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
285 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
286 #define PIXEL_TYPE GLubyte
287 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
289 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
290 #define RENDER_SPAN( span ) \
292 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
294 for (i = 0; i < span.end; i++, x++) { \
295 const DEPTH_TYPE z = FixedToDepth(span.z); \
297 pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red),\
298 FixedToInt(span.green), FixedToInt(span.blue) ); \
301 span.red += span.redStep; \
302 span.green += span.greenStep; \
303 span.blue += span.blueStep; \
304 span.z += span.zStep; \
306 #include "swrast/s_tritemp.h"
311 * XImage, smooth, depth-buffered, PF_DITHER triangle.
313 #define NAME smooth_DITHER_z_triangle
315 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
318 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
319 XMesaImage *img = xmesa->xm_buffer->backimage;
320 #define RENDER_SPAN( span ) \
322 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
324 for (i = 0; i < span.end; i++, x++) { \
325 const DEPTH_TYPE z = FixedToDepth(span.z); \
327 unsigned long p = XDITHER(x, FixedToInt(span.red), \
328 FixedToInt(span.green), FixedToInt(span.blue)); \
329 XMesaPutPixel(img, x, y, p); \
332 span.red += span.redStep; \
333 span.green += span.greenStep; \
334 span.blue += span.blueStep; \
335 span.z += span.zStep; \
337 #include "swrast/s_tritemp.h"
342 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
344 #define NAME smooth_LOOKUP8_z_triangle
346 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
348 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
349 #define PIXEL_TYPE GLubyte
350 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
352 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
353 #define RENDER_SPAN( span ) \
356 for (i = 0; i < span.end; i++) { \
357 const DEPTH_TYPE z = FixedToDepth(span.z); \
359 pRow[i] = LOOKUP(FixedToInt(span.red), \
360 FixedToInt(span.green), FixedToInt(span.blue)); \
363 span.red += span.redStep; \
364 span.green += span.greenStep; \
365 span.blue += span.blueStep; \
366 span.z += span.zStep; \
368 #include "swrast/s_tritemp.h"
373 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
375 #define NAME smooth_HPCR_z_triangle
377 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
379 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
380 #define PIXEL_TYPE GLubyte
381 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
383 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
384 #define RENDER_SPAN( span ) \
386 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
387 for (i = 0; i < span.end; i++, x++) { \
388 const DEPTH_TYPE z = FixedToDepth(span.z); \
390 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
391 FixedToInt(span.green), FixedToInt(span.blue) ); \
394 span.red += span.redStep; \
395 span.green += span.greenStep; \
396 span.blue += span.blueStep; \
397 span.z += span.zStep; \
399 #include "swrast/s_tritemp.h"
404 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
406 #define NAME flat_TRUECOLOR_z_triangle
408 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
410 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
411 XMesaImage *img = xmesa->xm_buffer->backimage; \
412 unsigned long pixel; \
413 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
414 #define RENDER_SPAN( span ) \
416 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
417 for (i = 0; i < span.end; i++, x++) { \
418 const DEPTH_TYPE z = FixedToDepth(span.z); \
420 XMesaPutPixel(img, x, y, pixel); \
423 span.z += span.zStep; \
425 #include "swrast/s_tritemp.h"
430 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
432 #define NAME flat_8A8B8G8R_z_triangle
434 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
435 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
436 #define PIXEL_TYPE GLuint
437 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
439 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
440 unsigned long p = PACK_8B8G8R( v2->color[0], \
441 v2->color[1], v2->color[2] );
442 #define RENDER_SPAN( span ) \
444 for (i = 0; i < span.end; i++) { \
445 const DEPTH_TYPE z = FixedToDepth(span.z); \
447 pRow[i] = (PIXEL_TYPE) p; \
450 span.z += span.zStep; \
452 #include "swrast/s_tritemp.h"
457 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
459 #define NAME flat_8R8G8B_z_triangle
461 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
462 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
463 #define PIXEL_TYPE GLuint
464 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
466 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
467 unsigned long p = PACK_8R8G8B( v2->color[0], \
468 v2->color[1], v2->color[2] );
469 #define RENDER_SPAN( span ) \
471 for (i = 0; i < span.end; i++) { \
472 DEPTH_TYPE z = FixedToDepth(span.z); \
474 pRow[i] = (PIXEL_TYPE) p; \
477 span.z += span.zStep; \
479 #include "swrast/s_tritemp.h"
484 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
486 #define NAME flat_8R8G8B24_z_triangle
488 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
489 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
490 #define PIXEL_TYPE bgr_t
491 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
493 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
494 const GLubyte *color = v2->color;
495 #define RENDER_SPAN( span ) \
497 for (i = 0; i < span.end; i++) { \
498 const DEPTH_TYPE z = FixedToDepth(span.z); \
500 PIXEL_TYPE *ptr = pRow + i; \
501 ptr->r = color[RCOMP]; \
502 ptr->g = color[GCOMP]; \
503 ptr->b = color[BCOMP]; \
506 span.z += span.zStep; \
508 #include "swrast/s_tritemp.h"
513 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
515 #define NAME flat_TRUEDITHER_z_triangle
517 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
519 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
520 XMesaImage *img = xmesa->xm_buffer->backimage;
521 #define RENDER_SPAN( span ) \
523 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
524 for (i = 0; i < span.end; i++, x++) { \
525 const DEPTH_TYPE z = FixedToDepth(span.z); \
528 PACK_TRUEDITHER(p, x, y, v2->color[0], \
529 v2->color[1], v2->color[2]); \
530 XMesaPutPixel(img, x, y, p); \
533 span.z += span.zStep; \
535 #include "swrast/s_tritemp.h"
540 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
542 #define NAME flat_5R6G5B_z_triangle
544 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
545 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
546 #define PIXEL_TYPE GLushort
547 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
549 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
550 unsigned long p = PACK_5R6G5B( v2->color[0], \
551 v2->color[1], v2->color[2] );
552 #define RENDER_SPAN( span ) \
554 for (i = 0; i < span.end; i++) { \
555 const DEPTH_TYPE z = FixedToDepth(span.z); \
557 pRow[i] = (PIXEL_TYPE) p; \
560 span.z += span.zStep; \
562 #include "swrast/s_tritemp.h"
567 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
569 #define NAME flat_DITHER_5R6G5B_z_triangle
571 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
572 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
573 #define PIXEL_TYPE GLushort
574 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
576 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
577 const GLubyte *color = v2->color;
578 #define RENDER_SPAN( span ) \
580 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
581 for (i = 0; i < span.end; i++, x++) { \
582 const DEPTH_TYPE z = FixedToDepth(span.z); \
584 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
585 color[GCOMP], color[BCOMP]); \
588 span.z += span.zStep; \
590 #include "swrast/s_tritemp.h"
595 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
597 #define NAME flat_DITHER8_z_triangle
599 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
600 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
601 #define PIXEL_TYPE GLubyte
602 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
604 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
605 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
606 #define RENDER_SPAN( span ) \
608 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
609 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
610 for (i = 0; i < span.end; i++, x++) { \
611 const DEPTH_TYPE z = FixedToDepth(span.z); \
613 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
616 span.z += span.zStep; \
618 #include "swrast/s_tritemp.h"
623 * XImage, flat, depth-buffered, PF_DITHER triangle.
625 #define NAME flat_DITHER_z_triangle
627 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
629 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
630 XMesaImage *img = xmesa->xm_buffer->backimage; \
631 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
632 #define RENDER_SPAN( span ) \
634 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
635 FLAT_DITHER_ROW_SETUP(y); \
636 for (i = 0; i < span.end; i++, x++) { \
637 const DEPTH_TYPE z = FixedToDepth(span.z); \
639 unsigned long p = FLAT_DITHER(x); \
640 XMesaPutPixel(img, x, y, p); \
643 span.z += span.zStep; \
645 #include "swrast/s_tritemp.h"
650 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
652 #define NAME flat_HPCR_z_triangle
654 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
655 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
656 #define PIXEL_TYPE GLubyte
657 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
659 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
660 GLubyte r = v2->color[0]; \
661 GLubyte g = v2->color[1]; \
662 GLubyte b = v2->color[2];
663 #define RENDER_SPAN( span ) \
665 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
666 for (i = 0; i < span.end; i++, x++) { \
667 const DEPTH_TYPE z = FixedToDepth(span.z); \
669 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
672 span.z += span.zStep; \
674 #include "swrast/s_tritemp.h"
679 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
681 #define NAME flat_LOOKUP8_z_triangle
683 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
684 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
685 #define PIXEL_TYPE GLubyte
686 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
688 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
690 GLubyte r = v2->color[0]; \
691 GLubyte g = v2->color[1]; \
692 GLubyte b = v2->color[2]; \
693 GLubyte p = LOOKUP(r,g,b);
694 #define RENDER_SPAN( span ) \
696 for (i = 0; i < span.end; i++) { \
697 const DEPTH_TYPE z = FixedToDepth(span.z); \
702 span.z += span.zStep; \
704 #include "swrast/s_tritemp.h"
709 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
711 #define NAME smooth_TRUECOLOR_triangle
714 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
715 XMesaImage *img = xmesa->xm_buffer->backimage;
716 #define RENDER_SPAN( span ) \
718 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
719 for (i = 0; i < span.end; i++, x++) { \
721 PACK_TRUECOLOR(p, FixedToInt(span.red), \
722 FixedToInt(span.green), FixedToInt(span.blue)); \
723 XMesaPutPixel(img, x, y, p); \
724 span.red += span.redStep; \
725 span.green += span.greenStep; \
726 span.blue += span.blueStep; \
728 #include "swrast/s_tritemp.h"
733 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
735 #define NAME smooth_8A8B8G8R_triangle
737 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
738 #define PIXEL_TYPE GLuint
739 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
741 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
742 #define RENDER_SPAN( span ) \
744 for (i = 0; i < span.end; i++) { \
745 pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
746 FixedToInt(span.green), FixedToInt(span.blue) ); \
747 span.red += span.redStep; \
748 span.green += span.greenStep; \
749 span.blue += span.blueStep; \
751 #include "swrast/s_tritemp.h"
756 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
758 #define NAME smooth_8R8G8B_triangle
760 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
761 #define PIXEL_TYPE GLuint
762 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
764 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
765 #define RENDER_SPAN( span ) \
767 for (i = 0; i < span.end; i++) { \
768 pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
769 FixedToInt(span.green), FixedToInt(span.blue) ); \
770 span.red += span.redStep; \
771 span.green += span.greenStep; \
772 span.blue += span.blueStep; \
774 #include "swrast/s_tritemp.h"
779 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
781 #define NAME smooth_8R8G8B24_triangle
783 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
784 #define PIXEL_TYPE bgr_t
785 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
787 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
788 #define RENDER_SPAN( span ) \
790 PIXEL_TYPE *pixel = pRow; \
791 for (i = 0; i < span.end; i++, pixel++) { \
792 pixel->r = FixedToInt(span.red); \
793 pixel->g = FixedToInt(span.green); \
794 pixel->b = FixedToInt(span.blue); \
795 span.red += span.redStep; \
796 span.green += span.greenStep; \
797 span.blue += span.blueStep; \
799 #include "swrast/s_tritemp.h"
804 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
806 #define NAME smooth_TRUEDITHER_triangle
809 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
810 XMesaImage *img = xmesa->xm_buffer->backimage;
811 #define RENDER_SPAN( span ) \
813 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
814 for (i = 0; i < span.end; i++, x++) { \
816 PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
817 FixedToInt(span.green), FixedToInt(span.blue)); \
818 XMesaPutPixel(img, x, y, p ); \
819 span.red += span.redStep; \
820 span.green += span.greenStep; \
821 span.blue += span.blueStep; \
823 #include "swrast/s_tritemp.h"
828 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
830 #define NAME smooth_5R6G5B_triangle
832 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
833 #define PIXEL_TYPE GLushort
834 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
836 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
837 #define RENDER_SPAN( span ) \
839 for (i = 0; i < span.end; i++) { \
840 pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span.red), \
841 FixedToInt(span.green), FixedToInt(span.blue)); \
842 span.red += span.redStep; \
843 span.green += span.greenStep; \
844 span.blue += span.blueStep; \
846 #include "swrast/s_tritemp.h"
851 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
853 #define NAME smooth_DITHER_5R6G5B_triangle
855 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
856 #define PIXEL_TYPE GLushort
857 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
859 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
860 #define RENDER_SPAN( span ) \
862 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
863 for (i = 0; i < span.end; i++, x++) { \
864 PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
865 FixedToInt(span.green), FixedToInt(span.blue)); \
866 span.red += span.redStep; \
867 span.green += span.greenStep; \
868 span.blue += span.blueStep; \
870 #include "swrast/s_tritemp.h"
875 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
877 #define NAME smooth_DITHER8_triangle
879 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
880 #define PIXEL_TYPE GLubyte
881 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
883 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
884 #define RENDER_SPAN( span ) \
886 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
888 for (i = 0; i < span.end; i++, x++) { \
889 pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \
890 FixedToInt(span.green), FixedToInt(span.blue) ); \
891 span.red += span.redStep; \
892 span.green += span.greenStep; \
893 span.blue += span.blueStep; \
895 #include "swrast/s_tritemp.h"
900 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
902 #define NAME smooth_DITHER_triangle
905 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
906 XMesaImage *img = xmesa->xm_buffer->backimage;
907 #define RENDER_SPAN( span ) \
909 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
911 for (i = 0; i < span.end; i++, x++) { \
912 unsigned long p = XDITHER(x, FixedToInt(span.red), \
913 FixedToInt(span.green), FixedToInt(span.blue) ); \
914 XMesaPutPixel(img, x, y, p); \
915 span.red += span.redStep; \
916 span.green += span.greenStep; \
917 span.blue += span.blueStep; \
919 #include "swrast/s_tritemp.h"
924 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
926 #define NAME smooth_LOOKUP8_triangle
928 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
929 #define PIXEL_TYPE GLubyte
930 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
932 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
933 #define RENDER_SPAN( span ) \
936 for (i = 0; i < span.end; i++) { \
937 pRow[i] = LOOKUP(FixedToInt(span.red), \
938 FixedToInt(span.green), FixedToInt(span.blue)); \
939 span.red += span.redStep; \
940 span.green += span.greenStep; \
941 span.blue += span.blueStep; \
943 #include "swrast/s_tritemp.h"
948 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
950 #define NAME smooth_HPCR_triangle
952 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
953 #define PIXEL_TYPE GLubyte
954 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
956 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
957 #define RENDER_SPAN( span ) \
959 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
960 for (i = 0; i < span.end; i++, x++) { \
961 pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
962 FixedToInt(span.green), FixedToInt(span.blue)); \
963 span.red += span.redStep; \
964 span.green += span.greenStep; \
965 span.blue += span.blueStep; \
967 #include "swrast/s_tritemp.h"
972 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
974 #define NAME flat_TRUECOLOR_triangle
976 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
977 XMesaImage *img = xmesa->xm_buffer->backimage; \
978 unsigned long pixel; \
979 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
980 #define RENDER_SPAN( span ) \
982 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
983 for (i = 0; i < span.end; i++, x++) { \
984 XMesaPutPixel(img, x, y, pixel); \
986 #include "swrast/s_tritemp.h"
991 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
993 #define NAME flat_8A8B8G8R_triangle
994 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
995 #define PIXEL_TYPE GLuint
996 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
998 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
999 unsigned long p = PACK_8B8G8R( v2->color[0], \
1000 v2->color[1], v2->color[2] );
1001 #define RENDER_SPAN( span ) \
1003 for (i = 0; i < span.end; i++) { \
1004 pRow[i] = (PIXEL_TYPE) p; \
1006 #include "swrast/s_tritemp.h"
1011 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1013 #define NAME flat_8R8G8B_triangle
1014 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1015 #define PIXEL_TYPE GLuint
1016 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1017 #define SETUP_CODE \
1018 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1019 unsigned long p = PACK_8R8G8B( v2->color[0], \
1020 v2->color[1], v2->color[2] );
1021 #define RENDER_SPAN( span ) \
1023 for (i = 0; i < span.end; i++) { \
1024 pRow[i] = (PIXEL_TYPE) p; \
1026 #include "swrast/s_tritemp.h"
1031 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1033 #define NAME flat_8R8G8B24_triangle
1034 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1035 #define PIXEL_TYPE bgr_t
1036 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1037 #define SETUP_CODE \
1038 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1039 const GLubyte *color = v2->color;
1040 #define RENDER_SPAN( span ) \
1042 PIXEL_TYPE *pixel = pRow; \
1043 for (i = 0; i < span.end; i++, pixel++) { \
1044 pixel->r = color[RCOMP]; \
1045 pixel->g = color[GCOMP]; \
1046 pixel->b = color[BCOMP]; \
1048 #include "swrast/s_tritemp.h"
1053 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1055 #define NAME flat_TRUEDITHER_triangle
1056 #define SETUP_CODE \
1057 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1058 XMesaImage *img = xmesa->xm_buffer->backimage;
1059 #define RENDER_SPAN( span ) \
1061 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1062 for (i = 0; i < span.end; i++, x++) { \
1064 PACK_TRUEDITHER(p, x, y, v2->color[0], \
1065 v2->color[1], v2->color[2] ); \
1066 XMesaPutPixel(img, x, y, p); \
1068 #include "swrast/s_tritemp.h"
1073 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1075 #define NAME flat_5R6G5B_triangle
1076 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1077 #define PIXEL_TYPE GLushort
1078 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1079 #define SETUP_CODE \
1080 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1081 unsigned long p = PACK_5R6G5B( v2->color[0], \
1082 v2->color[1], v2->color[2] );
1083 #define RENDER_SPAN( span ) \
1085 for (i = 0; i < span.end; i++) { \
1086 pRow[i] = (PIXEL_TYPE) p; \
1088 #include "swrast/s_tritemp.h"
1093 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1095 #define NAME flat_DITHER_5R6G5B_triangle
1096 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1097 #define PIXEL_TYPE GLushort
1098 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1099 #define SETUP_CODE \
1100 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1101 const GLubyte *color = v2->color;
1102 #define RENDER_SPAN( span ) \
1104 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1105 for (i = 0; i < span.end; i++, x++) { \
1106 PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
1107 color[GCOMP], color[BCOMP]); \
1109 #include "swrast/s_tritemp.h"
1114 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1116 #define NAME flat_DITHER8_triangle
1117 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1118 #define PIXEL_TYPE GLubyte
1119 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1120 #define SETUP_CODE \
1121 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1122 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1123 #define RENDER_SPAN( span ) \
1125 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1126 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
1127 for (i = 0; i < span.end; i++, x++) { \
1128 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
1130 #include "swrast/s_tritemp.h"
1135 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1137 #define NAME flat_DITHER_triangle
1138 #define SETUP_CODE \
1139 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1140 XMesaImage *img = xmesa->xm_buffer->backimage; \
1141 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1142 #define RENDER_SPAN( span ) \
1144 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1145 FLAT_DITHER_ROW_SETUP(y); \
1146 for (i = 0; i < span.end; i++, x++) { \
1147 unsigned long p = FLAT_DITHER(x); \
1148 XMesaPutPixel(img, x, y, p ); \
1150 #include "swrast/s_tritemp.h"
1155 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1157 #define NAME flat_HPCR_triangle
1158 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1159 #define PIXEL_TYPE GLubyte
1160 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1161 #define SETUP_CODE \
1162 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1163 GLubyte r = v2->color[0]; \
1164 GLubyte g = v2->color[1]; \
1165 GLubyte b = v2->color[2];
1166 #define RENDER_SPAN( span ) \
1168 GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
1169 for (i = 0; i < span.end; i++, x++) { \
1170 pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
1172 #include "swrast/s_tritemp.h"
1177 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1179 #define NAME flat_LOOKUP8_triangle
1180 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1181 #define PIXEL_TYPE GLubyte
1182 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1183 #define SETUP_CODE \
1184 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
1186 GLubyte r = v2->color[0]; \
1187 GLubyte g = v2->color[1]; \
1188 GLubyte b = v2->color[2]; \
1189 GLubyte p = LOOKUP(r,g,b);
1190 #define RENDER_SPAN( span ) \
1192 for (i = 0; i < span.end; i++) { \
1193 pRow[i] = (PIXEL_TYPE) p; \
1195 #include "swrast/s_tritemp.h"
1200 extern void _xmesa_print_triangle_func( swrast_tri_func triFunc
);
1201 void _xmesa_print_triangle_func( swrast_tri_func triFunc
)
1203 _mesa_printf("XMesa tri func = ");
1204 if (triFunc
==smooth_TRUECOLOR_z_triangle
)
1205 _mesa_printf("smooth_TRUECOLOR_z_triangle\n");
1206 else if (triFunc
==smooth_8A8B8G8R_z_triangle
)
1207 _mesa_printf("smooth_8A8B8G8R_z_triangle\n");
1208 else if (triFunc
==smooth_8R8G8B_z_triangle
)
1209 _mesa_printf("smooth_8R8G8B_z_triangle\n");
1210 else if (triFunc
==smooth_8R8G8B24_z_triangle
)
1211 _mesa_printf("smooth_8R8G8B24_z_triangle\n");
1212 else if (triFunc
==smooth_TRUEDITHER_z_triangle
)
1213 _mesa_printf("smooth_TRUEDITHER_z_triangle\n");
1214 else if (triFunc
==smooth_5R6G5B_z_triangle
)
1215 _mesa_printf("smooth_5R6G5B_z_triangle\n");
1216 else if (triFunc
==smooth_DITHER_5R6G5B_z_triangle
)
1217 _mesa_printf("smooth_DITHER_5R6G5B_z_triangle\n");
1218 else if (triFunc
==smooth_HPCR_z_triangle
)
1219 _mesa_printf("smooth_HPCR_z_triangle\n");
1220 else if (triFunc
==smooth_DITHER8_z_triangle
)
1221 _mesa_printf("smooth_DITHER8_z_triangle\n");
1222 else if (triFunc
==smooth_LOOKUP8_z_triangle
)
1223 _mesa_printf("smooth_LOOKUP8_z_triangle\n");
1224 else if (triFunc
==flat_TRUECOLOR_z_triangle
)
1225 _mesa_printf("flat_TRUECOLOR_z_triangle\n");
1226 else if (triFunc
==flat_8A8B8G8R_z_triangle
)
1227 _mesa_printf("flat_8A8B8G8R_z_triangle\n");
1228 else if (triFunc
==flat_8R8G8B_z_triangle
)
1229 _mesa_printf("flat_8R8G8B_z_triangle\n");
1230 else if (triFunc
==flat_8R8G8B24_z_triangle
)
1231 _mesa_printf("flat_8R8G8B24_z_triangle\n");
1232 else if (triFunc
==flat_TRUEDITHER_z_triangle
)
1233 _mesa_printf("flat_TRUEDITHER_z_triangle\n");
1234 else if (triFunc
==flat_5R6G5B_z_triangle
)
1235 _mesa_printf("flat_5R6G5B_z_triangle\n");
1236 else if (triFunc
==flat_DITHER_5R6G5B_z_triangle
)
1237 _mesa_printf("flat_DITHER_5R6G5B_z_triangle\n");
1238 else if (triFunc
==flat_HPCR_z_triangle
)
1239 _mesa_printf("flat_HPCR_z_triangle\n");
1240 else if (triFunc
==flat_DITHER8_z_triangle
)
1241 _mesa_printf("flat_DITHER8_z_triangle\n");
1242 else if (triFunc
==flat_LOOKUP8_z_triangle
)
1243 _mesa_printf("flat_LOOKUP8_z_triangle\n");
1244 else if (triFunc
==smooth_TRUECOLOR_triangle
)
1245 _mesa_printf("smooth_TRUECOLOR_triangle\n");
1246 else if (triFunc
==smooth_8A8B8G8R_triangle
)
1247 _mesa_printf("smooth_8A8B8G8R_triangle\n");
1248 else if (triFunc
==smooth_8R8G8B_triangle
)
1249 _mesa_printf("smooth_8R8G8B_triangle\n");
1250 else if (triFunc
==smooth_8R8G8B24_triangle
)
1251 _mesa_printf("smooth_8R8G8B24_triangle\n");
1252 else if (triFunc
==smooth_TRUEDITHER_triangle
)
1253 _mesa_printf("smooth_TRUEDITHER_triangle\n");
1254 else if (triFunc
==smooth_5R6G5B_triangle
)
1255 _mesa_printf("smooth_5R6G5B_triangle\n");
1256 else if (triFunc
==smooth_DITHER_5R6G5B_triangle
)
1257 _mesa_printf("smooth_DITHER_5R6G5B_triangle\n");
1258 else if (triFunc
==smooth_HPCR_triangle
)
1259 _mesa_printf("smooth_HPCR_triangle\n");
1260 else if (triFunc
==smooth_DITHER8_triangle
)
1261 _mesa_printf("smooth_DITHER8_triangle\n");
1262 else if (triFunc
==smooth_LOOKUP8_triangle
)
1263 _mesa_printf("smooth_LOOKUP8_triangle\n");
1264 else if (triFunc
==flat_TRUECOLOR_triangle
)
1265 _mesa_printf("flat_TRUECOLOR_triangle\n");
1266 else if (triFunc
==flat_TRUEDITHER_triangle
)
1267 _mesa_printf("flat_TRUEDITHER_triangle\n");
1268 else if (triFunc
==flat_8A8B8G8R_triangle
)
1269 _mesa_printf("flat_8A8B8G8R_triangle\n");
1270 else if (triFunc
==flat_8R8G8B_triangle
)
1271 _mesa_printf("flat_8R8G8B_triangle\n");
1272 else if (triFunc
==flat_8R8G8B24_triangle
)
1273 _mesa_printf("flat_8R8G8B24_triangle\n");
1274 else if (triFunc
==flat_5R6G5B_triangle
)
1275 _mesa_printf("flat_5R6G5B_triangle\n");
1276 else if (triFunc
==flat_DITHER_5R6G5B_triangle
)
1277 _mesa_printf("flat_DITHER_5R6G5B_triangle\n");
1278 else if (triFunc
==flat_HPCR_triangle
)
1279 _mesa_printf("flat_HPCR_triangle\n");
1280 else if (triFunc
==flat_DITHER8_triangle
)
1281 _mesa_printf("flat_DITHER8_triangle\n");
1282 else if (triFunc
==flat_LOOKUP8_triangle
)
1283 _mesa_printf("flat_LOOKUP8_triangle\n");
1285 _mesa_printf("???\n");
1292 /* record the current triangle function name */
1293 static const char *triFuncName
= NULL
;
1295 #define USE(triFunc) \
1297 triFuncName = #triFunc; \
1303 #define USE(triFunc) return triFunc
1308 static swrast_tri_func
get_triangle_func( GLcontext
*ctx
)
1310 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1311 XMesaContext xmesa
= (XMesaContext
) ctx
->DriverCtx
;
1312 int depth
= GET_VISUAL_DEPTH(xmesa
->xm_visual
);
1320 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1321 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1322 if (ctx
->Texture
._EnabledUnits
) return (swrast_tri_func
) NULL
;
1323 if (swrast
->_RasterMask
& MULTI_DRAW_BIT
) return (swrast_tri_func
) NULL
;
1324 if (ctx
->Polygon
.CullFlag
&&
1325 ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
1326 return (swrast_tri_func
) NULL
;
1328 if (xmesa
->xm_buffer
->buffer
==XIMAGE
) {
1329 if ( ctx
->Light
.ShadeModel
==GL_SMOOTH
1330 && swrast
->_RasterMask
==DEPTH_BIT
1331 && ctx
->Depth
.Func
==GL_LESS
1332 && ctx
->Depth
.Mask
==GL_TRUE
1333 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1334 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1335 switch (xmesa
->pixelformat
) {
1337 USE(smooth_TRUECOLOR_z_triangle
);
1339 USE(smooth_8A8B8G8R_z_triangle
);
1341 USE(smooth_8R8G8B_z_triangle
);
1343 USE(smooth_8R8G8B24_z_triangle
);
1344 case PF_Dither_True
:
1345 USE(smooth_TRUEDITHER_z_triangle
);
1347 USE(smooth_5R6G5B_z_triangle
);
1348 case PF_Dither_5R6G5B
:
1349 USE(smooth_DITHER_5R6G5B_z_triangle
);
1351 USE(smooth_HPCR_z_triangle
);
1354 USE(smooth_DITHER8_z_triangle
);
1356 USE(smooth_DITHER_z_triangle
);
1360 USE(smooth_LOOKUP8_z_triangle
);
1362 return (swrast_tri_func
) NULL
;
1364 return (swrast_tri_func
) NULL
;
1367 if ( ctx
->Light
.ShadeModel
==GL_FLAT
1368 && swrast
->_RasterMask
==DEPTH_BIT
1369 && ctx
->Depth
.Func
==GL_LESS
1370 && ctx
->Depth
.Mask
==GL_TRUE
1371 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1372 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1373 switch (xmesa
->pixelformat
) {
1375 USE(flat_TRUECOLOR_z_triangle
);
1377 USE(flat_8A8B8G8R_z_triangle
);
1379 USE(flat_8R8G8B_z_triangle
);
1381 USE(flat_8R8G8B24_z_triangle
);
1382 case PF_Dither_True
:
1383 USE(flat_TRUEDITHER_z_triangle
);
1385 USE(flat_5R6G5B_z_triangle
);
1386 case PF_Dither_5R6G5B
:
1387 USE(flat_DITHER_5R6G5B_z_triangle
);
1389 USE(flat_HPCR_z_triangle
);
1392 USE(flat_DITHER8_z_triangle
);
1394 USE(flat_DITHER_z_triangle
);
1398 USE(flat_LOOKUP8_z_triangle
);
1400 return (swrast_tri_func
) NULL
;
1402 return (swrast_tri_func
) NULL
;
1405 if ( swrast
->_RasterMask
==0 /* no depth test */
1406 && ctx
->Light
.ShadeModel
==GL_SMOOTH
1407 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1408 switch (xmesa
->pixelformat
) {
1410 USE(smooth_TRUECOLOR_triangle
);
1412 USE(smooth_8A8B8G8R_triangle
);
1414 USE(smooth_8R8G8B_triangle
);
1416 USE(smooth_8R8G8B24_triangle
);
1417 case PF_Dither_True
:
1418 USE(smooth_TRUEDITHER_triangle
);
1420 USE(smooth_5R6G5B_triangle
);
1421 case PF_Dither_5R6G5B
:
1422 USE(smooth_DITHER_5R6G5B_triangle
);
1424 USE(smooth_HPCR_triangle
);
1427 USE(smooth_DITHER8_triangle
);
1429 USE(smooth_DITHER_triangle
);
1433 USE(smooth_LOOKUP8_triangle
);
1435 return (swrast_tri_func
) NULL
;
1437 return (swrast_tri_func
) NULL
;
1441 if ( swrast
->_RasterMask
==0 /* no depth test */
1442 && ctx
->Light
.ShadeModel
==GL_FLAT
1443 && ctx
->Polygon
.StippleFlag
==GL_FALSE
) {
1444 switch (xmesa
->pixelformat
) {
1446 USE(flat_TRUECOLOR_triangle
);
1447 case PF_Dither_True
:
1448 USE(flat_TRUEDITHER_triangle
);
1450 USE(flat_8A8B8G8R_triangle
);
1452 USE(flat_8R8G8B_triangle
);
1454 USE(flat_8R8G8B24_triangle
);
1456 USE(flat_5R6G5B_triangle
);
1457 case PF_Dither_5R6G5B
:
1458 USE(flat_DITHER_5R6G5B_triangle
);
1460 USE(flat_HPCR_triangle
);
1463 USE(flat_DITHER8_triangle
);
1465 USE(flat_DITHER_triangle
);
1469 USE(flat_LOOKUP8_triangle
);
1471 return (swrast_tri_func
) NULL
;
1473 return (swrast_tri_func
) NULL
;
1477 return (swrast_tri_func
) NULL
;
1480 /* draw to pixmap */
1481 return (swrast_tri_func
) NULL
;
1486 /* Override for the swrast tri-selection function. Try to use one
1487 * of our internal tri functions, otherwise fall back to the
1488 * standard swrast functions.
1490 void xmesa_choose_triangle( GLcontext
*ctx
)
1492 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1494 if (!(swrast
->Triangle
= get_triangle_func( ctx
)))
1495 _swrast_choose_triangle( ctx
);