summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-11-23 11:32:58 +0100
committerMichal Krol <michal@vmware.com>2009-11-23 11:32:58 +0100
commitc511e0b8442f0ddd4265137446180d5ced3f1671 (patch)
treef79df0cffb1a82db91990c8d7bcbcaf1e3f9ca96
parenteacdd8fa75d83ed1e3e2d7c003cea857a310bffd (diff)
tgsi: Clamp the source argument in micro_exp2() to avoid Inf.
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index d52c94fcfa..af914f6d08 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -578,6 +578,24 @@ micro_exp2(
dst->f[2] = util_fast_exp2( src->f[2] );
dst->f[3] = util_fast_exp2( src->f[3] );
#else
+
+#if DEBUG
+ /* Inf is okay for this instruction, so clamp it to silence assertions. */
+ uint i;
+ union tgsi_exec_channel clamped;
+
+ for (i = 0; i < 4; i++) {
+ if (src->f[i] > 127.99999f) {
+ clamped.f[i] = 127.99999f;
+ } else if (src->f[i] < -126.99999f) {
+ clamped.f[i] = -126.99999f;
+ } else {
+ clamped.f[i] = src->f[i];
+ }
+ }
+ src = &clamped;
+#endif
+
dst->f[0] = powf( 2.0f, src->f[0] );
dst->f[1] = powf( 2.0f, src->f[1] );
dst->f[2] = powf( 2.0f, src->f[2] );