4 * 1. These functions plug into the gl_renderbuffer structure.
5 * 2. The 'values' parameter always points to GLuint values, regardless of
6 * the actual Z buffer depth.
10 #include "spantmp_common.h"
16 #ifndef HAVE_HW_DEPTH_SPANS
17 #define HAVE_HW_DEPTH_SPANS 0
20 #ifndef HAVE_HW_DEPTH_PIXELS
21 #define HAVE_HW_DEPTH_PIXELS 0
24 static void TAG(WriteDepthSpan
)( struct gl_context
*ctx
,
25 struct gl_renderbuffer
*rb
,
26 GLuint n
, GLint x
, GLint y
,
28 const GLubyte mask
[] )
32 const VALUE_TYPE
*depth
= (const VALUE_TYPE
*) values
;
39 #if HAVE_HW_DEPTH_SPANS
42 if ( DBG
) fprintf( stderr
, "WriteDepthSpan 0..%d (x1 %d)\n",
50 CLIPSPAN( x
, y
, n
, x1
, n1
, i
);
52 if ( DBG
) fprintf( stderr
, "WriteDepthSpan %d..%d (x1 %d) (mask %p)\n",
53 (int)i
, (int)n1
, (int)x1
, mask
);
56 for ( ; n1
>0 ; i
++, x1
++, n1
-- ) {
57 if ( mask
[i
] ) WRITE_DEPTH( x1
, y
, depth
[i
] );
60 for ( ; n1
>0 ; i
++, x1
++, n1
-- ) {
61 WRITE_DEPTH( x1
, y
, depth
[i
] );
74 static void TAG(WriteDepthPixels
)( struct gl_context
*ctx
,
75 struct gl_renderbuffer
*rb
,
80 const GLubyte mask
[] )
84 const VALUE_TYPE
*depth
= (const VALUE_TYPE
*) values
;
88 if ( DBG
) fprintf( stderr
, "WriteDepthPixels\n" );
90 #if HAVE_HW_DEPTH_PIXELS
98 for ( i
= 0 ; i
< n
; i
++ ) {
100 const int fy
= Y_FLIP( y
[i
] );
101 if ( CLIPPIXEL( x
[i
], fy
) )
102 WRITE_DEPTH( x
[i
], fy
, depth
[i
] );
107 for ( i
= 0 ; i
< n
; i
++ ) {
108 const int fy
= Y_FLIP( y
[i
] );
109 if ( CLIPPIXEL( x
[i
], fy
) )
110 WRITE_DEPTH( x
[i
], fy
, depth
[i
] );
123 /* Read depth spans and pixels
125 static void TAG(ReadDepthSpan
)( struct gl_context
*ctx
,
126 struct gl_renderbuffer
*rb
,
127 GLuint n
, GLint x
, GLint y
,
132 VALUE_TYPE
*depth
= (VALUE_TYPE
*) values
;
138 if ( DBG
) fprintf( stderr
, "ReadDepthSpan\n" );
140 #if HAVE_HW_DEPTH_SPANS
141 (void) x1
; (void) n1
;
148 CLIPSPAN( x
, y
, n
, x1
, n1
, i
);
149 for ( ; n1
>0 ; i
++, n1
-- ) {
150 READ_DEPTH( depth
[i
], x
+i
, y
);
159 static void TAG(ReadDepthPixels
)( struct gl_context
*ctx
,
160 struct gl_renderbuffer
*rb
,
162 const GLint x
[], const GLint y
[],
167 VALUE_TYPE
*depth
= (VALUE_TYPE
*) values
;
171 if ( DBG
) fprintf( stderr
, "ReadDepthPixels\n" );
173 #if HAVE_HW_DEPTH_PIXELS
180 for ( i
= 0 ; i
< n
;i
++ ) {
181 int fy
= Y_FLIP( y
[i
] );
182 if ( CLIPPIXEL( x
[i
], fy
) )
183 READ_DEPTH( depth
[i
], x
[i
], fy
);
196 * Initialize the given renderbuffer's span routines to point to
197 * the depth/z functions we generated above.
199 static void TAG(InitDepthPointers
)(struct gl_renderbuffer
*rb
)
201 rb
->GetRow
= TAG(ReadDepthSpan
);
202 rb
->GetValues
= TAG(ReadDepthPixels
);
203 rb
->PutRow
= TAG(WriteDepthSpan
);
204 rb
->PutValues
= TAG(WriteDepthPixels
);
208 #if HAVE_HW_DEPTH_SPANS
209 #undef WRITE_DEPTH_SPAN
210 #undef WRITE_DEPTH_PIXELS
211 #undef READ_DEPTH_SPAN
212 #undef READ_DEPTH_PIXELS