}
}
else {
- gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format);
+ mesa_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format);
const GLint bpp = _mesa_get_format_bytes(rb->Format);
const GLint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
zBufferVals = zStart;
}
else {
- if (_mesa_get_format_datatype(rb->Format) != GL_UNSIGNED_NORMALIZED) {
- _mesa_problem(ctx, "Incorrectly writing swrast's integer depth "
- "values to %s depth buffer",
- _mesa_get_format_name(rb->Format));
- }
-
/* copy Z buffer values into temp buffer (32-bit Z values) */
zBufferTemp = malloc(count * sizeof(GLuint));
if (!zBufferTemp)
}
else {
/* horizontal row */
- gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format);
+ mesa_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format);
GLubyte *dst = zStart;
GLuint i;
for (i = 0; i < count; i++) {
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
GLubyte *zStart;
- GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F);
- GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F);
+ GLuint zMin = (GLuint)((double)ctx->Depth.BoundsMin * 0xffffffff);
+ GLuint zMax = (GLuint)((double)ctx->Depth.BoundsMax * 0xffffffff);
GLubyte *mask = span->array->mask;
const GLuint count = span->end;
GLuint i;
zBufferVals = (const GLuint *) zStart;
}
else {
+ /* Round the bounds to the precision of the zbuffer. */
+ if (rb->Format == MESA_FORMAT_Z_UNORM16) {
+ zMin = (zMin & 0xffff0000) | (zMin >> 16);
+ zMax = (zMax & 0xffff0000) | (zMax >> 16);
+ } else {
+ /* 24 bits */
+ zMin = (zMin & 0xffffff00) | (zMin >> 24);
+ zMax = (zMax & 0xffffff00) | (zMax >> 24);
+ }
+
/* unpack Z values into a temporary array */
if (span->arrayMask & SPAN_XY) {
get_z32_values(ctx, rb, count, span->array->x, span->array->y,
}
ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height,
- mapMode, &map, &rowStride);
+ mapMode, &map, &rowStride,
+ ctx->DrawBuffer->FlipY);
if (!map) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glClear(depth)");
return;
}
ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height,
- mapMode, &map, &rowStride);
+ mapMode, &map, &rowStride,
+ ctx->DrawBuffer->FlipY);
if (!map) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glClear(depth+stencil)");
return;