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