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