From 1deafdb1dec24c2920ab92098f1433273b2ccbdd Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 10 Jul 2007 13:53:21 -0600 Subject: Do depth testing with integer values. Using floats (and float->ushort->float conversion) introduces errors. Only GLushort depth buffers work for now... --- src/mesa/drivers/x11/xm_surface.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 30c9049cbf..5158e42d9a 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -43,6 +43,7 @@ #include "renderbuffer.h" #include "pipe/p_state.h" +#include "pipe/p_defines.h" #include "pipe/softpipe/sp_context.h" #include "pipe/softpipe/sp_surface.h" @@ -245,7 +246,7 @@ xmesa_get_color_surface(GLcontext *ctx, GLuint buf) static void read_quad_z(struct softpipe_surface *sps, - GLint x, GLint y, GLfloat zzzz[QUAD_SIZE]) + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { struct xmesa_surface *xmsurf = xmesa_surface(sps); struct gl_renderbuffer *rb = xmsurf->rb; @@ -254,22 +255,24 @@ read_quad_z(struct softpipe_surface *sps, GET_CURRENT_CONTEXT(ctx); rb->GetRow(ctx, rb, 2, x, y, temp); rb->GetRow(ctx, rb, 2, x, y + 1, temp + 2); + /* convert from GLushort to GLuint */ for (i = 0; i < 4; i++) { - zzzz[i] = USHORT_TO_FLOAT(temp[i]); + zzzz[i] = temp[i]; } } static void write_quad_z(struct softpipe_surface *sps, - GLint x, GLint y, const GLfloat zzzz[QUAD_SIZE]) + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { struct xmesa_surface *xmsurf = xmesa_surface(sps); struct gl_renderbuffer *rb = xmsurf->rb; GLushort temp[4]; GLuint i; GET_CURRENT_CONTEXT(ctx); + /* convert from GLuint to GLushort */ for (i = 0; i < 4; i++) { - CLAMPED_FLOAT_TO_USHORT(temp[i], zzzz[i]); + temp[i] = zzzz[i]; } rb->PutRow(ctx, rb, 2, x, y, temp, NULL); rb->PutRow(ctx, rb, 2, x, y + 1, temp + 2, NULL); @@ -283,6 +286,7 @@ create_z_surface(XMesaContext xmctx, struct gl_renderbuffer *rb) xmsurf = CALLOC_STRUCT(xmesa_surface); if (xmsurf) { + xmsurf->sps.surface.format = PIPE_FORMAT_U_Z16; xmsurf->sps.surface.width = rb->Width; xmsurf->sps.surface.height = rb->Height; xmsurf->sps.read_quad_z = read_quad_z; -- cgit v1.2.3