summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-08-25 19:45:31 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-08-25 19:45:31 +0000
commit473f1aca7f4eb1dbb70e93cc6bf9a555512cd552 (patch)
tree58f4ac17f3078fa826cb5e528841e60d2c111561
parent439d59926ad8581bac74751b73b07268aa47ab65 (diff)
clamp result.depth to [0,1] if written to
-rw-r--r--src/mesa/swrast/s_nvfragprog.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 826e71d45c..97dbed04a8 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1491,7 +1491,12 @@ _swrast_exec_fragment_program( GLcontext *ctx, struct sw_span *span )
if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
const GLfloat depth
= ctx->FragmentProgram.Machine.Outputs[FRAG_RESULT_DEPR][2];
- span->array->z[i] = IROUND(depth * ctx->DrawBuffer->_DepthMaxF);
+ if (depth <= 0.0)
+ span->array->z[i] = 0;
+ else if (depth >= 1.0)
+ span->array->z[i] = ctx->DrawBuffer->_DepthMax;
+ else
+ span->array->z[i] = IROUND(depth * ctx->DrawBuffer->_DepthMaxF);
}
}
}