9f152265f753c60163e585e6d305b6d1be4e4734
[mesa.git] / src / mesa / drivers / x11 / xm_tri.c
1 /* $Id: xm_tri.c,v 1.18 2001/02/06 04:06:36 keithw 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 "mmath.h"
39 #include "mtypes.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 /*
57 * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
58 */
59 static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx,
60 const SWvertex *v0,
61 const SWvertex *v1,
62 const SWvertex *v2 )
63 {
64 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
65 XMesaImage *img = xmesa->xm_buffer->backimage;
66 #define INTERP_Z 1
67 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
68 #define INTERP_RGB 1
69 #define INNER_LOOP( LEFT, RIGHT, Y ) \
70 { \
71 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer, Y); \
72 GLint len = RIGHT-LEFT; \
73 (void) fffog; \
74 for (i=0;i<len;i++,xx++) { \
75 GLdepth z = FixedToDepth(ffz); \
76 if (z < zRow[i]) { \
77 unsigned long p; \
78 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
79 XMesaPutPixel( img, xx, yy, p ); \
80 zRow[i] = z; \
81 } \
82 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
83 ffz += fdzdx; \
84 } \
85 }
86 #include "swrast/s_tritemp.h"
87 }
88
89
90
91 /*
92 * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
93 */
94 static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
95 const SWvertex *v0,
96 const SWvertex *v1,
97 const SWvertex *v2 )
98 {
99 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
100 #define INTERP_Z 1
101 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
102 #define INTERP_RGB 1
103 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
104 #define PIXEL_TYPE GLuint
105 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
106 #define INNER_LOOP( LEFT, RIGHT, Y ) \
107 { \
108 GLint i, len = RIGHT-LEFT; \
109 (void) fffog; \
110 for (i=0;i<len;i++) { \
111 GLdepth z = FixedToDepth(ffz); \
112 if (z < zRow[i]) { \
113 pRow[i] = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
114 FixedToInt(ffb) ); \
115 zRow[i] = z; \
116 } \
117 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
118 ffz += fdzdx; \
119 } \
120 }
121 #include "swrast/s_tritemp.h"
122 }
123
124
125 /*
126 * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
127 */
128 static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
129 const SWvertex *v0,
130 const SWvertex *v1,
131 const SWvertex *v2 )
132 {
133 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
134 #define INTERP_Z 1
135 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
136 #define INTERP_RGB 1
137 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
138 #define PIXEL_TYPE GLuint
139 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
140 #define INNER_LOOP( LEFT, RIGHT, Y ) \
141 { \
142 GLint i, len = RIGHT-LEFT; \
143 (void) fffog; \
144 for (i=0;i<len;i++) { \
145 GLdepth z = FixedToDepth(ffz); \
146 if (z < zRow[i]) { \
147 pRow[i] = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
148 FixedToInt(ffb) ); \
149 zRow[i] = z; \
150 } \
151 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
152 ffz += fdzdx; \
153 } \
154 }
155 #include "swrast/s_tritemp.h"
156 }
157
158
159 /*
160 * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
161 */
162 static void smooth_8R8G8B24_z_triangle( GLcontext *ctx,
163 const SWvertex *v0,
164 const SWvertex *v1,
165 const SWvertex *v2 )
166 {
167 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
168 #define INTERP_Z 1
169 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
170 #define INTERP_RGB 1
171 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
172 #define PIXEL_TYPE bgr_t
173 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
174 #define INNER_LOOP( LEFT, RIGHT, Y ) \
175 { \
176 GLint i, len = RIGHT-LEFT; \
177 (void) fffog; \
178 for (i=0;i<len;i++) { \
179 GLdepth z = FixedToDepth(ffz); \
180 if (z < zRow[i]) { \
181 PIXEL_TYPE *ptr = pRow + i; \
182 ptr->r = FixedToInt(ffr); \
183 ptr->g = FixedToInt(ffg); \
184 ptr->b = FixedToInt(ffb); \
185 zRow[i] = z; \
186 } \
187 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
188 ffz += fdzdx; \
189 } \
190 }
191 #include "swrast/s_tritemp.h"
192 }
193
194
195 /*
196 * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
197 */
198 static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx,
199 const SWvertex *v0,
200 const SWvertex *v1,
201 const SWvertex *v2 )
202 {
203 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
204 XMesaImage *img = xmesa->xm_buffer->backimage;
205 #define INTERP_Z 1
206 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
207 #define INTERP_RGB 1
208 #define INNER_LOOP( LEFT, RIGHT, Y ) \
209 { \
210 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
211 (void) fffog; \
212 for (i=0;i<len;i++,xx++) { \
213 GLdepth z = FixedToDepth(ffz); \
214 if (z < zRow[i]) { \
215 unsigned long p; \
216 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), \
217 FixedToInt(ffg), FixedToInt(ffb) ); \
218 XMesaPutPixel( img, xx, yy, p ); \
219 zRow[i] = z; \
220 } \
221 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
222 ffz += fdzdx; \
223 } \
224 }
225 #include "swrast/s_tritemp.h"
226 }
227
228
229 /*
230 * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
231 */
232 static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
233 const SWvertex *v0,
234 const SWvertex *v1,
235 const SWvertex *v2 )
236 {
237 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
238 #define INTERP_Z 1
239 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
240 #define INTERP_RGB 1
241 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
242 #define PIXEL_TYPE GLushort
243 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
244 #define INNER_LOOP( LEFT, RIGHT, Y ) \
245 { \
246 GLint i, len = RIGHT-LEFT; \
247 (void) fffog; \
248 for (i=0;i<len;i++) { \
249 DEPTH_TYPE z = FixedToDepth(ffz); \
250 if (z < zRow[i]) { \
251 pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
252 FixedToInt(ffb) ); \
253 zRow[i] = z; \
254 } \
255 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
256 ffz += fdzdx; \
257 } \
258 }
259 #include "swrast/s_tritemp.h"
260 }
261
262
263 /*
264 * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
265 */
266 static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
267 const SWvertex *v0,
268 const SWvertex *v1,
269 const SWvertex *v2 )
270 {
271 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
272 #define INTERP_Z 1
273 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
274 #define INTERP_RGB 1
275 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
276 #define PIXEL_TYPE GLushort
277 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
278 #define INNER_LOOP( LEFT, RIGHT, Y ) \
279 { \
280 GLint i, len = RIGHT-LEFT; \
281 GLint yy = FLIP(xmesa->xm_buffer, Y); \
282 (void) fffog; \
283 for (i=0;i<len;i++) { \
284 GLdepth z = FixedToDepth(ffz); \
285 if (z < zRow[i]) { \
286 PACK_TRUEDITHER(pRow[i], LEFT+i, yy, FixedToInt(ffr), \
287 FixedToInt(ffg), FixedToInt(ffb) ); \
288 zRow[i] = z; \
289 } \
290 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
291 ffz += fdzdx; \
292 } \
293 }
294 #include "swrast/s_tritemp.h"
295 }
296
297
298 /*
299 * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
300 */
301 static void smooth_DITHER8_z_triangle( GLcontext *ctx,
302 const SWvertex *v0,
303 const SWvertex *v1,
304 const SWvertex *v2 )
305 {
306 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
307 #define INTERP_Z 1
308 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
309 #define INTERP_RGB 1
310 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
311 #define PIXEL_TYPE GLubyte
312 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
313 #define INNER_LOOP( LEFT, RIGHT, Y ) \
314 { \
315 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
316 XDITHER_SETUP(yy); \
317 (void) fffog; \
318 for (i=0;i<len;i++,xx++) { \
319 GLdepth z = FixedToDepth(ffz); \
320 if (z < zRow[i]) { \
321 pRow[i] = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
322 FixedToInt(ffg), FixedToInt(ffb) ); \
323 zRow[i] = z; \
324 } \
325 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
326 ffz += fdzdx; \
327 } \
328 }
329 #include "swrast/s_tritemp.h"
330 }
331
332
333 /*
334 * XImage, smooth, depth-buffered, PF_DITHER triangle.
335 */
336 static void smooth_DITHER_z_triangle( GLcontext *ctx,
337 const SWvertex *v0,
338 const SWvertex *v1,
339 const SWvertex *v2 )
340 {
341 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
342 XMesaImage *img = xmesa->xm_buffer->backimage;
343 #define INTERP_Z 1
344 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
345 #define INTERP_RGB 1
346 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
347 #define PIXEL_TYPE GLubyte
348 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
349 #define INNER_LOOP( LEFT, RIGHT, Y ) \
350 { \
351 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
352 XDITHER_SETUP(yy); \
353 (void) fffog; \
354 for (i=0;i<len;i++,xx++) { \
355 GLdepth z = FixedToDepth(ffz); \
356 if (z < zRow[i]) { \
357 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
358 FixedToInt(ffg), FixedToInt(ffb) ); \
359 XMesaPutPixel( img, xx, yy, p ); \
360 zRow[i] = z; \
361 } \
362 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
363 ffz += fdzdx; \
364 } \
365 }
366 #include "swrast/s_tritemp.h"
367 }
368
369
370 /*
371 * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
372 */
373 static void smooth_LOOKUP8_z_triangle( GLcontext *ctx,
374 const SWvertex *v0,
375 const SWvertex *v1,
376 const SWvertex *v2 )
377 {
378 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
379 #define INTERP_Z 1
380 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
381 #define INTERP_RGB 1
382 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
383 #define PIXEL_TYPE GLubyte
384 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
385 #define INNER_LOOP( LEFT, RIGHT, Y ) \
386 { \
387 GLint i, len = RIGHT-LEFT; \
388 LOOKUP_SETUP; \
389 (void) fffog; \
390 for (i=0;i<len;i++) { \
391 GLdepth z = FixedToDepth(ffz); \
392 if (z < zRow[i]) { \
393 pRow[i] = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
394 FixedToInt(ffb) ); \
395 zRow[i] = z; \
396 } \
397 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
398 ffz += fdzdx; \
399 } \
400 }
401 #include "swrast/s_tritemp.h"
402 }
403
404
405
406 /*
407 * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
408 */
409 static void smooth_HPCR_z_triangle( GLcontext *ctx,
410 const SWvertex *v0,
411 const SWvertex *v1,
412 const SWvertex *v2 )
413 {
414 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
415 #define INTERP_Z 1
416 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
417 #define INTERP_RGB 1
418 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
419 #define PIXEL_TYPE GLubyte
420 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
421 #define INNER_LOOP( LEFT, RIGHT, Y ) \
422 { \
423 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
424 (void) fffog; \
425 for (i=0;i<len;i++,xx++) { \
426 GLdepth z = FixedToDepth(ffz); \
427 if (z < zRow[i]) { \
428 pRow[i] = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
429 FixedToInt(ffg), FixedToInt(ffb) ); \
430 zRow[i] = z; \
431 } \
432 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
433 ffz += fdzdx; \
434 } \
435 }
436 #include "swrast/s_tritemp.h"
437 }
438
439
440 /*
441 * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
442 */
443 static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
444 const SWvertex *v0,
445 const SWvertex *v1,
446 const SWvertex *v2 )
447 {
448 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
449 XMesaImage *img = xmesa->xm_buffer->backimage;
450 #define INTERP_Z 1
451 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
452 #define SETUP_CODE \
453 unsigned long pixel; \
454 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
455
456 #define INNER_LOOP( LEFT, RIGHT, Y ) \
457 { \
458 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
459 (void) fffog; \
460 for (i=0;i<len;i++,xx++) { \
461 GLdepth z = FixedToDepth(ffz); \
462 if (z < zRow[i]) { \
463 XMesaPutPixel( img, xx, yy, pixel ); \
464 zRow[i] = z; \
465 } \
466 ffz += fdzdx; \
467 } \
468 }
469 #include "swrast/s_tritemp.h"
470 }
471
472
473 /*
474 * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
475 */
476 static void flat_8A8B8G8R_z_triangle( GLcontext *ctx,
477 const SWvertex *v0,
478 const SWvertex *v1,
479 const SWvertex *v2 )
480 {
481 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
482 #define INTERP_Z 1
483 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
484 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
485 #define PIXEL_TYPE GLuint
486 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
487 #define SETUP_CODE \
488 unsigned long p = PACK_8B8G8R( v2->color[0], \
489 v2->color[1], v2->color[2] );
490 #define INNER_LOOP( LEFT, RIGHT, Y ) \
491 { \
492 GLint i, len = RIGHT-LEFT; \
493 (void) fffog; \
494 for (i=0;i<len;i++) { \
495 GLdepth z = FixedToDepth(ffz); \
496 if (z < zRow[i]) { \
497 pRow[i] = (PIXEL_TYPE) p; \
498 zRow[i] = z; \
499 } \
500 ffz += fdzdx; \
501 } \
502 }
503 #include "swrast/s_tritemp.h"
504 }
505
506
507 /*
508 * XImage, flat, depth-buffered, PF_8R8G8B triangle.
509 */
510 static void flat_8R8G8B_z_triangle( GLcontext *ctx,
511 const SWvertex *v0,
512 const SWvertex *v1,
513 const SWvertex *v2 )
514 {
515 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
516 #define INTERP_Z 1
517 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
518 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
519 #define PIXEL_TYPE GLuint
520 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
521 #define SETUP_CODE \
522 unsigned long p = PACK_8R8G8B( v2->color[0], \
523 v2->color[1], v2->color[2] );
524 #define INNER_LOOP( LEFT, RIGHT, Y ) \
525 { \
526 GLint i, len = RIGHT-LEFT; \
527 (void) fffog; \
528 for (i=0;i<len;i++) { \
529 GLdepth z = FixedToDepth(ffz); \
530 if (z < zRow[i]) { \
531 pRow[i] = (PIXEL_TYPE) p; \
532 zRow[i] = z; \
533 } \
534 ffz += fdzdx; \
535 } \
536 }
537 #include "swrast/s_tritemp.h"
538 }
539
540
541 /*
542 * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
543 */
544 static void flat_8R8G8B24_z_triangle( GLcontext *ctx,
545 const SWvertex *v0,
546 const SWvertex *v1,
547 const SWvertex *v2 )
548 {
549 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
550 const GLubyte *color = v2->color;
551 #define INTERP_Z 1
552 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
553 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
554 #define PIXEL_TYPE bgr_t
555 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
556 #define INNER_LOOP( LEFT, RIGHT, Y ) \
557 { \
558 GLint i, len = RIGHT-LEFT; \
559 (void) fffog; \
560 for (i=0;i<len;i++) { \
561 GLdepth z = FixedToDepth(ffz); \
562 if (z < zRow[i]) { \
563 PIXEL_TYPE *ptr = pRow+i; \
564 ptr->r = color[RCOMP]; \
565 ptr->g = color[GCOMP]; \
566 ptr->b = color[BCOMP]; \
567 zRow[i] = z; \
568 } \
569 ffz += fdzdx; \
570 } \
571 }
572 #include "swrast/s_tritemp.h"
573 }
574
575
576 /*
577 * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
578 */
579 static void flat_TRUEDITHER_z_triangle( GLcontext *ctx,
580 const SWvertex *v0,
581 const SWvertex *v1,
582 const SWvertex *v2 )
583 {
584 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
585 XMesaImage *img = xmesa->xm_buffer->backimage;
586 #define INTERP_Z 1
587 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
588 #define INNER_LOOP( LEFT, RIGHT, Y ) \
589 { \
590 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
591 (void) fffog; \
592 for (i=0;i<len;i++,xx++) { \
593 GLdepth z = FixedToDepth(ffz); \
594 if (z < zRow[i]) { \
595 unsigned long p; \
596 PACK_TRUEDITHER( p, xx, yy, v2->color[0], \
597 v2->color[1], v2->color[2] ); \
598 XMesaPutPixel( img, xx, yy, p ); \
599 zRow[i] = z; \
600 } \
601 ffz += fdzdx; \
602 } \
603 }
604 #include "swrast/s_tritemp.h"
605 }
606
607
608 /*
609 * XImage, flat, depth-buffered, PF_5R6G5B triangle.
610 */
611 static void flat_5R6G5B_z_triangle( GLcontext *ctx,
612 const SWvertex *v0,
613 const SWvertex *v1,
614 const SWvertex *v2 )
615 {
616 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
617 #define INTERP_Z 1
618 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
619 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
620 #define PIXEL_TYPE GLushort
621 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
622 #define SETUP_CODE \
623 unsigned long p = PACK_5R6G5B( v2->color[0], \
624 v2->color[1], v2->color[2] );
625 #define INNER_LOOP( LEFT, RIGHT, Y ) \
626 { \
627 GLint i, len = RIGHT-LEFT; \
628 (void) fffog; \
629 for (i=0;i<len;i++) { \
630 DEPTH_TYPE z = FixedToDepth(ffz); \
631 if (z < zRow[i]) { \
632 pRow[i] = (PIXEL_TYPE) p; \
633 zRow[i] = z; \
634 } \
635 ffz += fdzdx; \
636 } \
637 }
638 #include "swrast/s_tritemp.h"
639 }
640
641
642 /*
643 * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
644 */
645 static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
646 const SWvertex *v0,
647 const SWvertex *v1,
648 const SWvertex *v2 )
649 {
650 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
651 const GLubyte *color = v2->color;
652 #define INTERP_Z 1
653 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
654 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
655 #define PIXEL_TYPE GLushort
656 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
657 #define INNER_LOOP( LEFT, RIGHT, Y ) \
658 { \
659 GLint i, len = RIGHT-LEFT; \
660 GLint yy = FLIP(xmesa->xm_buffer, Y); \
661 (void) fffog; \
662 for (i=0;i<len;i++) { \
663 DEPTH_TYPE z = FixedToDepth(ffz); \
664 if (z < zRow[i]) { \
665 PACK_TRUEDITHER(pRow[i], LEFT+i, yy, color[RCOMP], \
666 color[GCOMP], color[BCOMP]); \
667 zRow[i] = z; \
668 } \
669 ffz += fdzdx; \
670 } \
671 }
672 #include "swrast/s_tritemp.h"
673 }
674
675
676 /*
677 * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
678 */
679 static void flat_DITHER8_z_triangle( GLcontext *ctx,
680 const SWvertex *v0,
681 const SWvertex *v1,
682 const SWvertex *v2 )
683 {
684 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
685 #define INTERP_Z 1
686 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
687 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
688 #define PIXEL_TYPE GLubyte
689 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
690 #define SETUP_CODE \
691 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
692
693 #define INNER_LOOP( LEFT, RIGHT, Y ) \
694 { \
695 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
696 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, yy)); \
697 (void) fffog; \
698 for (i=0;i<len;i++,xx++) { \
699 GLdepth z = FixedToDepth(ffz); \
700 if (z < zRow[i]) { \
701 pRow[i] = (PIXEL_TYPE) FLAT_DITHER(xx); \
702 zRow[i] = z; \
703 } \
704 ffz += fdzdx; \
705 } \
706 }
707 #include "swrast/s_tritemp.h"
708 }
709
710
711 /*
712 * XImage, flat, depth-buffered, PF_DITHER triangle.
713 */
714 static void flat_DITHER_z_triangle( GLcontext *ctx,
715 const SWvertex *v0,
716 const SWvertex *v1,
717 const SWvertex *v2 )
718 {
719 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
720 XMesaImage *img = xmesa->xm_buffer->backimage;
721 #define INTERP_Z 1
722 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
723 #define SETUP_CODE \
724 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
725
726 #define INNER_LOOP( LEFT, RIGHT, Y ) \
727 { \
728 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
729 FLAT_DITHER_ROW_SETUP(yy); \
730 (void) fffog; \
731 for (i=0;i<len;i++,xx++) { \
732 GLdepth z = FixedToDepth(ffz); \
733 if (z < zRow[i]) { \
734 unsigned long p = FLAT_DITHER(xx); \
735 XMesaPutPixel( img, xx, yy, p ); \
736 zRow[i] = z; \
737 } \
738 ffz += fdzdx; \
739 } \
740 }
741 #include "swrast/s_tritemp.h"
742 }
743
744
745 /*
746 * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
747 */
748 static void flat_HPCR_z_triangle( GLcontext *ctx,
749 const SWvertex *v0,
750 const SWvertex *v1,
751 const SWvertex *v2 )
752 {
753 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
754 #define INTERP_Z 1
755 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
756 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
757 #define PIXEL_TYPE GLubyte
758 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
759 #define SETUP_CODE \
760 GLubyte r = v2->color[0]; \
761 GLubyte g = v2->color[1]; \
762 GLubyte b = v2->color[2];
763 #define INNER_LOOP( LEFT, RIGHT, Y ) \
764 { \
765 GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
766 (void) fffog; \
767 for (i=0;i<len;i++,xx++) { \
768 GLdepth z = FixedToDepth(ffz); \
769 if (z < zRow[i]) { \
770 pRow[i] = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
771 zRow[i] = z; \
772 } \
773 ffz += fdzdx; \
774 } \
775 }
776 #include "swrast/s_tritemp.h"
777 }
778
779
780 /*
781 * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
782 */
783 static void flat_LOOKUP8_z_triangle( GLcontext *ctx,
784 const SWvertex *v0,
785 const SWvertex *v1,
786 const SWvertex *v2 )
787 {
788 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
789 #define INTERP_Z 1
790 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
791 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
792 #define PIXEL_TYPE GLubyte
793 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
794 #define SETUP_CODE \
795 LOOKUP_SETUP; \
796 GLubyte r = v2->color[0]; \
797 GLubyte g = v2->color[1]; \
798 GLubyte b = v2->color[2]; \
799 GLubyte p = LOOKUP(r,g,b);
800 #define INNER_LOOP( LEFT, RIGHT, Y ) \
801 { \
802 GLint i, len = RIGHT-LEFT; \
803 (void) fffog; \
804 for (i=0;i<len;i++) { \
805 GLdepth z = FixedToDepth(ffz); \
806 if (z < zRow[i]) { \
807 pRow[i] = p; \
808 zRow[i] = z; \
809 } \
810 ffz += fdzdx; \
811 } \
812 }
813 #include "swrast/s_tritemp.h"
814 }
815
816
817
818 /*
819 * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
820 */
821 static void smooth_TRUECOLOR_triangle( GLcontext *ctx,
822 const SWvertex *v0,
823 const SWvertex *v1,
824 const SWvertex *v2 )
825 {
826 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
827 XMesaImage *img = xmesa->xm_buffer->backimage;
828 #define INTERP_RGB 1
829 #define INNER_LOOP( LEFT, RIGHT, Y ) \
830 { \
831 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
832 for (xx=LEFT;xx<RIGHT;xx++) { \
833 unsigned long p; \
834 PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
835 XMesaPutPixel( img, xx, yy, p ); \
836 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
837 } \
838 }
839 #include "swrast/s_tritemp.h"
840 }
841
842
843 /*
844 * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
845 */
846 static void smooth_8A8B8G8R_triangle( GLcontext *ctx,
847 const SWvertex *v0,
848 const SWvertex *v1,
849 const SWvertex *v2 )
850 {
851 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
852 #define INTERP_RGB 1
853 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
854 #define PIXEL_TYPE GLuint
855 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
856 #define INNER_LOOP( LEFT, RIGHT, Y ) \
857 { \
858 GLint xx; \
859 PIXEL_TYPE *pixel = pRow; \
860 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
861 *pixel = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
862 FixedToInt(ffb) ); \
863 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
864 } \
865 }
866 #include "swrast/s_tritemp.h"
867 }
868
869
870 /*
871 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
872 */
873 static void smooth_8R8G8B_triangle( GLcontext *ctx,
874 const SWvertex *v0,
875 const SWvertex *v1,
876 const SWvertex *v2 )
877 {
878 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
879 #define INTERP_RGB 1
880 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
881 #define PIXEL_TYPE GLuint
882 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
883 #define INNER_LOOP( LEFT, RIGHT, Y ) \
884 { \
885 GLint xx; \
886 PIXEL_TYPE *pixel = pRow; \
887 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
888 *pixel = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
889 FixedToInt(ffb) ); \
890 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
891 } \
892 }
893 #include "swrast/s_tritemp.h"
894 }
895
896
897 /*
898 * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
899 */
900 static void smooth_8R8G8B24_triangle( GLcontext *ctx,
901 const SWvertex *v0,
902 const SWvertex *v1,
903 const SWvertex *v2 )
904 {
905 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
906 #define INTERP_RGB 1
907 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
908 #define PIXEL_TYPE bgr_t
909 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
910 #define INNER_LOOP( LEFT, RIGHT, Y ) \
911 { \
912 GLint xx; \
913 PIXEL_TYPE *pixel = pRow; \
914 for (xx=LEFT;xx<RIGHT;xx++) { \
915 pixel->r = FixedToInt(ffr); \
916 pixel->g = FixedToInt(ffg); \
917 pixel->b = FixedToInt(ffb); \
918 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
919 pixel++; \
920 } \
921 }
922 #include "swrast/s_tritemp.h"
923 }
924
925
926 /*
927 * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
928 */
929 static void smooth_TRUEDITHER_triangle( GLcontext *ctx,
930 const SWvertex *v0,
931 const SWvertex *v1,
932 const SWvertex *v2 )
933 {
934 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
935 XMesaImage *img = xmesa->xm_buffer->backimage;
936 #define INTERP_RGB 1
937 #define INNER_LOOP( LEFT, RIGHT, Y ) \
938 { \
939 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
940 for (xx=LEFT;xx<RIGHT;xx++) { \
941 unsigned long p; \
942 PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), FixedToInt(ffg), \
943 FixedToInt(ffb) ); \
944 XMesaPutPixel( img, xx, yy, p ); \
945 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
946 } \
947 }
948 #include "swrast/s_tritemp.h"
949 }
950
951
952 /*
953 * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
954 */
955 static void smooth_5R6G5B_triangle( GLcontext *ctx,
956 const SWvertex *v0,
957 const SWvertex *v1,
958 const SWvertex *v2 )
959 {
960 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
961 #define INTERP_RGB 1
962 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
963 #define PIXEL_TYPE GLushort
964 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
965 #define INNER_LOOP( LEFT, RIGHT, Y ) \
966 { \
967 GLint xx; \
968 PIXEL_TYPE *pixel = pRow; \
969 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
970 *pixel = (PIXEL_TYPE) PACK_5R6G5B( FixedToInt(ffr), \
971 FixedToInt(ffg), FixedToInt(ffb) ); \
972 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
973 } \
974 }
975 #include "swrast/s_tritemp.h"
976 }
977
978
979 /*
980 * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
981 */
982 static void smooth_DITHER_5R6G5B_triangle( GLcontext *ctx,
983 const SWvertex *v0,
984 const SWvertex *v1,
985 const SWvertex *v2 )
986 {
987 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
988 #define INTERP_RGB 1
989 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
990 #define PIXEL_TYPE GLushort
991 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
992 #define INNER_LOOP( LEFT, RIGHT, Y ) \
993 { \
994 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
995 PIXEL_TYPE *pixel = pRow; \
996 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
997 PACK_TRUEDITHER(*pixel, xx, yy, FixedToInt(ffr), \
998 FixedToInt(ffg), FixedToInt(ffb) ); \
999 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1000 } \
1001 }
1002 #include "swrast/s_tritemp.h"
1003 }
1004
1005
1006 /*
1007 * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
1008 */
1009 static void smooth_DITHER8_triangle( GLcontext *ctx,
1010 const SWvertex *v0,
1011 const SWvertex *v1,
1012 const SWvertex *v2 )
1013 {
1014 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1015 #define INTERP_RGB 1
1016 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1017 #define PIXEL_TYPE GLubyte
1018 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1019 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1020 { \
1021 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1022 PIXEL_TYPE *pixel = pRow; \
1023 XDITHER_SETUP(yy); \
1024 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1025 *pixel = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
1026 FixedToInt(ffg), FixedToInt(ffb) ); \
1027 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1028 } \
1029 }
1030 #include "swrast/s_tritemp.h"
1031 }
1032
1033
1034 /*
1035 * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
1036 */
1037 static void smooth_DITHER_triangle( GLcontext *ctx,
1038 const SWvertex *v0,
1039 const SWvertex *v1,
1040 const SWvertex *v2 )
1041 {
1042 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1043 XMesaImage *img = xmesa->xm_buffer->backimage;
1044
1045 #define INTERP_RGB 1
1046 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1047 { \
1048 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1049 XDITHER_SETUP(yy); \
1050 for (xx=LEFT;xx<RIGHT;xx++) { \
1051 unsigned long p = XDITHER( xx, FixedToInt(ffr), \
1052 FixedToInt(ffg), FixedToInt(ffb) ); \
1053 XMesaPutPixel( img, xx, yy, p ); \
1054 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1055 } \
1056 }
1057 #include "swrast/s_tritemp.h"
1058 }
1059
1060
1061 /*
1062 * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1063 */
1064 static void smooth_LOOKUP8_triangle( GLcontext *ctx,
1065 const SWvertex *v0,
1066 const SWvertex *v1,
1067 const SWvertex *v2 )
1068 {
1069 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1070
1071 #define INTERP_RGB 1
1072 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1073 #define PIXEL_TYPE GLubyte
1074 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1075 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1076 { \
1077 GLint xx; \
1078 PIXEL_TYPE *pixel = pRow; \
1079 LOOKUP_SETUP; \
1080 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1081 *pixel = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
1082 FixedToInt(ffb) ); \
1083 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1084 } \
1085 }
1086 #include "swrast/s_tritemp.h"
1087 }
1088
1089
1090
1091 /*
1092 * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
1093 */
1094 static void smooth_HPCR_triangle( GLcontext *ctx,
1095 const SWvertex *v0,
1096 const SWvertex *v1,
1097 const SWvertex *v2 )
1098 {
1099 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1100
1101 #define INTERP_RGB 1
1102 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1103 #define PIXEL_TYPE GLubyte
1104 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1105 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1106 { \
1107 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1108 PIXEL_TYPE *pixel = pRow; \
1109 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1110 *pixel = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
1111 FixedToInt(ffg), FixedToInt(ffb) ); \
1112 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
1113 } \
1114 }
1115 #include "swrast/s_tritemp.h"
1116 }
1117
1118
1119 /*
1120 * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
1121 */
1122 static void flat_TRUECOLOR_triangle( GLcontext *ctx,
1123 const SWvertex *v0,
1124 const SWvertex *v1,
1125 const SWvertex *v2 )
1126 {
1127 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1128 XMesaImage *img = xmesa->xm_buffer->backimage;
1129 #define SETUP_CODE \
1130 unsigned long pixel; \
1131 PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
1132
1133 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1134 { \
1135 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1136 for (xx=LEFT;xx<RIGHT;xx++) { \
1137 XMesaPutPixel( img, xx, yy, pixel ); \
1138 } \
1139 }
1140 #include "swrast/s_tritemp.h"
1141 }
1142
1143
1144 /*
1145 * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
1146 */
1147 static void flat_8A8B8G8R_triangle( GLcontext *ctx,
1148 const SWvertex *v0,
1149 const SWvertex *v1,
1150 const SWvertex *v2 )
1151 {
1152 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1153 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1154 #define PIXEL_TYPE GLuint
1155 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1156 #define SETUP_CODE \
1157 unsigned long p = PACK_8B8G8R( v2->color[0], \
1158 v2->color[1], v2->color[2] );
1159 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1160 { \
1161 GLint xx; \
1162 PIXEL_TYPE *pixel = pRow; \
1163 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1164 *pixel = (PIXEL_TYPE) p; \
1165 } \
1166 }
1167 #include "swrast/s_tritemp.h"
1168 }
1169
1170
1171 /*
1172 * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
1173 */
1174 static void flat_8R8G8B_triangle( GLcontext *ctx,
1175 const SWvertex *v0,
1176 const SWvertex *v1,
1177 const SWvertex *v2 )
1178 {
1179 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1180 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
1181 #define PIXEL_TYPE GLuint
1182 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1183 #define SETUP_CODE \
1184 unsigned long p = PACK_8R8G8B( v2->color[0], \
1185 v2->color[1], v2->color[2] );
1186 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1187 { \
1188 GLint xx; \
1189 PIXEL_TYPE *pixel = pRow; \
1190 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1191 *pixel = (PIXEL_TYPE) p; \
1192 } \
1193 }
1194 #include "swrast/s_tritemp.h"
1195 }
1196
1197
1198 /*
1199 * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
1200 */
1201 static void flat_8R8G8B24_triangle( GLcontext *ctx,
1202 const SWvertex *v0,
1203 const SWvertex *v1,
1204 const SWvertex *v2 )
1205 {
1206 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1207 const GLubyte *color = v2->color;
1208 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
1209 #define PIXEL_TYPE bgr_t
1210 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1211 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1212 { \
1213 GLint xx; \
1214 PIXEL_TYPE *pixel = pRow; \
1215 for (xx=LEFT;xx<RIGHT;xx++) { \
1216 pixel->r = color[RCOMP]; \
1217 pixel->g = color[GCOMP]; \
1218 pixel->b = color[BCOMP]; \
1219 pixel++; \
1220 } \
1221 }
1222 #include "swrast/s_tritemp.h"
1223 }
1224
1225 /*
1226 * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
1227 */
1228 static void flat_TRUEDITHER_triangle( GLcontext *ctx,
1229 const SWvertex *v0,
1230 const SWvertex *v1,
1231 const SWvertex *v2 )
1232 {
1233 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1234 XMesaImage *img = xmesa->xm_buffer->backimage;
1235 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1236 { \
1237 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1238 for (xx=LEFT;xx<RIGHT;xx++) { \
1239 unsigned long p; \
1240 PACK_TRUEDITHER( p, xx, yy, v2->color[0], \
1241 v2->color[1], v2->color[2] ); \
1242 XMesaPutPixel( img, xx, yy, p ); \
1243 } \
1244 }
1245 #include "swrast/s_tritemp.h"
1246 }
1247
1248
1249
1250 /*
1251 * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
1252 */
1253 static void flat_5R6G5B_triangle( GLcontext *ctx,
1254 const SWvertex *v0,
1255 const SWvertex *v1,
1256 const SWvertex *v2 )
1257 {
1258 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1259 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1260 #define PIXEL_TYPE GLushort
1261 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1262 #define SETUP_CODE \
1263 unsigned long p = PACK_5R6G5B( v2->color[0], \
1264 v2->color[1], v2->color[2] );
1265 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1266 { \
1267 GLint xx; \
1268 PIXEL_TYPE *pixel = pRow; \
1269 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1270 *pixel = (PIXEL_TYPE) p; \
1271 } \
1272 }
1273 #include "swrast/s_tritemp.h"
1274 }
1275
1276
1277 /*
1278 * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
1279 */
1280 static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx,
1281 const SWvertex *v0,
1282 const SWvertex *v1,
1283 const SWvertex *v2 )
1284 {
1285 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1286 const GLubyte *color = v2->color;
1287 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
1288 #define PIXEL_TYPE GLushort
1289 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1290 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1291 { \
1292 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1293 PIXEL_TYPE *pixel = pRow; \
1294 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1295 PACK_TRUEDITHER(*pixel, xx, yy, color[RCOMP], \
1296 color[GCOMP], color[BCOMP]); \
1297 } \
1298 }
1299 #include "swrast/s_tritemp.h"
1300 }
1301
1302
1303 /*
1304 * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
1305 */
1306 static void flat_DITHER8_triangle( GLcontext *ctx,
1307 const SWvertex *v0,
1308 const SWvertex *v1,
1309 const SWvertex *v2 )
1310 {
1311 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1312 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1313 #define PIXEL_TYPE GLubyte
1314 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1315 #define SETUP_CODE \
1316 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1317
1318 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1319 { \
1320 GLint xx; \
1321 PIXEL_TYPE *pixel = pRow; \
1322 FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
1323 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1324 *pixel = (PIXEL_TYPE) FLAT_DITHER(xx); \
1325 } \
1326 }
1327 #include "swrast/s_tritemp.h"
1328 }
1329
1330
1331 /*
1332 * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
1333 */
1334 static void flat_DITHER_triangle( GLcontext *ctx,
1335 const SWvertex *v0,
1336 const SWvertex *v1,
1337 const SWvertex *v2 )
1338 {
1339 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1340 XMesaImage *img = xmesa->xm_buffer->backimage;
1341 #define SETUP_CODE \
1342 FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
1343
1344 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1345 { \
1346 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1347 FLAT_DITHER_ROW_SETUP(yy); \
1348 for (xx=LEFT;xx<RIGHT;xx++) { \
1349 unsigned long p = FLAT_DITHER(xx); \
1350 XMesaPutPixel( img, xx, yy, p ); \
1351 } \
1352 }
1353 #include "swrast/s_tritemp.h"
1354 }
1355
1356
1357 /*
1358 * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
1359 */
1360 static void flat_HPCR_triangle( GLcontext *ctx,
1361 const SWvertex *v0,
1362 const SWvertex *v1,
1363 const SWvertex *v2 )
1364 {
1365 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1366 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1367 #define PIXEL_TYPE GLubyte
1368 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1369 #define SETUP_CODE \
1370 GLubyte r = v2->color[0]; \
1371 GLubyte g = v2->color[1]; \
1372 GLubyte b = v2->color[2];
1373 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1374 { \
1375 GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
1376 PIXEL_TYPE *pixel = pRow; \
1377 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1378 *pixel = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
1379 } \
1380 }
1381 #include "swrast/s_tritemp.h"
1382 }
1383
1384
1385 /*
1386 * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
1387 */
1388 static void flat_LOOKUP8_triangle( GLcontext *ctx,
1389 const SWvertex *v0,
1390 const SWvertex *v1,
1391 const SWvertex *v2 )
1392 {
1393 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1394 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
1395 #define PIXEL_TYPE GLubyte
1396 #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
1397 #define SETUP_CODE \
1398 LOOKUP_SETUP; \
1399 GLubyte r = v2->color[0]; \
1400 GLubyte g = v2->color[1]; \
1401 GLubyte b = v2->color[2]; \
1402 GLubyte p = LOOKUP(r,g,b);
1403 #define INNER_LOOP( LEFT, RIGHT, Y ) \
1404 { \
1405 GLint xx; \
1406 PIXEL_TYPE *pixel = pRow; \
1407 for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
1408 *pixel = p; \
1409 } \
1410 }
1411 #include "swrast/s_tritemp.h"
1412 }
1413
1414
1415 #ifdef DEBUG
1416 extern void _xmesa_print_triangle_func( swrast_tri_func triFunc );
1417 void _xmesa_print_triangle_func( swrast_tri_func triFunc )
1418 {
1419 printf("XMesa tri func = ");
1420 if (triFunc ==smooth_TRUECOLOR_z_triangle)
1421 printf("smooth_TRUECOLOR_z_triangle\n");
1422 else if (triFunc ==smooth_8A8B8G8R_z_triangle)
1423 printf("smooth_8A8B8G8R_z_triangle\n");
1424 else if (triFunc ==smooth_8R8G8B_z_triangle)
1425 printf("smooth_8R8G8B_z_triangle\n");
1426 else if (triFunc ==smooth_8R8G8B24_z_triangle)
1427 printf("smooth_8R8G8B24_z_triangle\n");
1428 else if (triFunc ==smooth_TRUEDITHER_z_triangle)
1429 printf("smooth_TRUEDITHER_z_triangle\n");
1430 else if (triFunc ==smooth_5R6G5B_z_triangle)
1431 printf("smooth_5R6G5B_z_triangle\n");
1432 else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle)
1433 printf("smooth_DITHER_5R6G5B_z_triangle\n");
1434 else if (triFunc ==smooth_HPCR_z_triangle)
1435 printf("smooth_HPCR_z_triangle\n");
1436 else if (triFunc ==smooth_DITHER8_z_triangle)
1437 printf("smooth_DITHER8_z_triangle\n");
1438 else if (triFunc ==smooth_LOOKUP8_z_triangle)
1439 printf("smooth_LOOKUP8_z_triangle\n");
1440 else if (triFunc ==flat_TRUECOLOR_z_triangle)
1441 printf("flat_TRUECOLOR_z_triangle\n");
1442 else if (triFunc ==flat_8A8B8G8R_z_triangle)
1443 printf("flat_8A8B8G8R_z_triangle\n");
1444 else if (triFunc ==flat_8R8G8B_z_triangle)
1445 printf("flat_8R8G8B_z_triangle\n");
1446 else if (triFunc ==flat_8R8G8B24_z_triangle)
1447 printf("flat_8R8G8B24_z_triangle\n");
1448 else if (triFunc ==flat_TRUEDITHER_z_triangle)
1449 printf("flat_TRUEDITHER_z_triangle\n");
1450 else if (triFunc ==flat_5R6G5B_z_triangle)
1451 printf("flat_5R6G5B_z_triangle\n");
1452 else if (triFunc ==flat_DITHER_5R6G5B_z_triangle)
1453 printf("flat_DITHER_5R6G5B_z_triangle\n");
1454 else if (triFunc ==flat_HPCR_z_triangle)
1455 printf("flat_HPCR_z_triangle\n");
1456 else if (triFunc ==flat_DITHER8_z_triangle)
1457 printf("flat_DITHER8_z_triangle\n");
1458 else if (triFunc ==flat_LOOKUP8_z_triangle)
1459 printf("flat_LOOKUP8_z_triangle\n");
1460 else if (triFunc ==smooth_TRUECOLOR_triangle)
1461 printf("smooth_TRUECOLOR_triangle\n");
1462 else if (triFunc ==smooth_8A8B8G8R_triangle)
1463 printf("smooth_8A8B8G8R_triangle\n");
1464 else if (triFunc ==smooth_8R8G8B_triangle)
1465 printf("smooth_8R8G8B_triangle\n");
1466 else if (triFunc ==smooth_8R8G8B24_triangle)
1467 printf("smooth_8R8G8B24_triangle\n");
1468 else if (triFunc ==smooth_TRUEDITHER_triangle)
1469 printf("smooth_TRUEDITHER_triangle\n");
1470 else if (triFunc ==smooth_5R6G5B_triangle)
1471 printf("smooth_5R6G5B_triangle\n");
1472 else if (triFunc ==smooth_DITHER_5R6G5B_triangle)
1473 printf("smooth_DITHER_5R6G5B_triangle\n");
1474 else if (triFunc ==smooth_HPCR_triangle)
1475 printf("smooth_HPCR_triangle\n");
1476 else if (triFunc ==smooth_DITHER8_triangle)
1477 printf("smooth_DITHER8_triangle\n");
1478 else if (triFunc ==smooth_LOOKUP8_triangle)
1479 printf("smooth_LOOKUP8_triangle\n");
1480 else if (triFunc ==flat_TRUECOLOR_triangle)
1481 printf("flat_TRUECOLOR_triangle\n");
1482 else if (triFunc ==flat_TRUEDITHER_triangle)
1483 printf("flat_TRUEDITHER_triangle\n");
1484 else if (triFunc ==flat_8A8B8G8R_triangle)
1485 printf("flat_8A8B8G8R_triangle\n");
1486 else if (triFunc ==flat_8R8G8B_triangle)
1487 printf("flat_8R8G8B_triangle\n");
1488 else if (triFunc ==flat_8R8G8B24_triangle)
1489 printf("flat_8R8G8B24_triangle\n");
1490 else if (triFunc ==flat_5R6G5B_triangle)
1491 printf("flat_5R6G5B_triangle\n");
1492 else if (triFunc ==flat_DITHER_5R6G5B_triangle)
1493 printf("flat_DITHER_5R6G5B_triangle\n");
1494 else if (triFunc ==flat_HPCR_triangle)
1495 printf("flat_HPCR_triangle\n");
1496 else if (triFunc ==flat_DITHER8_triangle)
1497 printf("flat_DITHER8_triangle\n");
1498 else if (triFunc ==flat_LOOKUP8_triangle)
1499 printf("flat_LOOKUP8_triangle\n");
1500 else
1501 printf("???\n");
1502 }
1503 #endif
1504
1505
1506 #ifdef DEBUG
1507
1508 /* record the current triangle function name */
1509 static const char *triFuncName = NULL;
1510
1511 #define USE(triFunc) \
1512 do { \
1513 triFuncName = #triFunc; \
1514 /*printf("%s\n", triFuncName);*/ \
1515 return triFunc; \
1516 } while (0)
1517
1518 #else
1519
1520 #define USE(triFunc) return triFunc
1521
1522 #endif
1523
1524
1525 static swrast_tri_func get_triangle_func( GLcontext *ctx )
1526 {
1527 SWcontext *swrast = SWRAST_CONTEXT(ctx);
1528 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
1529 int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
1530
1531 (void) kernel1;
1532
1533 #ifdef DEBUG
1534 triFuncName = NULL;
1535 #endif
1536
1537 if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
1538 if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
1539 if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
1540
1541 if (xmesa->xm_buffer->buffer==XIMAGE) {
1542 if ( ctx->Light.ShadeModel==GL_SMOOTH
1543 && swrast->_RasterMask==DEPTH_BIT
1544 && ctx->Depth.Func==GL_LESS
1545 && ctx->Depth.Mask==GL_TRUE
1546 && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
1547 && ctx->Polygon.StippleFlag==GL_FALSE) {
1548 switch (xmesa->pixelformat) {
1549 case PF_TRUECOLOR:
1550 USE(smooth_TRUECOLOR_z_triangle);
1551 case PF_8A8B8G8R:
1552 USE(smooth_8A8B8G8R_z_triangle);
1553 case PF_8R8G8B:
1554 USE(smooth_8R8G8B_z_triangle);
1555 case PF_8R8G8B24:
1556 USE(smooth_8R8G8B24_z_triangle);
1557 case PF_TRUEDITHER:
1558 USE(smooth_TRUEDITHER_z_triangle);
1559 case PF_5R6G5B:
1560 USE(smooth_5R6G5B_z_triangle);
1561 case PF_DITHER_5R6G5B:
1562 USE(smooth_DITHER_5R6G5B_z_triangle);
1563 case PF_HPCR:
1564 USE(smooth_HPCR_z_triangle);
1565 case PF_DITHER:
1566 if (depth == 8)
1567 USE(smooth_DITHER8_z_triangle);
1568 else
1569 USE(smooth_DITHER_z_triangle);
1570 break;
1571 case PF_LOOKUP:
1572 if (depth == 8)
1573 USE(smooth_LOOKUP8_z_triangle);
1574 else
1575 return (swrast_tri_func) NULL;
1576 default:
1577 return (swrast_tri_func) NULL;
1578 }
1579 }
1580 if ( ctx->Light.ShadeModel==GL_FLAT
1581 && swrast->_RasterMask==DEPTH_BIT
1582 && ctx->Depth.Func==GL_LESS
1583 && ctx->Depth.Mask==GL_TRUE
1584 && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
1585 && ctx->Polygon.StippleFlag==GL_FALSE) {
1586 switch (xmesa->pixelformat) {
1587 case PF_TRUECOLOR:
1588 USE(flat_TRUECOLOR_z_triangle);
1589 case PF_8A8B8G8R:
1590 USE(flat_8A8B8G8R_z_triangle);
1591 case PF_8R8G8B:
1592 USE(flat_8R8G8B_z_triangle);
1593 case PF_8R8G8B24:
1594 USE(flat_8R8G8B24_z_triangle);
1595 case PF_TRUEDITHER:
1596 USE(flat_TRUEDITHER_z_triangle);
1597 case PF_5R6G5B:
1598 USE(flat_5R6G5B_z_triangle);
1599 case PF_DITHER_5R6G5B:
1600 USE(flat_DITHER_5R6G5B_z_triangle);
1601 case PF_HPCR:
1602 USE(flat_HPCR_z_triangle);
1603 case PF_DITHER:
1604 if (depth == 8)
1605 USE(flat_DITHER8_z_triangle);
1606 else
1607 USE(flat_DITHER_z_triangle);
1608 break;
1609 case PF_LOOKUP:
1610 if (depth == 8)
1611 USE(flat_LOOKUP8_z_triangle);
1612 else
1613 return (swrast_tri_func) NULL;
1614 default:
1615 return (swrast_tri_func) NULL;
1616 }
1617 }
1618 if ( swrast->_RasterMask==0 /* no depth test */
1619 && ctx->Light.ShadeModel==GL_SMOOTH
1620 && ctx->Polygon.StippleFlag==GL_FALSE) {
1621 switch (xmesa->pixelformat) {
1622 case PF_TRUECOLOR:
1623 USE(smooth_TRUECOLOR_triangle);
1624 case PF_8A8B8G8R:
1625 USE(smooth_8A8B8G8R_triangle);
1626 case PF_8R8G8B:
1627 USE(smooth_8R8G8B_triangle);
1628 case PF_8R8G8B24:
1629 USE(smooth_8R8G8B24_triangle);
1630 case PF_TRUEDITHER:
1631 USE(smooth_TRUEDITHER_triangle);
1632 case PF_5R6G5B:
1633 USE(smooth_5R6G5B_triangle);
1634 case PF_DITHER_5R6G5B:
1635 USE(smooth_DITHER_5R6G5B_triangle);
1636 case PF_HPCR:
1637 USE(smooth_HPCR_triangle);
1638 case PF_DITHER:
1639 if (depth == 8)
1640 USE(smooth_DITHER8_triangle);
1641 else
1642 USE(smooth_DITHER_triangle);
1643 break;
1644 case PF_LOOKUP:
1645 if (depth == 8)
1646 USE(smooth_LOOKUP8_triangle);
1647 else
1648 return (swrast_tri_func) NULL;
1649 default:
1650 return (swrast_tri_func) NULL;
1651 }
1652 }
1653
1654 if ( swrast->_RasterMask==0 /* no depth test */
1655 && ctx->Light.ShadeModel==GL_FLAT
1656 && ctx->Polygon.StippleFlag==GL_FALSE) {
1657 switch (xmesa->pixelformat) {
1658 case PF_TRUECOLOR:
1659 USE(flat_TRUECOLOR_triangle);
1660 case PF_TRUEDITHER:
1661 USE(flat_TRUEDITHER_triangle);
1662 case PF_8A8B8G8R:
1663 USE(flat_8A8B8G8R_triangle);
1664 case PF_8R8G8B:
1665 USE(flat_8R8G8B_triangle);
1666 case PF_8R8G8B24:
1667 USE(flat_8R8G8B24_triangle);
1668 case PF_5R6G5B:
1669 USE(flat_5R6G5B_triangle);
1670 case PF_DITHER_5R6G5B:
1671 USE(flat_DITHER_5R6G5B_triangle);
1672 case PF_HPCR:
1673 USE(flat_HPCR_triangle);
1674 case PF_DITHER:
1675 if (depth == 8)
1676 USE(flat_DITHER8_triangle);
1677 else
1678 USE(flat_DITHER_triangle);
1679 break;
1680 case PF_LOOKUP:
1681 if (depth == 8)
1682 USE(flat_LOOKUP8_triangle);
1683 else
1684 return (swrast_tri_func) NULL;
1685 default:
1686 return (swrast_tri_func) NULL;
1687 }
1688 }
1689
1690 return (swrast_tri_func) NULL;
1691 }
1692 else {
1693 /* draw to pixmap */
1694 return (swrast_tri_func) NULL;
1695 }
1696 }
1697
1698
1699 /* Override for the swrast tri-selection function. Try to use one
1700 * of our internal tri functions, otherwise fall back to the
1701 * standard swrast functions.
1702 */
1703 void xmesa_choose_triangle( GLcontext *ctx )
1704 {
1705 SWcontext *swrast = SWRAST_CONTEXT(ctx);
1706
1707 if (!(swrast->Triangle = get_triangle_func( ctx )))
1708 _swrast_choose_triangle( ctx );
1709 }
1710