1 /* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.5 2001/03/21 16:14:20 dawes Exp $ */
5 * 1. These functions plug into the gl_renderbuffer structure.
6 * 2. The 'values' parameter always points to GLuint values, regardless of
7 * the actual Z buffer depth.
16 #ifndef HAVE_HW_DEPTH_SPANS
17 #define HAVE_HW_DEPTH_SPANS 0
19 #ifndef HAVE_HW_DEPTH_PIXELS
20 #define HAVE_HW_DEPTH_PIXELS 0
24 #define HW_READ_LOCK() HW_LOCK()
26 #ifndef HW_READ_UNLOCK
27 #define HW_READ_UNLOCK() HW_UNLOCK()
30 static void TAG(WriteDepthSpan
)( GLcontext
*ctx
,
31 struct gl_renderbuffer
*rb
,
32 GLuint n
, GLint x
, GLint y
,
34 const GLubyte mask
[] )
38 const GLuint
*depth
= (const GLuint
*) values
;
45 #if HAVE_HW_DEPTH_SPANS
48 if ( DBG
) fprintf( stderr
, "WriteDepthSpan 0..%d (x1 %d)\n",
56 CLIPSPAN( x
, y
, n
, x1
, n1
, i
);
58 if ( DBG
) fprintf( stderr
, "WriteDepthSpan %d..%d (x1 %d) (mask %p)\n",
59 (int)i
, (int)n1
, (int)x1
, mask
);
62 for ( ; n1
>0 ; i
++, x1
++, n1
-- ) {
63 if ( mask
[i
] ) WRITE_DEPTH( x1
, y
, depth
[i
] );
66 for ( ; n1
>0 ; i
++, x1
++, n1
-- ) {
67 WRITE_DEPTH( x1
, y
, depth
[i
] );
78 #if HAVE_HW_DEPTH_SPANS
79 /* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
81 TAG(WriteMonoDepthSpan
)( GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
82 GLuint n
, GLint x
, GLint y
,
83 const void *value
, const GLubyte mask
[] )
85 const GLuint depthVal
= *((GLuint
*) value
);
86 GLuint depths
[MAX_WIDTH
];
88 for (i
= 0; i
< n
; i
++)
90 TAG(WriteDepthSpan
)(ctx
, rb
, n
, x
, y
, depths
, mask
);
93 static void TAG(WriteMonoDepthSpan
)( GLcontext
*ctx
,
94 struct gl_renderbuffer
*rb
,
95 GLuint n
, GLint x
, GLint y
,
97 const GLubyte mask
[] )
101 const GLuint depth
= *((GLuint
*) value
);
111 CLIPSPAN( x
, y
, n
, x1
, n1
, i
);
113 if ( DBG
) fprintf( stderr
, "%s %d..%d (x1 %d) = %u\n",
114 __FUNCTION__
, (int)i
, (int)n1
, (int)x1
, (GLuint
)depth
);
117 for ( ; n1
>0 ; i
++, x1
++, n1
-- ) {
118 if ( mask
[i
] ) WRITE_DEPTH( x1
, y
, depth
);
121 for ( ; n1
>0 ; x1
++, n1
-- ) {
122 WRITE_DEPTH( x1
, y
, depth
);
133 static void TAG(WriteDepthPixels
)( GLcontext
*ctx
,
134 struct gl_renderbuffer
*rb
,
139 const GLubyte mask
[] )
143 const GLuint
*depth
= (const GLuint
*) values
;
147 if ( DBG
) fprintf( stderr
, "WriteDepthPixels\n" );
149 #if HAVE_HW_DEPTH_PIXELS
152 WRITE_DEPTH_PIXELS();
156 for ( i
= 0 ; i
< n
; i
++ ) {
158 const int fy
= Y_FLIP( y
[i
] );
159 if ( CLIPPIXEL( x
[i
], fy
) )
160 WRITE_DEPTH( x
[i
], fy
, depth
[i
] );
171 /* Read depth spans and pixels
173 static void TAG(ReadDepthSpan
)( GLcontext
*ctx
,
174 struct gl_renderbuffer
*rb
,
175 GLuint n
, GLint x
, GLint y
,
180 GLuint
*depth
= (GLuint
*) values
;
186 if ( DBG
) fprintf( stderr
, "ReadDepthSpan\n" );
188 #if HAVE_HW_DEPTH_SPANS
189 (void) x1
; (void) n1
;
196 CLIPSPAN( x
, y
, n
, x1
, n1
, i
);
197 for ( ; n1
>0 ; i
++, n1
-- ) {
198 READ_DEPTH( depth
[i
], x
+i
, y
);
207 static void TAG(ReadDepthPixels
)( GLcontext
*ctx
,
208 struct gl_renderbuffer
*rb
,
210 const GLint x
[], const GLint y
[],
215 GLuint
*depth
= (GLuint
*) values
;
219 if ( DBG
) fprintf( stderr
, "ReadDepthPixels\n" );
221 #if HAVE_HW_DEPTH_PIXELS
228 for ( i
= 0 ; i
< n
;i
++ ) {
229 int fy
= Y_FLIP( y
[i
] );
230 if ( CLIPPIXEL( x
[i
], fy
) )
231 READ_DEPTH( depth
[i
], x
[i
], fy
);
241 #if HAVE_HW_DEPTH_SPANS
242 #undef WRITE_DEPTH_SPAN
243 #undef WRITE_DEPTH_PIXELS
244 #undef READ_DEPTH_SPAN
245 #undef READ_DEPTH_PIXELS