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