If an application cleared before any state had been emitted, that clear would
[mesa.git] / src / mesa / drivers / dri / common / depthtmp.h
1 /* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.5 2001/03/21 16:14:20 dawes Exp $ */
2
3 #ifndef DBG
4 #define DBG 0
5 #endif
6
7
8 #ifndef HAVE_HW_DEPTH_SPANS
9 #define HAVE_HW_DEPTH_SPANS 0
10 #endif
11 #ifndef HAVE_HW_DEPTH_PIXELS
12 #define HAVE_HW_DEPTH_PIXELS 0
13 #endif
14
15 #ifndef HW_READ_LOCK
16 #define HW_READ_LOCK() HW_LOCK()
17 #endif
18 #ifndef HW_READ_UNLOCK
19 #define HW_READ_UNLOCK() HW_UNLOCK()
20 #endif
21
22 static void TAG(WriteDepthSpan)( GLcontext *ctx,
23 GLuint n, GLint x, GLint y,
24 const GLdepth *depth,
25 const GLubyte mask[] )
26 {
27 HW_WRITE_LOCK()
28 {
29 GLint x1;
30 GLint n1;
31 LOCAL_DEPTH_VARS;
32
33 y = Y_FLIP( y );
34
35 #if HAVE_HW_DEPTH_SPANS
36 (void) x1; (void) n1;
37
38 if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n",
39 (int)n, (int)x );
40
41 WRITE_DEPTH_SPAN();
42 #else
43 HW_CLIPLOOP()
44 {
45 GLint i = 0;
46 CLIPSPAN( x, y, n, x1, n1, i );
47
48 if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
49 (int)i, (int)n1, (int)x1 );
50
51 if ( mask ) {
52 for ( ; i < n1 ; i++, x1++ ) {
53 if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
54 }
55 } else {
56 for ( ; i < n1 ; i++, x1++ ) {
57 WRITE_DEPTH( x1, y, depth[i] );
58 }
59 }
60 }
61 HW_ENDCLIPLOOP();
62 #endif
63 }
64 HW_WRITE_UNLOCK();
65 }
66
67 static void TAG(WriteMonoDepthSpan)( GLcontext *ctx,
68 GLuint n, GLint x, GLint y,
69 const GLdepth depth,
70 const GLubyte mask[] )
71 {
72 HW_WRITE_LOCK()
73 {
74 GLint x1;
75 GLint n1;
76 LOCAL_DEPTH_VARS;
77
78 y = Y_FLIP( y );
79
80 HW_CLIPLOOP()
81 {
82 GLint i = 0;
83 CLIPSPAN( x, y, n, x1, n1, i );
84
85 if ( DBG ) fprintf( stderr, "%s %d..%d (x1 %d) = %u\n",
86 __FUNCTION__, (int)i, (int)n1, (int)x1, (GLuint)depth );
87
88 if ( mask ) {
89 for ( ; i < n1 ; i++, x1++ ) {
90 if ( mask[i] ) WRITE_DEPTH( x1, y, depth );
91 }
92 } else {
93 for ( ; i < n1 ; i++, x1++ ) {
94 WRITE_DEPTH( x1, y, depth );
95 }
96 }
97 }
98 HW_ENDCLIPLOOP();
99 }
100 HW_WRITE_UNLOCK();
101 }
102
103 static void TAG(WriteDepthPixels)( GLcontext *ctx,
104 GLuint n,
105 const GLint x[],
106 const GLint y[],
107 const GLdepth depth[],
108 const GLubyte mask[] )
109 {
110 HW_WRITE_LOCK()
111 {
112 GLint i;
113 LOCAL_DEPTH_VARS;
114
115 if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
116
117 #if HAVE_HW_DEPTH_PIXELS
118 (void) i;
119
120 WRITE_DEPTH_PIXELS();
121 #else
122 HW_CLIPLOOP()
123 {
124 for ( i = 0 ; i < n ; i++ ) {
125 if ( mask[i] ) {
126 const int fy = Y_FLIP( y[i] );
127 if ( CLIPPIXEL( x[i], fy ) )
128 WRITE_DEPTH( x[i], fy, depth[i] );
129 }
130 }
131 }
132 HW_ENDCLIPLOOP();
133 #endif
134 }
135 HW_WRITE_UNLOCK();
136 }
137
138
139 /* Read depth spans and pixels
140 */
141 static void TAG(ReadDepthSpan)( GLcontext *ctx,
142 GLuint n, GLint x, GLint y,
143 GLdepth depth[] )
144 {
145 HW_READ_LOCK()
146 {
147 GLint x1, n1;
148 LOCAL_DEPTH_VARS;
149
150 y = Y_FLIP( y );
151
152 if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" );
153
154 #if HAVE_HW_DEPTH_SPANS
155 (void) x1; (void) n1;
156
157 READ_DEPTH_SPAN();
158 #else
159 HW_CLIPLOOP()
160 {
161 GLint i = 0;
162 CLIPSPAN( x, y, n, x1, n1, i );
163 for ( ; i < n1 ; i++ )
164 READ_DEPTH( depth[i], (x1+i), y );
165 }
166 HW_ENDCLIPLOOP();
167 #endif
168 }
169 HW_READ_UNLOCK();
170 }
171
172 static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
173 const GLint x[], const GLint y[],
174 GLdepth depth[] )
175 {
176 HW_READ_LOCK()
177 {
178 GLint i;
179 LOCAL_DEPTH_VARS;
180
181 if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
182
183 #if HAVE_HW_DEPTH_PIXELS
184 (void) i;
185
186 READ_DEPTH_PIXELS();
187 #else
188 HW_CLIPLOOP()
189 {
190 for ( i = 0 ; i < n ;i++ ) {
191 int fy = Y_FLIP( y[i] );
192 if ( CLIPPIXEL( x[i], fy ) )
193 READ_DEPTH( depth[i], x[i], fy );
194 }
195 }
196 HW_ENDCLIPLOOP();
197 #endif
198 }
199 HW_READ_UNLOCK();
200 }
201
202
203 #if HAVE_HW_DEPTH_SPANS
204 #undef WRITE_DEPTH_SPAN
205 #undef WRITE_DEPTH_PIXELS
206 #undef READ_DEPTH_SPAN
207 #undef READ_DEPTH_PIXELS
208 #else
209 #undef WRITE_DEPTH
210 #undef READ_DEPTH
211 #endif
212 #undef TAG