removed GL_ prefix from memory macros
[mesa.git] / src / mesa / main / depth.c
1 /* $Id: depth.c,v 1.7 1999/10/13 18:42:50 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
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 /* $XFree86: xc/lib/GL/mesa/src/depth.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */
29
30 /*
31 * Depth buffer functions
32 */
33
34 #include <stdlib.h>
35
36 #ifdef PC_HEADER
37 #include "all.h"
38 #else
39 #ifndef XFree86Server
40 #include <stdio.h>
41 #include <string.h>
42 #else
43 #include "GL/xf86glx.h"
44 #endif
45 #include "context.h"
46 #include "enums.h"
47 #include "depth.h"
48 #include "macros.h"
49 #include "types.h"
50 #ifdef XFree86Server
51 #include "GL/xf86glx.h"
52 #endif
53 #endif
54
55
56
57 /**********************************************************************/
58 /***** API Functions *****/
59 /**********************************************************************/
60
61
62
63 void gl_ClearDepth( GLcontext* ctx, GLclampd depth )
64 {
65 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClearDepth");
66 ctx->Depth.Clear = (GLfloat) CLAMP( depth, 0.0, 1.0 );
67 if (ctx->Driver.ClearDepth)
68 (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear );
69 }
70
71
72
73 void gl_DepthFunc( GLcontext* ctx, GLenum func )
74 {
75 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDepthFunc");
76
77 if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
78 fprintf(stderr, "glDepthFunc %s\n", gl_lookup_enum_by_nr(func));
79
80 switch (func) {
81 case GL_LESS: /* (default) pass if incoming z < stored z */
82 case GL_GEQUAL:
83 case GL_LEQUAL:
84 case GL_GREATER:
85 case GL_NOTEQUAL:
86 case GL_EQUAL:
87 case GL_ALWAYS:
88 if (ctx->Depth.Func != func) {
89 ctx->Depth.Func = func;
90 ctx->NewState |= NEW_RASTER_OPS;
91 ctx->TriangleCaps &= ~DD_Z_NEVER;
92 if (ctx->Driver.DepthFunc) {
93 (*ctx->Driver.DepthFunc)( ctx, func );
94 }
95 }
96 break;
97 case GL_NEVER:
98 if (ctx->Depth.Func != func) {
99 ctx->Depth.Func = func;
100 ctx->NewState |= NEW_RASTER_OPS;
101 ctx->TriangleCaps |= DD_Z_NEVER;
102 if (ctx->Driver.DepthFunc) {
103 (*ctx->Driver.DepthFunc)( ctx, func );
104 }
105 }
106 break;
107 default:
108 gl_error( ctx, GL_INVALID_ENUM, "glDepth.Func" );
109 }
110 }
111
112
113
114 void gl_DepthMask( GLcontext* ctx, GLboolean flag )
115 {
116 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDepthMask");
117
118 if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
119 fprintf(stderr, "glDepthMask %d\n", flag);
120
121 /*
122 * GL_TRUE indicates depth buffer writing is enabled (default)
123 * GL_FALSE indicates depth buffer writing is disabled
124 */
125 if (ctx->Depth.Mask != flag) {
126 ctx->Depth.Mask = flag;
127 ctx->NewState |= NEW_RASTER_OPS;
128 if (ctx->Driver.DepthMask) {
129 (*ctx->Driver.DepthMask)( ctx, flag );
130 }
131 }
132 }
133
134
135
136 /**********************************************************************/
137 /***** Depth Testing Functions *****/
138 /**********************************************************************/
139
140
141 /*
142 * Depth test horizontal spans of fragments. These functions are called
143 * via ctx->Driver.depth_test_span only.
144 *
145 * Input: n - number of pixels in the span
146 * x, y - location of leftmost pixel in span in window coords
147 * z - array [n] of integer depth values
148 * In/Out: mask - array [n] of flags (1=draw pixel, 0=don't draw)
149 * Return: number of pixels which passed depth test
150 */
151
152
153 /*
154 * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
155 */
156 GLuint gl_depth_test_span_generic( GLcontext* ctx,
157 GLuint n, GLint x, GLint y,
158 const GLdepth z[],
159 GLubyte mask[] )
160 {
161 GLdepth *zptr = Z_ADDRESS( ctx, x, y );
162 GLubyte *m = mask;
163 GLuint i;
164 GLuint passed = 0;
165
166 /* switch cases ordered from most frequent to less frequent */
167 switch (ctx->Depth.Func) {
168 case GL_LESS:
169 if (ctx->Depth.Mask) {
170 /* Update Z buffer */
171 for (i=0; i<n; i++,zptr++,m++) {
172 if (*m) {
173 if (z[i] < *zptr) {
174 /* pass */
175 *zptr = z[i];
176 passed++;
177 }
178 else {
179 /* fail */
180 *m = 0;
181 }
182 }
183 }
184 }
185 else {
186 /* Don't update Z buffer */
187 for (i=0; i<n; i++,zptr++,m++) {
188 if (*m) {
189 if (z[i] < *zptr) {
190 /* pass */
191 passed++;
192 }
193 else {
194 *m = 0;
195 }
196 }
197 }
198 }
199 break;
200 case GL_LEQUAL:
201 if (ctx->Depth.Mask) {
202 /* Update Z buffer */
203 for (i=0;i<n;i++,zptr++,m++) {
204 if (*m) {
205 if (z[i] <= *zptr) {
206 *zptr = z[i];
207 passed++;
208 }
209 else {
210 *m = 0;
211 }
212 }
213 }
214 }
215 else {
216 /* Don't update Z buffer */
217 for (i=0;i<n;i++,zptr++,m++) {
218 if (*m) {
219 if (z[i] <= *zptr) {
220 /* pass */
221 passed++;
222 }
223 else {
224 *m = 0;
225 }
226 }
227 }
228 }
229 break;
230 case GL_GEQUAL:
231 if (ctx->Depth.Mask) {
232 /* Update Z buffer */
233 for (i=0;i<n;i++,zptr++,m++) {
234 if (*m) {
235 if (z[i] >= *zptr) {
236 *zptr = z[i];
237 passed++;
238 }
239 else {
240 *m = 0;
241 }
242 }
243 }
244 }
245 else {
246 /* Don't update Z buffer */
247 for (i=0;i<n;i++,zptr++,m++) {
248 if (*m) {
249 if (z[i] >= *zptr) {
250 /* pass */
251 passed++;
252 }
253 else {
254 *m = 0;
255 }
256 }
257 }
258 }
259 break;
260 case GL_GREATER:
261 if (ctx->Depth.Mask) {
262 /* Update Z buffer */
263 for (i=0;i<n;i++,zptr++,m++) {
264 if (*m) {
265 if (z[i] > *zptr) {
266 *zptr = z[i];
267 passed++;
268 }
269 else {
270 *m = 0;
271 }
272 }
273 }
274 }
275 else {
276 /* Don't update Z buffer */
277 for (i=0;i<n;i++,zptr++,m++) {
278 if (*m) {
279 if (z[i] > *zptr) {
280 /* pass */
281 passed++;
282 }
283 else {
284 *m = 0;
285 }
286 }
287 }
288 }
289 break;
290 case GL_NOTEQUAL:
291 if (ctx->Depth.Mask) {
292 /* Update Z buffer */
293 for (i=0;i<n;i++,zptr++,m++) {
294 if (*m) {
295 if (z[i] != *zptr) {
296 *zptr = z[i];
297 passed++;
298 }
299 else {
300 *m = 0;
301 }
302 }
303 }
304 }
305 else {
306 /* Don't update Z buffer */
307 for (i=0;i<n;i++,zptr++,m++) {
308 if (*m) {
309 if (z[i] != *zptr) {
310 /* pass */
311 passed++;
312 }
313 else {
314 *m = 0;
315 }
316 }
317 }
318 }
319 break;
320 case GL_EQUAL:
321 if (ctx->Depth.Mask) {
322 /* Update Z buffer */
323 for (i=0;i<n;i++,zptr++,m++) {
324 if (*m) {
325 if (z[i] == *zptr) {
326 *zptr = z[i];
327 passed++;
328 }
329 else {
330 *m =0;
331 }
332 }
333 }
334 }
335 else {
336 /* Don't update Z buffer */
337 for (i=0;i<n;i++,zptr++,m++) {
338 if (*m) {
339 if (z[i] == *zptr) {
340 /* pass */
341 passed++;
342 }
343 else {
344 *m =0;
345 }
346 }
347 }
348 }
349 break;
350 case GL_ALWAYS:
351 if (ctx->Depth.Mask) {
352 /* Update Z buffer */
353 for (i=0;i<n;i++,zptr++,m++) {
354 if (*m) {
355 *zptr = z[i];
356 passed++;
357 }
358 }
359 }
360 else {
361 /* Don't update Z buffer or mask */
362 passed = n;
363 }
364 break;
365 case GL_NEVER:
366 for (i=0;i<n;i++) {
367 mask[i] = 0;
368 }
369 break;
370 default:
371 gl_problem(ctx, "Bad depth func in gl_depth_test_span_generic");
372 } /*switch*/
373
374 return passed;
375 }
376
377
378
379 /*
380 * glDepthFunc(GL_LESS) and glDepthMask(GL_TRUE).
381 */
382 GLuint gl_depth_test_span_less( GLcontext* ctx,
383 GLuint n, GLint x, GLint y, const GLdepth z[],
384 GLubyte mask[] )
385 {
386 GLdepth *zptr = Z_ADDRESS( ctx, x, y );
387 GLuint i;
388 GLuint passed = 0;
389
390 for (i=0; i<n; i++) {
391 if (mask[i]) {
392 if (z[i] < zptr[i]) {
393 /* pass */
394 zptr[i] = z[i];
395 passed++;
396 }
397 else {
398 /* fail */
399 mask[i] = 0;
400 }
401 }
402 }
403 return passed;
404 }
405
406
407 /*
408 * glDepthFunc(GL_GREATER) and glDepthMask(GL_TRUE).
409 */
410 GLuint gl_depth_test_span_greater( GLcontext* ctx,
411 GLuint n, GLint x, GLint y,
412 const GLdepth z[],
413 GLubyte mask[] )
414 {
415 GLdepth *zptr = Z_ADDRESS( ctx, x, y );
416 GLuint i;
417 GLuint passed = 0;
418
419 for (i=0; i<n; i++) {
420 if (mask[i]) {
421 if (z[i] > zptr[i]) {
422 /* pass */
423 zptr[i] = z[i];
424 passed++;
425 }
426 else {
427 /* fail */
428 mask[i] = 0;
429 }
430 }
431 }
432 return passed;
433 }
434
435
436
437 /*
438 * Depth test an array of randomly positioned fragments.
439 */
440
441
442 #define ZADDR_SETUP GLdepth *depthbuffer = ctx->Buffer->Depth; \
443 GLint width = ctx->Buffer->Width;
444
445 #define ZADDR( X, Y ) (depthbuffer + (Y) * width + (X) )
446
447
448
449 /*
450 * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
451 */
452 void gl_depth_test_pixels_generic( GLcontext* ctx,
453 GLuint n, const GLint x[], const GLint y[],
454 const GLdepth z[], GLubyte mask[] )
455 {
456 register GLdepth *zptr;
457 register GLuint i;
458
459 /* switch cases ordered from most frequent to less frequent */
460 switch (ctx->Depth.Func) {
461 case GL_LESS:
462 if (ctx->Depth.Mask) {
463 /* Update Z buffer */
464 for (i=0; i<n; i++) {
465 if (mask[i]) {
466 zptr = Z_ADDRESS(ctx,x[i],y[i]);
467 if (z[i] < *zptr) {
468 /* pass */
469 *zptr = z[i];
470 }
471 else {
472 /* fail */
473 mask[i] = 0;
474 }
475 }
476 }
477 }
478 else {
479 /* Don't update Z buffer */
480 for (i=0; i<n; i++) {
481 if (mask[i]) {
482 zptr = Z_ADDRESS(ctx,x[i],y[i]);
483 if (z[i] < *zptr) {
484 /* pass */
485 }
486 else {
487 /* fail */
488 mask[i] = 0;
489 }
490 }
491 }
492 }
493 break;
494 case GL_LEQUAL:
495 if (ctx->Depth.Mask) {
496 /* Update Z buffer */
497 for (i=0; i<n; i++) {
498 if (mask[i]) {
499 zptr = Z_ADDRESS(ctx,x[i],y[i]);
500 if (z[i] <= *zptr) {
501 /* pass */
502 *zptr = z[i];
503 }
504 else {
505 /* fail */
506 mask[i] = 0;
507 }
508 }
509 }
510 }
511 else {
512 /* Don't update Z buffer */
513 for (i=0; i<n; i++) {
514 if (mask[i]) {
515 zptr = Z_ADDRESS(ctx,x[i],y[i]);
516 if (z[i] <= *zptr) {
517 /* pass */
518 }
519 else {
520 /* fail */
521 mask[i] = 0;
522 }
523 }
524 }
525 }
526 break;
527 case GL_GEQUAL:
528 if (ctx->Depth.Mask) {
529 /* Update Z buffer */
530 for (i=0; i<n; i++) {
531 if (mask[i]) {
532 zptr = Z_ADDRESS(ctx,x[i],y[i]);
533 if (z[i] >= *zptr) {
534 /* pass */
535 *zptr = z[i];
536 }
537 else {
538 /* fail */
539 mask[i] = 0;
540 }
541 }
542 }
543 }
544 else {
545 /* Don't update Z buffer */
546 for (i=0; i<n; i++) {
547 if (mask[i]) {
548 zptr = Z_ADDRESS(ctx,x[i],y[i]);
549 if (z[i] >= *zptr) {
550 /* pass */
551 }
552 else {
553 /* fail */
554 mask[i] = 0;
555 }
556 }
557 }
558 }
559 break;
560 case GL_GREATER:
561 if (ctx->Depth.Mask) {
562 /* Update Z buffer */
563 for (i=0; i<n; i++) {
564 if (mask[i]) {
565 zptr = Z_ADDRESS(ctx,x[i],y[i]);
566 if (z[i] > *zptr) {
567 /* pass */
568 *zptr = z[i];
569 }
570 else {
571 /* fail */
572 mask[i] = 0;
573 }
574 }
575 }
576 }
577 else {
578 /* Don't update Z buffer */
579 for (i=0; i<n; i++) {
580 if (mask[i]) {
581 zptr = Z_ADDRESS(ctx,x[i],y[i]);
582 if (z[i] > *zptr) {
583 /* pass */
584 }
585 else {
586 /* fail */
587 mask[i] = 0;
588 }
589 }
590 }
591 }
592 break;
593 case GL_NOTEQUAL:
594 if (ctx->Depth.Mask) {
595 /* Update Z buffer */
596 for (i=0; i<n; i++) {
597 if (mask[i]) {
598 zptr = Z_ADDRESS(ctx,x[i],y[i]);
599 if (z[i] != *zptr) {
600 /* pass */
601 *zptr = z[i];
602 }
603 else {
604 /* fail */
605 mask[i] = 0;
606 }
607 }
608 }
609 }
610 else {
611 /* Don't update Z buffer */
612 for (i=0; i<n; i++) {
613 if (mask[i]) {
614 zptr = Z_ADDRESS(ctx,x[i],y[i]);
615 if (z[i] != *zptr) {
616 /* pass */
617 }
618 else {
619 /* fail */
620 mask[i] = 0;
621 }
622 }
623 }
624 }
625 break;
626 case GL_EQUAL:
627 if (ctx->Depth.Mask) {
628 /* Update Z buffer */
629 for (i=0; i<n; i++) {
630 if (mask[i]) {
631 zptr = Z_ADDRESS(ctx,x[i],y[i]);
632 if (z[i] == *zptr) {
633 /* pass */
634 *zptr = z[i];
635 }
636 else {
637 /* fail */
638 mask[i] = 0;
639 }
640 }
641 }
642 }
643 else {
644 /* Don't update Z buffer */
645 for (i=0; i<n; i++) {
646 if (mask[i]) {
647 zptr = Z_ADDRESS(ctx,x[i],y[i]);
648 if (z[i] == *zptr) {
649 /* pass */
650 }
651 else {
652 /* fail */
653 mask[i] = 0;
654 }
655 }
656 }
657 }
658 break;
659 case GL_ALWAYS:
660 if (ctx->Depth.Mask) {
661 /* Update Z buffer */
662 for (i=0; i<n; i++) {
663 if (mask[i]) {
664 zptr = Z_ADDRESS(ctx,x[i],y[i]);
665 *zptr = z[i];
666 }
667 }
668 }
669 else {
670 /* Don't update Z buffer or mask */
671 }
672 break;
673 case GL_NEVER:
674 /* depth test never passes */
675 for (i=0;i<n;i++) {
676 mask[i] = 0;
677 }
678 break;
679 default:
680 gl_problem(ctx, "Bad depth func in gl_depth_test_pixels_generic");
681 } /*switch*/
682 }
683
684
685
686 /*
687 * glDepthFunc( GL_LESS ) and glDepthMask( GL_TRUE ).
688 */
689 void gl_depth_test_pixels_less( GLcontext* ctx,
690 GLuint n, const GLint x[], const GLint y[],
691 const GLdepth z[], GLubyte mask[] )
692 {
693 GLdepth *zptr;
694 GLuint i;
695
696 for (i=0; i<n; i++) {
697 if (mask[i]) {
698 zptr = Z_ADDRESS(ctx,x[i],y[i]);
699 if (z[i] < *zptr) {
700 /* pass */
701 *zptr = z[i];
702 }
703 else {
704 /* fail */
705 mask[i] = 0;
706 }
707 }
708 }
709 }
710
711
712 /*
713 * glDepthFunc( GL_GREATER ) and glDepthMask( GL_TRUE ).
714 */
715 void gl_depth_test_pixels_greater( GLcontext* ctx,
716 GLuint n, const GLint x[], const GLint y[],
717 const GLdepth z[], GLubyte mask[] )
718 {
719 GLdepth *zptr;
720 GLuint i;
721
722 for (i=0; i<n; i++) {
723 if (mask[i]) {
724 zptr = Z_ADDRESS(ctx,x[i],y[i]);
725 if (z[i] > *zptr) {
726 /* pass */
727 *zptr = z[i];
728 }
729 else {
730 /* fail */
731 mask[i] = 0;
732 }
733 }
734 }
735 }
736
737
738
739
740 /**********************************************************************/
741 /***** Read Depth Buffer *****/
742 /**********************************************************************/
743
744
745 /*
746 * Return a span of depth values from the depth buffer as floats in [0,1].
747 * This function is only called through Driver.read_depth_span_float()
748 * Input: n - how many pixels
749 * x,y - location of first pixel
750 * Output: depth - the array of depth values
751 */
752 void gl_read_depth_span_float( GLcontext* ctx,
753 GLuint n, GLint x, GLint y, GLfloat depth[] )
754 {
755 GLdepth *zptr;
756 GLfloat scale;
757 GLuint i;
758
759 scale = 1.0F / DEPTH_SCALE;
760
761 if (ctx->Buffer->Depth) {
762 zptr = Z_ADDRESS( ctx, x, y );
763 for (i=0;i<n;i++) {
764 depth[i] = (GLfloat) zptr[i] * scale;
765 }
766 }
767 else {
768 for (i=0;i<n;i++) {
769 depth[i] = 0.0F;
770 }
771 }
772 }
773
774
775 /*
776 * Return a span of depth values from the depth buffer as integers in
777 * [0,MAX_DEPTH].
778 * This function is only called through Driver.read_depth_span_int()
779 * Input: n - how many pixels
780 * x,y - location of first pixel
781 * Output: depth - the array of depth values
782 */
783 void gl_read_depth_span_int( GLcontext* ctx,
784 GLuint n, GLint x, GLint y, GLdepth depth[] )
785 {
786 if (ctx->Buffer->Depth) {
787 GLdepth *zptr = Z_ADDRESS( ctx, x, y );
788 MEMCPY( depth, zptr, n * sizeof(GLdepth) );
789 }
790 else {
791 GLuint i;
792 for (i=0;i<n;i++) {
793 depth[i] = 0;
794 }
795 }
796 }
797
798
799
800 /**********************************************************************/
801 /***** Allocate and Clear Depth Buffer *****/
802 /**********************************************************************/
803
804
805
806 /*
807 * Allocate a new depth buffer. If there's already a depth buffer allocated
808 * it will be free()'d. The new depth buffer will be uniniitalized.
809 * This function is only called through Driver.alloc_depth_buffer.
810 */
811 void gl_alloc_depth_buffer( GLcontext* ctx )
812 {
813 /* deallocate current depth buffer if present */
814 if (ctx->Buffer->Depth) {
815 FREE(ctx->Buffer->Depth);
816 ctx->Buffer->Depth = NULL;
817 }
818
819 /* allocate new depth buffer, but don't initialize it */
820 ctx->Buffer->Depth = (GLdepth *) MALLOC( ctx->Buffer->Width
821 * ctx->Buffer->Height
822 * sizeof(GLdepth) );
823 if (!ctx->Buffer->Depth) {
824 /* out of memory */
825 ctx->Depth.Test = GL_FALSE;
826 ctx->NewState |= NEW_RASTER_OPS;
827 gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer" );
828 }
829 }
830
831
832
833
834 /*
835 * Clear the depth buffer. If the depth buffer doesn't exist yet we'll
836 * allocate it now.
837 * This function is only called through Driver.clear_depth_buffer.
838 */
839 void gl_clear_depth_buffer( GLcontext* ctx )
840 {
841 GLdepth clear_value = (GLdepth) (ctx->Depth.Clear * DEPTH_SCALE);
842
843 if (ctx->Visual->DepthBits==0 || !ctx->Buffer->Depth || !ctx->Depth.Mask) {
844 /* no depth buffer, or writing to it is disabled */
845 return;
846 }
847
848 /* The loops in this function have been written so the IRIX 5.3
849 * C compiler can unroll them. Hopefully other compilers can too!
850 */
851
852 if (ctx->Scissor.Enabled) {
853 /* only clear scissor region */
854 GLint y;
855 for (y=ctx->Buffer->Ymin; y<=ctx->Buffer->Ymax; y++) {
856 GLdepth *d = Z_ADDRESS( ctx, ctx->Buffer->Xmin, y );
857 GLint n = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1;
858 do {
859 *d++ = clear_value;
860 n--;
861 } while (n);
862 }
863 }
864 else {
865 /* clear whole buffer */
866 if (sizeof(GLdepth)==2 && (clear_value&0xff)==(clear_value>>8)) {
867 /* lower and upper bytes of clear_value are same, use MEMSET */
868 MEMSET( ctx->Buffer->Depth, clear_value&0xff,
869 2*ctx->Buffer->Width*ctx->Buffer->Height);
870 }
871 else {
872 GLdepth *d = ctx->Buffer->Depth;
873 GLint n = ctx->Buffer->Width * ctx->Buffer->Height;
874 while (n>=16) {
875 d[0] = clear_value; d[1] = clear_value;
876 d[2] = clear_value; d[3] = clear_value;
877 d[4] = clear_value; d[5] = clear_value;
878 d[6] = clear_value; d[7] = clear_value;
879 d[8] = clear_value; d[9] = clear_value;
880 d[10] = clear_value; d[11] = clear_value;
881 d[12] = clear_value; d[13] = clear_value;
882 d[14] = clear_value; d[15] = clear_value;
883 d += 16;
884 n -= 16;
885 }
886 while (n>0) {
887 *d++ = clear_value;
888 n--;
889 }
890 }
891 }
892 }
893
894
895