b152e5c8bbc84b84c927b48631a52f90732e78ce
[mesa.git] / src / mesa / drivers / x11 / xm_tri.c
1 /* $Id: xm_tri.c,v 1.8 2000/11/06 17:28:20 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
28 /*
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.
32 */
33
34
35 #include "glxheader.h"
36 #include "depth.h"
37 #include "macros.h"
38 #include "vb.h"
39 #include "types.h"
40 #include "xmesaP.h"
41
42 /* Internal swrast includes:
43 */
44 #include "swrast/s_context.h"
45 #include "swrast/s_depth.h"
46 #include "swrast/s_triangle.h"
47
48
49
50
51 /**********************************************************************/
52 /*** Triangle rendering ***/
53 /**********************************************************************/
54
55
56 #if 0
57 /*
58 * Render a triangle into a pixmap, any pixel format, flat shaded and
59 * no raster ops.
60 */
61 static void flat_pixmap_triangle( GLcontext *ctx,
62 SWvertex *v0,
63 SWvertex *v1,
64 SWvertex *v2 )
65 {
66 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
67 XMesaPoint p[3];
68 XMesaGC gc;
69
70 {
71 unsigned long pixel;
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],
76 xmesa->pixelformat );
77 }
78 else {
79 pixel = v0->index;
80 }
81 gc = xmesa->xm_buffer->gc2;
82 XMesaSetForeground( xmesa->display, gc, pixel );
83 }
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 );
92 }
93 #endif
94
95
96 /*
97 * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
98 */
99 static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx,
100 SWvertex *v0,
101 SWvertex *v1,
102 SWvertex *v2 )
103 {
104 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
105 XMesaImage *img = xmesa->xm_buffer->backimage;
106 #define INTERP_Z 1
107 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
108 #define INTERP_RGB 1
109 #define INNER_LOOP( LEFT, RIGHT, Y ) \
110 { \
111 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer, Y); \
112 GLint len = RIGHT-LEFT; \
113 (void) fffog; \
114 for (i=0;i<len;i++,xx++) { \
115 GLdepth z = FixedToDepth(ffz); \
116 if (z < zRow[i]) { \
117 unsigned long p; \
118 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
119 XMesaPutPixel( img, xx, yy, p ); \
120 zRow[i] = z; \
121 } \
122 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
123 ffz += fdzdx; \
124 } \
125 }
126 #include "swrast/s_tritemp.h"
127 }
128
129
130
131 /*
132 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
133 */
134 static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
135 SWvertex *v0,
136 SWvertex *v1,
137 SWvertex *v2 )
138 {
139 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
140 #define INTERP_Z 1
141 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
142 #define INTERP_RGB 1
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 ) \
147 { \
148 GLint i, len = RIGHT-LEFT; \
149 (void) fffog; \
150 for (i=0;i<len;i++) { \
151 GLdepth z = FixedToDepth(ffz); \
152 if (z < zRow[i]) { \
153 pRow[i] = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
154 FixedToInt(ffb) ); \
155 zRow[i] = z; \
156 } \
157 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
158 ffz += fdzdx; \
159 } \
160 }
161 #include "swrast/s_tritemp.h"
162 }
163
164
165 /*
166 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
167 */
168 static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
169 SWvertex *v0,
170 SWvertex *v1,
171 SWvertex *v2 )
172 {
173 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
174 #define INTERP_Z 1
175 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
176 #define INTERP_RGB 1
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 ) \
181 { \
182 GLint i, len = RIGHT-LEFT; \
183 (void) fffog; \
184 for (i=0;i<len;i++) { \
185 GLdepth z = FixedToDepth(ffz); \
186 if (z < zRow[i]) { \
187 pRow[i] = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
188 FixedToInt(ffb) ); \
189 zRow[i] = z; \
190 } \
191 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
192 ffz += fdzdx; \
193 } \
194 }
195 #include "swrast/s_tritemp.h"
196 }
197
198
199 /*
200 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
201 */
202 static void smooth_8R8G8B24_z_triangle( GLcontext *ctx,
203 SWvertex *v0,
204 SWvertex *v1,
205 SWvertex *v2 )
206 {
207 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
208 #define INTERP_Z 1
209 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
210 #define INTERP_RGB 1
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 ) \
215 { \
216 GLint i, len = RIGHT-LEFT; \
217 (void) fffog; \
218 for (i=0;i<len;i++) { \
219 GLdepth z = FixedToDepth(ffz); \
220 if (z < zRow[i]) { \
221 PIXEL_TYPE *ptr = pRow + i; \
222 ptr->r = FixedToInt(ffr); \
223 ptr->g = FixedToInt(ffg); \
224 ptr->b = FixedToInt(ffb); \
225 zRow[i] = z; \
226 } \
227 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
228 ffz += fdzdx; \
229 } \
230 }
231 #include "swrast/s_tritemp.h"
232 }
233
234
235 /*
236 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
237 */
238 static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx,
239 SWvertex *v0,
240 SWvertex *v1,
241 SWvertex *v2 )
242 {
243 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
244 XMesaImage *img = xmesa->xm_buffer->backimage;
245 #define INTERP_Z 1
246 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
247 #define INTERP_RGB 1
248 #define INNER_LOOP( LEFT, RIGHT, Y ) \
249 { \
250 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
251 (void) fffog; \
252 for (i=0;i<len;i++,xx++) { \
253 GLdepth z = FixedToDepth(ffz); \
254 if (z < zRow[i]) { \
255 unsigned long p; \
256 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), \
257 FixedToInt(ffg), FixedToInt(ffb) ); \
258 XMesaPutPixel( img, xx, yy, p ); \
259 zRow[i] = z; \
260 } \
261 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
262 ffz += fdzdx; \
263 } \
264 }
265 #include "swrast/s_tritemp.h"
266 }
267
268
269 /*
270 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
271 */
272 static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
273 SWvertex *v0,
274 SWvertex *v1,
275 SWvertex *v2 )
276 {
277 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
278 #define INTERP_Z 1
279 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
280 #define INTERP_RGB 1
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 ) \
285 { \
286 GLint i, len = RIGHT-LEFT; \
287 (void) fffog; \
288 for (i=0;i<len;i++) { \
289 DEPTH_TYPE z = FixedToDepth(ffz); \
290 if (z < zRow[i]) { \
291 pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
292 FixedToInt(ffb) ); \
293 zRow[i] = z; \
294 } \
295 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
296 ffz += fdzdx; \
297 } \
298 }
299 #include "swrast/s_tritemp.h"
300 }
301
302
303 /*
304 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
305 */
306 static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
307 SWvertex *v0,
308 SWvertex *v1,
309 SWvertex *v2 )
310 {
311 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
312 #define INTERP_Z 1
313 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
314 #define INTERP_RGB 1
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 ) \
319 { \
320 GLint i, len = RIGHT-LEFT; \
321 (void) fffog; \
322 for (i=0;i<len;i++) { \
323 GLdepth z = FixedToDepth(ffz); \
324 if (z < zRow[i]) { \
325 PACK_TRUEDITHER(pRow[i], LEFT+i, Y, FixedToInt(ffr), \
326 FixedToInt(ffg), FixedToInt(ffb) ); \
327 zRow[i] = z; \
328 } \
329 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
330 ffz += fdzdx; \
331 } \
332 }
333 #include "swrast/s_tritemp.h"
334 }
335
336
337 /*
338 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
339 */
340 static void smooth_DITHER8_z_triangle( GLcontext *ctx,
341 SWvertex *v0,
342 SWvertex *v1,
343 SWvertex *v2 )
344 {
345 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
346 #define INTERP_Z 1
347 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
348 #define INTERP_RGB 1
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 ) \
353 { \
354 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
355 XDITHER_SETUP(yy); \
356 (void) fffog; \
357 for (i=0;i<len;i++,xx++) { \
358 GLdepth z = FixedToDepth(ffz); \
359 if (z < zRow[i]) { \
360 pRow[i] = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
361 FixedToInt(ffg), FixedToInt(ffb) ); \
362 zRow[i] = z; \
363 } \
364 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
365 ffz += fdzdx; \
366 } \
367 }
368 #include "swrast/s_tritemp.h"
369 }
370
371
372 /*
373 * XImage, smooth, depth-buffered, PF_DITHER triangle.
374 */
375 static void smooth_DITHER_z_triangle( GLcontext *ctx,
376 SWvertex *v0,
377 SWvertex *v1,
378 SWvertex *v2 )
379 {
380 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
381 XMesaImage *img = xmesa->xm_buffer->backimage;
382 #define INTERP_Z 1
383 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
384 #define INTERP_RGB 1
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 ) \
389 { \
390 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
391 XDITHER_SETUP(yy); \
392 (void) fffog; \
393 for (i=0;i<len;i++,xx++) { \
394 GLdepth z = FixedToDepth(ffz); \
395 if (z < zRow[i]) { \
396 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
397 FixedToInt(ffg), FixedToInt(ffb) ); \
398 XMesaPutPixel( img, xx, yy, p ); \
399 zRow[i] = z; \
400 } \
401 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
402 ffz += fdzdx; \
403 } \
404 }
405 #include "swrast/s_tritemp.h"
406 }
407
408
409 /*
410 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
411 */
412 static void smooth_LOOKUP8_z_triangle( GLcontext *ctx,
413 SWvertex *v0,
414 SWvertex *v1,
415 SWvertex *v2 )
416 {
417 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
418 #define INTERP_Z 1
419 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
420 #define INTERP_RGB 1
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 ) \
425 { \
426 GLint i, len = RIGHT-LEFT; \
427 LOOKUP_SETUP; \
428 (void) fffog; \
429 for (i=0;i<len;i++) { \
430 GLdepth z = FixedToDepth(ffz); \
431 if (z < zRow[i]) { \
432 pRow[i] = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
433 FixedToInt(ffb) ); \
434 zRow[i] = z; \
435 } \
436 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
437 ffz += fdzdx; \
438 } \
439 }
440 #include "swrast/s_tritemp.h"
441 }
442
443
444
445 /*
446 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
447 */
448 static void smooth_HPCR_z_triangle( GLcontext *ctx,
449 SWvertex *v0,
450 SWvertex *v1,
451 SWvertex *v2 )
452 {
453 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
454 #define INTERP_Z 1
455 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
456 #define INTERP_RGB 1
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 ) \
461 { \
462 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
463 (void) fffog; \
464 for (i=0;i<len;i++,xx++) { \
465 GLdepth z = FixedToDepth(ffz); \
466 if (z < zRow[i]) { \
467 pRow[i] = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
468 FixedToInt(ffg), FixedToInt(ffb) ); \
469 zRow[i] = z; \
470 } \
471 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
472 ffz += fdzdx; \
473 } \
474 }
475 #include "swrast/s_tritemp.h"
476 }
477
478
479 /*
480 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
481 */
482 static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
483 SWvertex *v0,
484 SWvertex *v1,
485 SWvertex *v2 )
486 {
487 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
488 XMesaImage *img = xmesa->xm_buffer->backimage;
489 #define INTERP_Z 1
490 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
491 #define SETUP_CODE \
492 unsigned long pixel; \
493 PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
494
495 #define INNER_LOOP( LEFT, RIGHT, Y ) \
496 { \
497 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
498 (void) fffog; \
499 for (i=0;i<len;i++,xx++) { \
500 GLdepth z = FixedToDepth(ffz); \
501 if (z < zRow[i]) { \
502 XMesaPutPixel( img, xx, yy, pixel ); \
503 zRow[i] = z; \
504 } \
505 ffz += fdzdx; \
506 } \
507 }
508 #include "swrast/s_tritemp.h"
509 }
510
511
512 /*
513 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
514 */
515 static void flat_8A8B8G8R_z_triangle( GLcontext *ctx,
516 SWvertex *v0,
517 SWvertex *v1,
518 SWvertex *v2 )
519 {
520 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
521 #define INTERP_Z 1
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)
526 #define SETUP_CODE \
527 unsigned long p = PACK_8B8G8R( v0->color[0], \
528 v0->color[1], v0->color[2] );
529 #define INNER_LOOP( LEFT, RIGHT, Y ) \
530 { \
531 GLint i, len = RIGHT-LEFT; \
532 (void) fffog; \
533 for (i=0;i<len;i++) { \
534 GLdepth z = FixedToDepth(ffz); \
535 if (z < zRow[i]) { \
536 pRow[i] = (PIXEL_TYPE) p; \
537 zRow[i] = z; \
538 } \
539 ffz += fdzdx; \
540 } \
541 }
542 #include "swrast/s_tritemp.h"
543 }
544
545
546 /*
547 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
548 */
549 static void flat_8R8G8B_z_triangle( GLcontext *ctx,
550 SWvertex *v0,
551 SWvertex *v1,
552 SWvertex *v2 )
553 {
554 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
555 #define INTERP_Z 1
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)
560 #define SETUP_CODE \
561 unsigned long p = PACK_8R8G8B( v0->color[0], \
562 v0->color[1], v0->color[2] );
563 #define INNER_LOOP( LEFT, RIGHT, Y ) \
564 { \
565 GLint i, len = RIGHT-LEFT; \
566 (void) fffog; \
567 for (i=0;i<len;i++) { \
568 GLdepth z = FixedToDepth(ffz); \
569 if (z < zRow[i]) { \
570 pRow[i] = (PIXEL_TYPE) p; \
571 zRow[i] = z; \
572 } \
573 ffz += fdzdx; \
574 } \
575 }
576 #include "swrast/s_tritemp.h"
577 }
578
579
580 /*
581 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
582 */
583 static void flat_8R8G8B24_z_triangle( GLcontext *ctx,
584 SWvertex *v0,
585 SWvertex *v1,
586 SWvertex *v2 )
587 {
588 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
589 const GLubyte *color = v0->color;
590 #define INTERP_Z 1
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 ) \
596 { \
597 GLint i, len = RIGHT-LEFT; \
598 (void) fffog; \
599 for (i=0;i<len;i++) { \
600 GLdepth z = FixedToDepth(ffz); \
601 if (z < zRow[i]) { \
602 PIXEL_TYPE *ptr = pRow+i; \
603 ptr->r = color[RCOMP]; \
604 ptr->g = color[GCOMP]; \
605 ptr->b = color[BCOMP]; \
606 zRow[i] = z; \
607 } \
608 ffz += fdzdx; \
609 } \
610 }
611 #include "swrast/s_tritemp.h"
612 }
613
614
615 /*
616 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
617 */
618 static void flat_TRUEDITHER_z_triangle( GLcontext *ctx,
619 SWvertex *v0,
620 SWvertex *v1,
621 SWvertex *v2 )
622 {
623 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
624 XMesaImage *img = xmesa->xm_buffer->backimage;
625 #define INTERP_Z 1
626 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
627 #define INNER_LOOP( LEFT, RIGHT, Y ) \
628 { \
629 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
630 (void) fffog; \
631 for (i=0;i<len;i++,xx++) { \
632 GLdepth z = FixedToDepth(ffz); \
633 if (z < zRow[i]) { \
634 unsigned long p; \
635 PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
636 v0->color[1], v0->color[2] ); \
637 XMesaPutPixel( img, xx, yy, p ); \
638 zRow[i] = z; \
639 } \
640 ffz += fdzdx; \
641 } \
642 }
643 #include "swrast/s_tritemp.h"
644 }
645
646
647 /*
648 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
649 */
650 static void flat_5R6G5B_z_triangle( GLcontext *ctx,
651 SWvertex *v0,
652 SWvertex *v1,
653 SWvertex *v2 )
654 {
655 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
656 #define INTERP_Z 1
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)
661 #define SETUP_CODE \
662 unsigned long p = PACK_5R6G5B( v0->color[0], \
663 v0->color[1], v0->color[2] );
664 #define INNER_LOOP( LEFT, RIGHT, Y ) \
665 { \
666 GLint i, len = RIGHT-LEFT; \
667 (void) fffog; \
668 for (i=0;i<len;i++) { \
669 DEPTH_TYPE z = FixedToDepth(ffz); \
670 if (z < zRow[i]) { \
671 pRow[i] = (PIXEL_TYPE) p; \
672 zRow[i] = z; \
673 } \
674 ffz += fdzdx; \
675 } \
676 }
677 #include "swrast/s_tritemp.h"
678 }
679
680
681 /*
682 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
683 */
684 static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
685 SWvertex *v0,
686 SWvertex *v1,
687 SWvertex *v2 )
688 {
689 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
690 const GLubyte *color = v0->color;
691 #define INTERP_Z 1
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 ) \
697 { \
698 GLint i, len = RIGHT-LEFT; \
699 (void) fffog; \
700 for (i=0;i<len;i++) { \
701 DEPTH_TYPE z = FixedToDepth(ffz); \
702 if (z < zRow[i]) { \
703 PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \
704 color[GCOMP], color[BCOMP]); \
705 zRow[i] = z; \
706 } \
707 ffz += fdzdx; \
708 } \
709 }
710 #include "swrast/s_tritemp.h"
711 }
712
713
714 /*
715 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
716 */
717 static void flat_DITHER8_z_triangle( GLcontext *ctx,
718 SWvertex *v0,
719 SWvertex *v1,
720 SWvertex *v2 )
721 {
722 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
723 #define INTERP_Z 1
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)
728 #define SETUP_CODE \
729 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
730
731 #define INNER_LOOP( LEFT, RIGHT, Y ) \
732 { \
733 GLint i, xx = LEFT, len = RIGHT-LEFT; \
734 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
735 (void) fffog; \
736 for (i=0;i<len;i++,xx++) { \
737 GLdepth z = FixedToDepth(ffz); \
738 if (z < zRow[i]) { \
739 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(xx); \
740 zRow[i] = z; \
741 } \
742 ffz += fdzdx; \
743 } \
744 }
745 #include "swrast/s_tritemp.h"
746 }
747
748
749 /*
750 * XImage, flat, depth-buffered, PF_DITHER triangle.
751 */
752 static void flat_DITHER_z_triangle( GLcontext *ctx,
753 SWvertex *v0,
754 SWvertex *v1,
755 SWvertex *v2 )
756 {
757 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
758 XMesaImage *img = xmesa->xm_buffer->backimage;
759 #define INTERP_Z 1
760 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
761 #define SETUP_CODE \
762 FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
763
764 #define INNER_LOOP( LEFT, RIGHT, Y ) \
765 { \
766 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
767 FLAT_DITHER_ROW_SETUP(yy); \
768 (void) fffog; \
769 for (i=0;i<len;i++,xx++) { \
770 GLdepth z = FixedToDepth(ffz); \
771 if (z < zRow[i]) { \
772 unsigned long p = FLAT_DITHER(xx); \
773 XMesaPutPixel( img, xx, yy, p ); \
774 zRow[i] = z; \
775 } \
776 ffz += fdzdx; \
777 } \
778 }
779 #include "swrast/s_tritemp.h"
780 }
781
782
783 /*
784 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
785 */
786 static void flat_HPCR_z_triangle( GLcontext *ctx,
787 SWvertex *v0,
788 SWvertex *v1,
789 SWvertex *v2 )
790 {
791 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
792 #define INTERP_Z 1
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)
797 #define SETUP_CODE \
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 ) \
802 { \
803 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
804 (void) fffog; \
805 for (i=0;i<len;i++,xx++) { \
806 GLdepth z = FixedToDepth(ffz); \
807 if (z < zRow[i]) { \
808 pRow[i] = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
809 zRow[i] = z; \
810 } \
811 ffz += fdzdx; \
812 } \
813 }
814 #include "swrast/s_tritemp.h"
815 }
816
817
818 /*
819 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
820 */
821 static void flat_LOOKUP8_z_triangle( GLcontext *ctx,
822 SWvertex *v0,
823 SWvertex *v1,
824 SWvertex *v2 )
825 {
826 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
827 #define INTERP_Z 1
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)
832 #define SETUP_CODE \
833 LOOKUP_SETUP; \
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 ) \
839 { \
840 GLint i, len = RIGHT-LEFT; \
841 (void) fffog; \
842 for (i=0;i<len;i++) { \
843 GLdepth z = FixedToDepth(ffz); \
844 if (z < zRow[i]) { \
845 pRow[i] = p; \
846 zRow[i] = z; \
847 } \
848 ffz += fdzdx; \
849 } \
850 }
851 #include "swrast/s_tritemp.h"
852 }
853
854
855
856 /*
857 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
858 */
859 static void smooth_TRUECOLOR_triangle( GLcontext *ctx,
860 SWvertex *v0,
861 SWvertex *v1,
862 SWvertex *v2 )
863 {
864 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
865 XMesaImage *img = xmesa->xm_buffer->backimage;
866 #define INTERP_RGB 1
867 #define INNER_LOOP( LEFT, RIGHT, Y ) \
868 { \
869 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
870 for (xx=LEFT;xx<RIGHT;xx++) { \
871 unsigned long p; \
872 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
873 XMesaPutPixel( img, xx, yy, p ); \
874 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
875 } \
876 }
877 #include "swrast/s_tritemp.h"
878 }
879
880
881 /*
882 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
883 */
884 static void smooth_8A8B8G8R_triangle( GLcontext *ctx,
885 SWvertex *v0,
886 SWvertex *v1,
887 SWvertex *v2 )
888 {
889 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
890 #define INTERP_RGB 1
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 ) \
895 { \
896 GLint xx; \
897 PIXEL_TYPE *pixel = pRow; \
898 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
899 *pixel = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
900 FixedToInt(ffb) ); \
901 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
902 } \
903 }
904 #include "swrast/s_tritemp.h"
905 }
906
907
908 /*
909 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
910 */
911 static void smooth_8R8G8B_triangle( GLcontext *ctx,
912 SWvertex *v0,
913 SWvertex *v1,
914 SWvertex *v2 )
915 {
916 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
917 #define INTERP_RGB 1
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 ) \
922 { \
923 GLint xx; \
924 PIXEL_TYPE *pixel = pRow; \
925 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
926 *pixel = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
927 FixedToInt(ffb) ); \
928 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
929 } \
930 }
931 #include "swrast/s_tritemp.h"
932 }
933
934
935 /*
936 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
937 */
938 static void smooth_8R8G8B24_triangle( GLcontext *ctx,
939 SWvertex *v0,
940 SWvertex *v1,
941 SWvertex *v2 )
942 {
943 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
944 #define INTERP_RGB 1
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 ) \
949 { \
950 GLint xx; \
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; \
957 pixel++; \
958 } \
959 }
960 #include "swrast/s_tritemp.h"
961 }
962
963
964 /*
965 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
966 */
967 static void smooth_TRUEDITHER_triangle( GLcontext *ctx,
968 SWvertex *v0,
969 SWvertex *v1,
970 SWvertex *v2 )
971 {
972 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
973 XMesaImage *img = xmesa->xm_buffer->backimage;
974 #define INTERP_RGB 1
975 #define INNER_LOOP( LEFT, RIGHT, Y ) \
976 { \
977 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
978 for (xx=LEFT;xx<RIGHT;xx++) { \
979 unsigned long p; \
980 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), FixedToInt(ffg), \
981 FixedToInt(ffb) ); \
982 XMesaPutPixel( img, xx, yy, p ); \
983 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
984 } \
985 }
986 #include "swrast/s_tritemp.h"
987 }
988
989
990 /*
991 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
992 */
993 static void smooth_5R6G5B_triangle( GLcontext *ctx,
994 SWvertex *v0,
995 SWvertex *v1,
996 SWvertex *v2 )
997 {
998 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
999 #define INTERP_RGB 1
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 ) \
1004 { \
1005 GLint xx; \
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; \
1011 } \
1012 }
1013 #include "swrast/s_tritemp.h"
1014 }
1015
1016
1017 /*
1018 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1019 */
1020 static void smooth_DITHER_5R6G5B_triangle( GLcontext *ctx,
1021 SWvertex *v0,
1022 SWvertex *v1,
1023 SWvertex *v2 )
1024 {
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 ) \
1031 { \
1032 GLint xx; \
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; \
1038 } \
1039 }
1040 #include "swrast/s_tritemp.h"
1041 }
1042
1043
1044 /*
1045 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
1046 */
1047 static void smooth_DITHER8_triangle( GLcontext *ctx,
1048 SWvertex *v0,
1049 SWvertex *v1,
1050 SWvertex *v2 )
1051 {
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 ) \
1058 { \
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; \
1066 } \
1067 }
1068 #include "swrast/s_tritemp.h"
1069 }
1070
1071
1072 /*
1073 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
1074 */
1075 static void smooth_DITHER_triangle( GLcontext *ctx,
1076 SWvertex *v0,
1077 SWvertex *v1,
1078 SWvertex *v2 )
1079 {
1080 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1081 XMesaImage *img = xmesa->xm_buffer->backimage;
1082
1083 #define INTERP_RGB 1
1084 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1085 { \
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; \
1093 } \
1094 }
1095 #include "swrast/s_tritemp.h"
1096 }
1097
1098
1099 /*
1100 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1101 */
1102 static void smooth_LOOKUP8_triangle( GLcontext *ctx,
1103 SWvertex *v0,
1104 SWvertex *v1,
1105 SWvertex *v2 )
1106 {
1107 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1108
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 ) \
1114 { \
1115 GLint xx; \
1116 PIXEL_TYPE *pixel = pRow; \
1117 LOOKUP_SETUP; \
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; \
1122 } \
1123 }
1124 #include "swrast/s_tritemp.h"
1125 }
1126
1127
1128
1129 /*
1130 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
1131 */
1132 static void smooth_HPCR_triangle( GLcontext *ctx,
1133 SWvertex *v0,
1134 SWvertex *v1,
1135 SWvertex *v2 )
1136 {
1137 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1138
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 ) \
1144 { \
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; \
1151 } \
1152 }
1153 #include "swrast/s_tritemp.h"
1154 }
1155
1156
1157 /*
1158 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
1159 */
1160 static void flat_TRUECOLOR_triangle( GLcontext *ctx,
1161 SWvertex *v0,
1162 SWvertex *v1,
1163 SWvertex *v2 )
1164 {
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]);
1170
1171 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1172 { \
1173 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1174 for (xx=LEFT;xx<RIGHT;xx++) { \
1175 XMesaPutPixel( img, xx, yy, pixel ); \
1176 } \
1177 }
1178 #include "swrast/s_tritemp.h"
1179 }
1180
1181
1182 /*
1183 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
1184 */
1185 static void flat_8A8B8G8R_triangle( GLcontext *ctx,
1186 SWvertex *v0,
1187 SWvertex *v1,
1188 SWvertex *v2 )
1189 {
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 ) \
1198 { \
1199 GLint xx; \
1200 PIXEL_TYPE *pixel = pRow; \
1201 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1202 *pixel = (PIXEL_TYPE) p; \
1203 } \
1204 }
1205 #include "swrast/s_tritemp.h"
1206 }
1207
1208
1209 /*
1210 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1211 */
1212 static void flat_8R8G8B_triangle( GLcontext *ctx,
1213 SWvertex *v0,
1214 SWvertex *v1,
1215 SWvertex *v2 )
1216 {
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 ) \
1225 { \
1226 GLint xx; \
1227 PIXEL_TYPE *pixel = pRow; \
1228 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1229 *pixel = (PIXEL_TYPE) p; \
1230 } \
1231 }
1232 #include "swrast/s_tritemp.h"
1233 }
1234
1235
1236 /*
1237 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1238 */
1239 static void flat_8R8G8B24_triangle( GLcontext *ctx,
1240 SWvertex *v0,
1241 SWvertex *v1,
1242 SWvertex *v2 )
1243 {
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 ) \
1250 { \
1251 GLint xx; \
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]; \
1257 pixel++; \
1258 } \
1259 }
1260 #include "swrast/s_tritemp.h"
1261 }
1262
1263 /*
1264 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1265 */
1266 static void flat_TRUEDITHER_triangle( GLcontext *ctx,
1267 SWvertex *v0,
1268 SWvertex *v1,
1269 SWvertex *v2 )
1270 {
1271 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1272 XMesaImage *img = xmesa->xm_buffer->backimage;
1273 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1274 { \
1275 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1276 for (xx=LEFT;xx<RIGHT;xx++) { \
1277 unsigned long p; \
1278 PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
1279 v0->color[1], v0->color[2] ); \
1280 XMesaPutPixel( img, xx, yy, p ); \
1281 } \
1282 }
1283 #include "swrast/s_tritemp.h"
1284 }
1285
1286
1287
1288 /*
1289 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1290 */
1291 static void flat_5R6G5B_triangle( GLcontext *ctx,
1292 SWvertex *v0,
1293 SWvertex *v1,
1294 SWvertex *v2 )
1295 {
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 ) \
1304 { \
1305 GLint xx; \
1306 PIXEL_TYPE *pixel = pRow; \
1307 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1308 *pixel = (PIXEL_TYPE) p; \
1309 } \
1310 }
1311 #include "swrast/s_tritemp.h"
1312 }
1313
1314
1315 /*
1316 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1317 */
1318 static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx,
1319 SWvertex *v0,
1320 SWvertex *v1,
1321 SWvertex *v2 )
1322 {
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 ) \
1329 { \
1330 GLint xx; \
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]); \
1335 } \
1336 }
1337 #include "swrast/s_tritemp.h"
1338 }
1339
1340
1341 /*
1342 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1343 */
1344 static void flat_DITHER8_triangle( GLcontext *ctx,
1345 SWvertex *v0,
1346 SWvertex *v1,
1347 SWvertex *v2 )
1348 {
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] );
1355
1356 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1357 { \
1358 GLint xx; \
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); \
1363 } \
1364 }
1365 #include "swrast/s_tritemp.h"
1366 }
1367
1368
1369 /*
1370 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1371 */
1372 static void flat_DITHER_triangle( GLcontext *ctx,
1373 SWvertex *v0,
1374 SWvertex *v1,
1375 SWvertex *v2 )
1376 {
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] );
1381
1382 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1383 { \
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 ); \
1389 } \
1390 }
1391 #include "swrast/s_tritemp.h"
1392 }
1393
1394
1395 /*
1396 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1397 */
1398 static void flat_HPCR_triangle( GLcontext *ctx,
1399 SWvertex *v0,
1400 SWvertex *v1,
1401 SWvertex *v2 )
1402 {
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 ) \
1412 { \
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 ); \
1417 } \
1418 }
1419 #include "swrast/s_tritemp.h"
1420 }
1421
1422
1423 /*
1424 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1425 */
1426 static void flat_LOOKUP8_triangle( GLcontext *ctx,
1427 SWvertex *v0,
1428 SWvertex *v1,
1429 SWvertex *v2 )
1430 {
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 \
1436 LOOKUP_SETUP; \
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 ) \
1442 { \
1443 GLint xx; \
1444 PIXEL_TYPE *pixel = pRow; \
1445 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1446 *pixel = p; \
1447 } \
1448 }
1449 #include "swrast/s_tritemp.h"
1450 }
1451
1452
1453 #ifdef DEBUG
1454 void
1455 _xmesa_print_triangle_func( swrast_tri_func triFunc )
1456 {
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");
1538 else
1539 printf("???\n");
1540 }
1541 #endif
1542
1543
1544 static swrast_tri_func get_triangle_func( GLcontext *ctx )
1545 {
1546 SWcontext *swrast = SWRAST_CONTEXT(ctx);
1547 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1548 int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
1549
1550 (void) kernel1;
1551
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;
1555
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) {
1564 case PF_TRUECOLOR:
1565 return smooth_TRUECOLOR_z_triangle;
1566 case PF_8A8B8G8R:
1567 return smooth_8A8B8G8R_z_triangle;
1568 case PF_8R8G8B:
1569 return smooth_8R8G8B_z_triangle;
1570 case PF_8R8G8B24:
1571 return smooth_8R8G8B24_z_triangle;
1572 case PF_TRUEDITHER:
1573 return smooth_TRUEDITHER_z_triangle;
1574 case PF_5R6G5B:
1575 return smooth_5R6G5B_z_triangle;
1576 case PF_DITHER_5R6G5B:
1577 return smooth_DITHER_5R6G5B_z_triangle;
1578 case PF_HPCR:
1579 return smooth_HPCR_z_triangle;
1580 case PF_DITHER:
1581 return (depth==8) ? smooth_DITHER8_z_triangle
1582 : smooth_DITHER_z_triangle;
1583 case PF_LOOKUP:
1584 return (depth==8) ? smooth_LOOKUP8_z_triangle : (swrast_tri_func)NULL;
1585 default:
1586 return (swrast_tri_func)NULL;
1587 }
1588 }
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) {
1596 case PF_TRUECOLOR:
1597 return flat_TRUECOLOR_z_triangle;
1598 case PF_8A8B8G8R:
1599 return flat_8A8B8G8R_z_triangle;
1600 case PF_8R8G8B:
1601 return flat_8R8G8B_z_triangle;
1602 case PF_8R8G8B24:
1603 return flat_8R8G8B24_z_triangle;
1604 case PF_TRUEDITHER:
1605 return flat_TRUEDITHER_z_triangle;
1606 case PF_5R6G5B:
1607 return flat_5R6G5B_z_triangle;
1608 case PF_DITHER_5R6G5B:
1609 return flat_DITHER_5R6G5B_z_triangle;
1610 case PF_HPCR:
1611 return flat_HPCR_z_triangle;
1612 case PF_DITHER:
1613 return (depth==8) ? flat_DITHER8_z_triangle
1614 : flat_DITHER_z_triangle;
1615 case PF_LOOKUP:
1616 return (depth==8) ? flat_LOOKUP8_z_triangle : (swrast_tri_func)NULL;
1617 default:
1618 return (swrast_tri_func)NULL;
1619 }
1620 }
1621 if ( swrast->_RasterMask==0 /* no depth test */
1622 && ctx->Light.ShadeModel==GL_SMOOTH
1623 && ctx->Polygon.StippleFlag==GL_FALSE) {
1624 switch (xmesa->pixelformat) {
1625 case PF_TRUECOLOR:
1626 return smooth_TRUECOLOR_triangle;
1627 case PF_8A8B8G8R:
1628 return smooth_8A8B8G8R_triangle;
1629 case PF_8R8G8B:
1630 return smooth_8R8G8B_triangle;
1631 case PF_8R8G8B24:
1632 return smooth_8R8G8B24_triangle;
1633 case PF_TRUEDITHER:
1634 return smooth_TRUEDITHER_triangle;
1635 case PF_5R6G5B:
1636 return smooth_5R6G5B_triangle;
1637 case PF_DITHER_5R6G5B:
1638 return smooth_DITHER_5R6G5B_triangle;
1639 case PF_HPCR:
1640 return smooth_HPCR_triangle;
1641 case PF_DITHER:
1642 return (depth==8) ? smooth_DITHER8_triangle
1643 : smooth_DITHER_triangle;
1644 case PF_LOOKUP:
1645 return (depth==8) ? smooth_LOOKUP8_triangle : (swrast_tri_func)NULL;
1646 default:
1647 return (swrast_tri_func)NULL;
1648 }
1649 }
1650
1651 if ( swrast->_RasterMask==0 /* no depth test */
1652 && ctx->Light.ShadeModel==GL_FLAT
1653 && ctx->Polygon.StippleFlag==GL_FALSE) {
1654 switch (xmesa->pixelformat) {
1655 case PF_TRUECOLOR:
1656 return flat_TRUECOLOR_triangle;
1657 case PF_TRUEDITHER:
1658 return flat_TRUEDITHER_triangle;
1659 case PF_8A8B8G8R:
1660 return flat_8A8B8G8R_triangle;
1661 case PF_8R8G8B:
1662 return flat_8R8G8B_triangle;
1663 case PF_8R8G8B24:
1664 return flat_8R8G8B24_triangle;
1665 case PF_5R6G5B:
1666 return flat_5R6G5B_triangle;
1667 case PF_DITHER_5R6G5B:
1668 return flat_DITHER_5R6G5B_triangle;
1669 case PF_HPCR:
1670 return flat_HPCR_triangle;
1671 case PF_DITHER:
1672 return (depth==8) ? flat_DITHER8_triangle
1673 : flat_DITHER_triangle;
1674 case PF_LOOKUP:
1675 return (depth==8) ? flat_LOOKUP8_triangle : (swrast_tri_func)NULL;
1676 default:
1677 return (swrast_tri_func)NULL;
1678 }
1679 }
1680
1681 return (swrast_tri_func)NULL;
1682 }
1683 else {
1684 /* draw to pixmap */
1685 return (swrast_tri_func) NULL;
1686 }
1687 }
1688
1689
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.
1693 */
1694 void xmesa_choose_triangle( GLcontext *ctx )
1695 {
1696 SWcontext *swrast = SWRAST_CONTEXT(ctx);
1697
1698 if (!(swrast->Triangle = get_triangle_func( ctx )))
1699 _swrast_choose_triangle( ctx );
1700 }
1701