summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_depth.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2009-10-28 16:35:16 -0700
committerEric Anholt <[email protected]>2009-10-29 10:01:17 -0700
commit32ec3f26731ac998b6fda7ce596ec568d6f76eeb (patch)
tree9e19761b9b67db1bbdebdf44f075d672bf7f4686 /src/mesa/swrast/s_depth.c
parent6eb6a0e9cbed6ba5543d54e277f7ac11a0612070 (diff)
mesa: Mostly fix swrast's ARB_depth_clamp support.
I'd written a testcase for the hard part of the extension enablement, so naturally the easy stuff was completely broken. There are still issues, as I'm seeing FLOAT_TO_UINT(max_f) == 0x0 when max_f == 1.0, but it gets piglit depth-clamp-range closer to success.
Diffstat (limited to 'src/mesa/swrast/s_depth.c')
-rw-r--r--src/mesa/swrast/s_depth.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 393590c6734..c37a54eb3eb 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -506,22 +506,32 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span )
struct gl_renderbuffer *rb = fb->_DepthBuffer;
const GLuint count = span->end;
GLuint *zValues = span->array->z;
- GLuint near, far;
+ GLuint min, max;
+ GLfloat min_f, max_f;
int i;
+ if (ctx->Viewport.Near < ctx->Viewport.Far) {
+ min_f = ctx->Viewport.Near;
+ max_f = ctx->Viewport.Far;
+ } else {
+ min_f = ctx->Viewport.Far;
+ max_f = ctx->Viewport.Near;
+ }
+
if (rb->DataType == GL_UNSIGNED_SHORT) {
- near = FLOAT_TO_UINT(ctx->Viewport.Near);
- far = FLOAT_TO_UINT(ctx->Viewport.Far);
+ CLAMPED_FLOAT_TO_USHORT(min, min_f);
+ CLAMPED_FLOAT_TO_USHORT(max, max_f);
} else {
assert(rb->DataType == GL_UNSIGNED_INT);
- CLAMPED_FLOAT_TO_USHORT(near, ctx->Viewport.Near);
- CLAMPED_FLOAT_TO_USHORT(far, ctx->Viewport.Far);
+ min = FLOAT_TO_UINT(min_f);
+ max = FLOAT_TO_UINT(max_f);
}
+
for (i = 0; i < count; i++) {
- if (zValues[i] < near)
- zValues[i] = near;
- if (zValues[i] > far)
- zValues[i] = far;
+ if (zValues[i] < min)
+ zValues[i] = min;
+ if (zValues[i] > max)
+ zValues[i] = max;
}
}