/**
* Get array of 32-bit z values from the depth buffer. With clipping.
+ * Note: the returned values are always in the range [0, 2^32-1].
*/
static void
get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
}
}
+
+/**
+ * Put an array of 32-bit z values into the depth buffer.
+ * Note: the z values are always in the range [0, 2^32-1].
+ */
static void
put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
void *zBufferVals;
GLuint *zBufferTemp = NULL;
GLuint passed;
+ GLuint zBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS);
GLboolean ztest16 = GL_FALSE;
- GLboolean ztest24 = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS) == 24;
if (rb->Format == MESA_FORMAT_Z16 && !(span->arrayMask & SPAN_XY)) {
/* directly read/write row of 16-bit Z values */
_mesa_unpack_uint_z_row(rb->Format, count, zStart, zBufferTemp);
}
- if (ztest24) {
+ if (zBits == 24) {
GLuint i;
/* Convert depth buffer values from 32 to 24 bits to match the
* fragment Z values generated by rasterization.
zBufferTemp[i] >>= 8;
}
}
+ else if (zBits == 16) {
+ GLuint i;
+ /* Convert depth buffer values from 32 to 16 bits */
+ for (i = 0; i < count; i++) {
+ zBufferTemp[i] >>= 16;
+ }
+ }
+ else {
+ assert(zBits == 32);
+ }
zBufferVals = zBufferTemp;
}
if (zBufferTemp) {
/* need to write temp Z values back into the buffer */
- if (ztest24) {
+ /* Convert depth buffer values back to 32-bit values. The least
+ * significant bits don't matter since they'll get dropped when
+ * they're packed back into the depth buffer.
+ */
+ if (zBits == 24) {
GLuint i;
- /* Convert depth buffer values back to 32-bit values. The least
- * significant bits don't matter since they'll get dropped when
- * they're packed back into the depth buffer.
- */
for (i = 0; i < count; i++) {
zBufferTemp[i] = (zBufferTemp[i] << 8);
}
}
+ else if (zBits == 16) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ zBufferTemp[i] = zBufferTemp[i] << 16;
+ }
+ }
if (span->arrayMask & SPAN_XY) {
/* random locations */