Initial revision
[mesa.git] / src / mesa / drivers / glide / fxddspan.c
1 /* -*- mode: C; tab-width:8; -*-
2
3 fxdd.c - 3Dfx VooDoo Mesa span and pixel functions
4 */
5
6 /*
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * See the file fxapi.c for more informations about authors
22 *
23 */
24
25 #ifdef HAVE_CONFIG_H
26 #include "conf.h"
27 #endif
28
29 #if defined(FX)
30
31 #include "fxdrv.h"
32
33 #ifdef _MSC_VER
34 #ifdef _WIN32
35 #pragma warning( disable : 4090 4022 )
36 /* 4101 : "different 'const' qualifier"
37 * 4022 : "pointer mistmatch for actual parameter 'n'
38 */
39 #endif
40 #endif
41
42
43 #if !defined(FXMESA_USE_ARGB)
44
45 #define LFB_WRITE_SPAN_MESA(dst_buffer,dst_x,dst_y,src_width,src_stride,src_data) \
46 grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_width,1,GR_LFB_SRC_FMT_8888,src_stride,src_data)
47 #else /* defined(FXMESA_USE_RGBA) */
48
49 #define MESACOLOR_TO_ARGB(c) ( \
50 ( ((unsigned int)(c[ACOMP]))<<24 ) | \
51 ( ((unsigned int)(c[RCOMP]))<<16 ) | \
52 ( ((unsigned int)(c[GCOMP]))<<8 ) | \
53 ( (unsigned int)(c[BCOMP])) )
54
55 /* inline */ void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
56 FxU32 dst_x, FxU32 dst_y,
57 /* GrLfbSrcFmt_t src_format, format is GR_LFB_SRC_FMT_8888 */
58 FxU32 src_width,/* FxU32 src_height, height is 1 */
59 FxI32 src_stride, void *src_data )
60 {
61 /* Covert to ARGB */
62 GLubyte (*rgba)[4] = src_data;
63 GLuint argb[MAX_WIDTH];
64 int i;
65
66 for (i = 0; i < src_width; i++)
67 {
68 argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
69 }
70 FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,GR_LFB_SRC_FMT_8888,src_width,1,src_stride,(void*)argb);
71 }
72 #endif
73
74 /************************************************************************/
75 /***** Span functions *****/
76 /************************************************************************/
77
78 static void fxDDWriteRGBASpan(const GLcontext *ctx,
79 GLuint n, GLint x, GLint y,
80 const GLubyte rgba[][4], const GLubyte mask[])
81 {
82 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
83 GLuint i;
84 GLint bottom=fxMesa->height-1;
85
86 if (MESA_VERBOSE&VERBOSE_DRIVER) {
87 fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
88 }
89
90 if (mask) {
91 int span=0;
92
93 for (i=0;i<n;i++) {
94 if (mask[i]) {
95 ++span;
96 } else {
97 if (span > 0) {
98 LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
99 /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] );
100 span = 0;
101 }
102 }
103 }
104
105 if (span > 0)
106 LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
107 /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] );
108 } else
109 LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
110 n,/* 1,*/ 0, (void *) rgba );
111 }
112
113
114 static void fxDDWriteRGBSpan(const GLcontext *ctx,
115 GLuint n, GLint x, GLint y,
116 const GLubyte rgb[][3], const GLubyte mask[])
117 {
118 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
119 GLuint i;
120 GLint bottom=fxMesa->height-1;
121 GLubyte rgba[MAX_WIDTH][4];
122
123 if (MESA_VERBOSE&VERBOSE_DRIVER) {
124 fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
125 }
126
127 if (mask) {
128 int span=0;
129
130 for (i=0;i<n;i++) {
131 if (mask[i]) {
132 rgba[span][RCOMP] = rgb[i][0];
133 rgba[span][GCOMP] = rgb[i][1];
134 rgba[span][BCOMP] = rgb[i][2];
135 rgba[span][ACOMP] = 255;
136 ++span;
137 } else {
138 if (span > 0) {
139 LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
140 /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
141 span = 0;
142 }
143 }
144 }
145
146 if (span > 0)
147 LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
148 /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
149 } else {
150 for (i=0;i<n;i++) {
151 rgba[i][RCOMP]=rgb[i][0];
152 rgba[i][GCOMP]=rgb[i][1];
153 rgba[i][BCOMP]=rgb[i][2];
154 rgba[i][ACOMP]=255;
155 }
156
157 LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
158 n,/* 1,*/ 0, (void *) rgba );
159 }
160 }
161
162
163 static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
164 GLuint n, GLint x, GLint y,
165 const GLubyte mask[])
166 {
167 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
168 GLuint i;
169 GLint bottom=fxMesa->height-1;
170 GLuint data[MAX_WIDTH];
171
172 if (MESA_VERBOSE&VERBOSE_DRIVER) {
173 fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
174 }
175
176 if (mask) {
177 int span=0;
178
179 for (i=0;i<n;i++) {
180 if (mask[i]) {
181 data[span] = (GLuint) fxMesa->color;
182 ++span;
183 } else {
184 if (span > 0) {
185 FX_grLfbWriteRegion( fxMesa->currentFB, x+i-span, bottom-y,
186 GR_LFB_SRC_FMT_8888, span, 1, 0,
187 (void *) data );
188 span = 0;
189 }
190 }
191 }
192
193 if (span > 0)
194 FX_grLfbWriteRegion( fxMesa->currentFB, x+n-span, bottom-y,
195 GR_LFB_SRC_FMT_8888, span, 1, 0,
196 (void *) data );
197 } else {
198 for (i=0;i<n;i++) {
199 data[i]=(GLuint) fxMesa->color;
200 }
201
202 FX_grLfbWriteRegion( fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
203 n, 1, 0, (void *) data );
204 }
205 }
206
207
208 static void fxDDReadRGBASpan(const GLcontext *ctx,
209 GLuint n, GLint x, GLint y, GLubyte rgba[][4])
210 {
211 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
212 GLushort data[MAX_WIDTH];
213 GLuint i;
214 GLint bottom=fxMesa->height-1;
215
216 if (MESA_VERBOSE&VERBOSE_DRIVER) {
217 fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n");
218 }
219
220 assert(n < MAX_WIDTH);
221
222 grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
223 for (i=0;i<n;i++) {
224 #if FXMESA_USE_ARGB
225 rgba[i][RCOMP]=(data[i] & 0xF800) >> 8;
226 rgba[i][GCOMP]=(data[i] & 0x07E0) >> 3;
227 rgba[i][BCOMP]=(data[i] & 0x001F) << 3;
228 #else
229 rgba[i][RCOMP]=(data[i] & 0x001f) << 3;
230 rgba[i][GCOMP]=(data[i] & 0x07e0) >> 3;
231 rgba[i][BCOMP]=(data[i] & 0xf800) >> 8;
232 #endif
233 rgba[i][ACOMP]=255;
234 }
235
236 }
237
238 /************************************************************************/
239 /***** Pixel functions *****/
240 /************************************************************************/
241
242 static void fxDDWriteRGBAPixels(const GLcontext *ctx,
243 GLuint n, const GLint x[], const GLint y[],
244 CONST GLubyte rgba[][4], const GLubyte mask[])
245 {
246 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
247 GLuint i;
248 GLint bottom=fxMesa->height-1;
249
250 if (MESA_VERBOSE&VERBOSE_DRIVER) {
251 fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
252 }
253
254 for(i=0;i<n;i++)
255 if(mask[i])
256 LFB_WRITE_SPAN_MESA(fxMesa->currentFB,x[i],bottom-y[i],
257 /*GR_LFB_SRC_FMT_8888,*/1,/*1,*/0,(void *)rgba[i]);
258 }
259
260 static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
261 GLuint n, const GLint x[], const GLint y[],
262 const GLubyte mask[])
263 {
264 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
265 GLuint i;
266 GLint bottom=fxMesa->height-1;
267
268 if (MESA_VERBOSE&VERBOSE_DRIVER) {
269 fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
270 }
271
272 for(i=0;i<n;i++)
273 if(mask[i])
274 FX_grLfbWriteRegion(fxMesa->currentFB,x[i],bottom-y[i],
275 GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color);
276 }
277
278 static void fxDDReadRGBAPixels(const GLcontext *ctx,
279 GLuint n, const GLint x[], const GLint y[],
280 GLubyte rgba[][4], const GLubyte mask[])
281 {
282 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
283 GLuint i;
284 GLint bottom=fxMesa->height-1;
285 GLushort data;
286
287 if (MESA_VERBOSE&VERBOSE_DRIVER) {
288 fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
289 }
290
291 for(i=0;i<n;i++)
292 if(mask[i]) {
293 grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&data);
294 #if FXMESA_USE_ARGB
295 rgba[i][RCOMP]=(data & 0xF800) >> 8;
296 rgba[i][GCOMP]=(data & 0x07E0) >> 3;
297 rgba[i][BCOMP]=(data & 0x001F) >> 8;
298 #else
299 rgba[i][RCOMP]=(data & 0x001f) << 3;
300 rgba[i][GCOMP]=(data & 0x07e0) >> 3;
301 rgba[i][BCOMP]=(data & 0xf800) >> 8;
302 #endif
303 /* the alpha value should be read from the auxiliary buffer when required */
304
305 rgba[i][ACOMP]=255;
306 }
307 }
308
309 /************************************************************************/
310 /***** Depth functions *****/
311 /************************************************************************/
312
313 void fxDDReadDepthSpanFloat(GLcontext *ctx,
314 GLuint n, GLint x, GLint y, GLfloat depth[])
315 {
316 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
317 GLuint i;
318 GLint bottom=fxMesa->height-1;
319 GLushort data[MAX_WIDTH];
320
321 if (MESA_VERBOSE&VERBOSE_DRIVER) {
322 fprintf(stderr,"fxmesa: fxDDReadDepthSpanFloat(...)\n");
323 }
324
325 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data);
326
327 /*
328 convert the read values to float values [0.0 .. 1.0].
329 */
330 for(i=0;i<n;i++)
331 depth[i]=data[i]/65535.0f;
332 }
333
334 void fxDDReadDepthSpanInt(GLcontext *ctx,
335 GLuint n, GLint x, GLint y, GLdepth depth[])
336 {
337 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
338 GLint bottom=fxMesa->height-1;
339
340 if (MESA_VERBOSE&VERBOSE_DRIVER) {
341 fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
342 }
343
344 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
345 }
346
347 GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
348 GLuint n, GLint x, GLint y, const GLdepth z[],
349 GLubyte mask[])
350 {
351 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
352 GLushort depthdata[MAX_WIDTH];
353 GLdepth *zptr=depthdata;
354 GLubyte *m=mask;
355 GLuint i;
356 GLuint passed=0;
357 GLint bottom=fxMesa->height-1;
358
359 if (MESA_VERBOSE&VERBOSE_DRIVER) {
360 fprintf(stderr,"fxmesa: fxDDDepthTestSpanGeneric(...)\n");
361 }
362
363 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata);
364
365 /* switch cases ordered from most frequent to less frequent */
366 switch (ctx->Depth.Func) {
367 case GL_LESS:
368 if (ctx->Depth.Mask) {
369 /* Update Z buffer */
370 for (i=0; i<n; i++,zptr++,m++) {
371 if (*m) {
372 if (z[i] < *zptr) {
373 /* pass */
374 *zptr = z[i];
375 passed++;
376 } else {
377 /* fail */
378 *m = 0;
379 }
380 }
381 }
382 } else {
383 /* Don't update Z buffer */
384 for (i=0; i<n; i++,zptr++,m++) {
385 if (*m) {
386 if (z[i] < *zptr) {
387 /* pass */
388 passed++;
389 } else {
390 *m = 0;
391 }
392 }
393 }
394 }
395 break;
396 case GL_LEQUAL:
397 if (ctx->Depth.Mask) {
398 /* Update Z buffer */
399 for (i=0;i<n;i++,zptr++,m++) {
400 if (*m) {
401 if (z[i] <= *zptr) {
402 *zptr = z[i];
403 passed++;
404 } else {
405 *m = 0;
406 }
407 }
408 }
409 } else {
410 /* Don't update Z buffer */
411 for (i=0;i<n;i++,zptr++,m++) {
412 if (*m) {
413 if (z[i] <= *zptr) {
414 /* pass */
415 passed++;
416 } else {
417 *m = 0;
418 }
419 }
420 }
421 }
422 break;
423 case GL_GEQUAL:
424 if (ctx->Depth.Mask) {
425 /* Update Z buffer */
426 for (i=0;i<n;i++,zptr++,m++) {
427 if (*m) {
428 if (z[i] >= *zptr) {
429 *zptr = z[i];
430 passed++;
431 } else {
432 *m = 0;
433 }
434 }
435 }
436 } else {
437 /* Don't update Z buffer */
438 for (i=0;i<n;i++,zptr++,m++) {
439 if (*m) {
440 if (z[i] >= *zptr) {
441 /* pass */
442 passed++;
443 } else {
444 *m = 0;
445 }
446 }
447 }
448 }
449 break;
450 case GL_GREATER:
451 if (ctx->Depth.Mask) {
452 /* Update Z buffer */
453 for (i=0;i<n;i++,zptr++,m++) {
454 if (*m) {
455 if (z[i] > *zptr) {
456 *zptr = z[i];
457 passed++;
458 } else {
459 *m = 0;
460 }
461 }
462 }
463 } else {
464 /* Don't update Z buffer */
465 for (i=0;i<n;i++,zptr++,m++) {
466 if (*m) {
467 if (z[i] > *zptr) {
468 /* pass */
469 passed++;
470 } else {
471 *m = 0;
472 }
473 }
474 }
475 }
476 break;
477 case GL_NOTEQUAL:
478 if (ctx->Depth.Mask) {
479 /* Update Z buffer */
480 for (i=0;i<n;i++,zptr++,m++) {
481 if (*m) {
482 if (z[i] != *zptr) {
483 *zptr = z[i];
484 passed++;
485 } else {
486 *m = 0;
487 }
488 }
489 }
490 } else {
491 /* Don't update Z buffer */
492 for (i=0;i<n;i++,zptr++,m++) {
493 if (*m) {
494 if (z[i] != *zptr) {
495 /* pass */
496 passed++;
497 } else {
498 *m = 0;
499 }
500 }
501 }
502 }
503 break;
504 case GL_EQUAL:
505 if (ctx->Depth.Mask) {
506 /* Update Z buffer */
507 for (i=0;i<n;i++,zptr++,m++) {
508 if (*m) {
509 if (z[i] == *zptr) {
510 *zptr = z[i];
511 passed++;
512 } else {
513 *m =0;
514 }
515 }
516 }
517 } else {
518 /* Don't update Z buffer */
519 for (i=0;i<n;i++,zptr++,m++) {
520 if (*m) {
521 if (z[i] == *zptr) {
522 /* pass */
523 passed++;
524 } else {
525 *m =0;
526 }
527 }
528 }
529 }
530 break;
531 case GL_ALWAYS:
532 if (ctx->Depth.Mask) {
533 /* Update Z buffer */
534 for (i=0;i<n;i++,zptr++,m++) {
535 if (*m) {
536 *zptr = z[i];
537 passed++;
538 }
539 }
540 } else {
541 /* Don't update Z buffer or mask */
542 passed = n;
543 }
544 break;
545 case GL_NEVER:
546 for (i=0;i<n;i++) {
547 mask[i] = 0;
548 }
549 break;
550 default:
551 ;
552 } /*switch*/
553
554 if(passed)
555 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata);
556
557 return passed;
558 }
559
560 void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
561 GLuint n, const GLint x[], const GLint y[],
562 const GLdepth z[], GLubyte mask[])
563 {
564 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
565 GLdepth zval;
566 GLuint i;
567 GLint bottom=fxMesa->height-1;
568
569 if (MESA_VERBOSE&VERBOSE_DRIVER) {
570 fprintf(stderr,"fxmesa: fxDDDepthTestPixelsGeneric(...)\n");
571 }
572
573 /* switch cases ordered from most frequent to less frequent */
574 switch (ctx->Depth.Func) {
575 case GL_LESS:
576 if (ctx->Depth.Mask) {
577 /* Update Z buffer */
578 for (i=0; i<n; i++) {
579 if (mask[i]) {
580 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
581 if (z[i] < zval) {
582 /* pass */
583 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
584 } else {
585 /* fail */
586 mask[i] = 0;
587 }
588 }
589 }
590 } else {
591 /* Don't update Z buffer */
592 for (i=0; i<n; i++) {
593 if (mask[i]) {
594 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
595 if (z[i] < zval) {
596 /* pass */
597 }
598 else {
599 /* fail */
600 mask[i] = 0;
601 }
602 }
603 }
604 }
605 break;
606 case GL_LEQUAL:
607 if (ctx->Depth.Mask) {
608 /* Update Z buffer */
609 for (i=0; i<n; i++) {
610 if (mask[i]) {
611 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
612 if (z[i] <= zval) {
613 /* pass */
614 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
615 } else {
616 /* fail */
617 mask[i] = 0;
618 }
619 }
620 }
621 } else {
622 /* Don't update Z buffer */
623 for (i=0; i<n; i++) {
624 if (mask[i]) {
625 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
626 if (z[i] <= zval) {
627 /* pass */
628 } else {
629 /* fail */
630 mask[i] = 0;
631 }
632 }
633 }
634 }
635 break;
636 case GL_GEQUAL:
637 if (ctx->Depth.Mask) {
638 /* Update Z buffer */
639 for (i=0; i<n; i++) {
640 if (mask[i]) {
641 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
642 if (z[i] >= zval) {
643 /* pass */
644 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
645 } else {
646 /* fail */
647 mask[i] = 0;
648 }
649 }
650 }
651 } else {
652 /* Don't update Z buffer */
653 for (i=0; i<n; i++) {
654 if (mask[i]) {
655 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
656 if (z[i] >= zval) {
657 /* pass */
658 } else {
659 /* fail */
660 mask[i] = 0;
661 }
662 }
663 }
664 }
665 break;
666 case GL_GREATER:
667 if (ctx->Depth.Mask) {
668 /* Update Z buffer */
669 for (i=0; i<n; i++) {
670 if (mask[i]) {
671 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
672 if (z[i] > zval) {
673 /* pass */
674 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
675 } else {
676 /* fail */
677 mask[i] = 0;
678 }
679 }
680 }
681 } else {
682 /* Don't update Z buffer */
683 for (i=0; i<n; i++) {
684 if (mask[i]) {
685 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
686 if (z[i] > zval) {
687 /* pass */
688 } else {
689 /* fail */
690 mask[i] = 0;
691 }
692 }
693 }
694 }
695 break;
696 case GL_NOTEQUAL:
697 if (ctx->Depth.Mask) {
698 /* Update Z buffer */
699 for (i=0; i<n; i++) {
700 if (mask[i]) {
701 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
702 if (z[i] != zval) {
703 /* pass */
704 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
705 } else {
706 /* fail */
707 mask[i] = 0;
708 }
709 }
710 }
711 } else {
712 /* Don't update Z buffer */
713 for (i=0; i<n; i++) {
714 if (mask[i]) {
715 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
716 if (z[i] != zval) {
717 /* pass */
718 }
719 else {
720 /* fail */
721 mask[i] = 0;
722 }
723 }
724 }
725 }
726 break;
727 case GL_EQUAL:
728 if (ctx->Depth.Mask) {
729 /* Update Z buffer */
730 for (i=0; i<n; i++) {
731 if (mask[i]) {
732 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
733 if (z[i] == zval) {
734 /* pass */
735 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
736 } else {
737 /* fail */
738 mask[i] = 0;
739 }
740 }
741 }
742 } else {
743 /* Don't update Z buffer */
744 for (i=0; i<n; i++) {
745 if (mask[i]) {
746 grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
747 if (z[i] == zval) {
748 /* pass */
749 } else {
750 /* fail */
751 mask[i] = 0;
752 }
753 }
754 }
755 }
756 break;
757 case GL_ALWAYS:
758 if (ctx->Depth.Mask) {
759 /* Update Z buffer */
760 for (i=0; i<n; i++) {
761 if (mask[i]) {
762 FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
763 }
764 }
765 } else {
766 /* Don't update Z buffer or mask */
767 }
768 break;
769 case GL_NEVER:
770 /* depth test never passes */
771 for (i=0;i<n;i++) {
772 mask[i] = 0;
773 }
774 break;
775 default:
776 ;
777 } /*switch*/
778 }
779
780 /************************************************************************/
781
782
783 void fxSetupDDSpanPointers(GLcontext *ctx)
784 {
785 ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan;
786 ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan;
787 ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan;
788 ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels;
789 ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels;
790
791 ctx->Driver.WriteCI8Span =NULL;
792 ctx->Driver.WriteCI32Span =NULL;
793 ctx->Driver.WriteMonoCISpan =NULL;
794 ctx->Driver.WriteCI32Pixels =NULL;
795 ctx->Driver.WriteMonoCIPixels =NULL;
796
797 ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;
798 ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels;
799
800 ctx->Driver.ReadCI32Span =NULL;
801 ctx->Driver.ReadCI32Pixels =NULL;
802 }
803
804
805 #else
806
807
808 /*
809 * Need this to provide at least one external definition.
810 */
811
812 int gl_fx_dummy_function_span(void)
813 {
814 return 0;
815 }
816
817 #endif /* FX */