summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_depth.c
diff options
context:
space:
mode:
authorNicolai Hähnle <nhaehnle@gmail.com>2009-09-21 13:26:50 +0200
committerNicolai Hähnle <nhaehnle@gmail.com>2009-09-21 13:26:50 +0200
commit81c7561d9d3faf70ac22c6a5f3fbea18f53eed92 (patch)
tree5ec097e0e1fe99804104d3a56923c16edf1533aa /src/mesa/swrast/s_depth.c
parentf02f63997ce65530788a6dfcb28f11790a14d938 (diff)
parent3083ba38f4c884b32cd0460607b5064b6b7008d2 (diff)
Merge branch 'master' into r300-compiler
There were additional non-textual conflicts. Conflicts: src/gallium/drivers/r300/r300_tgsi_to_rc.c src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c src/mesa/drivers/dri/r300/compiler/radeon_program.c src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c
Diffstat (limited to 'src/mesa/swrast/s_depth.c')
-rw-r--r--src/mesa/swrast/s_depth.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 26e23f02d5..1a428fb1a2 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -497,6 +497,33 @@ depth_test_span32( GLcontext *ctx, GLuint n,
return passed;
}
+/* Apply ARB_depth_clamp to span of fragments. */
+void
+_swrast_depth_clamp_span( GLcontext *ctx, SWspan *span )
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->_DepthBuffer;
+ const GLuint count = span->end;
+ GLuint *zValues = span->array->z;
+ GLuint near, far;
+ int i;
+
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ near = FLOAT_TO_UINT(ctx->Viewport.Near);
+ far = FLOAT_TO_UINT(ctx->Viewport.Far);
+ } else {
+ assert(rb->DataType == GL_UNSIGNED_INT);
+ CLAMPED_FLOAT_TO_USHORT(near, ctx->Viewport.Near);
+ CLAMPED_FLOAT_TO_USHORT(far, ctx->Viewport.Far);
+ }
+ for (i = 0; i < count; i++) {
+ if (zValues[i] < near)
+ zValues[i] = near;
+ if (zValues[i] > far)
+ zValues[i] = far;
+ }
+}
+
/*