gallium/tgsi: use CLAMP instead of open-coded clamps
authorErik Faye-Lund <kusmabite@gmail.com>
Fri, 7 Feb 2014 12:45:10 +0000 (13:45 +0100)
committerBrian Paul <brianp@vmware.com>
Fri, 7 Feb 2014 15:22:14 +0000 (08:22 -0700)
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_exec.c

index 3d37eaafb9dfafdf0473658b6e29793db9c7459b..96809cd03f5d49e44fb06b2e70a0ea199c785479 100644 (file)
@@ -914,28 +914,10 @@ micro_rcc(union tgsi_exec_channel *dst,
    for (i = 0; i < 4; i++) {
       float recip = 1.0f / src->f[i];
 
-      if (recip > 0.0f) {
-         if (recip > 1.884467e+019f) {
-            dst->f[i] = 1.884467e+019f;
-         }
-         else if (recip < 5.42101e-020f) {
-            dst->f[i] = 5.42101e-020f;
-         }
-         else {
-            dst->f[i] = recip;
-         }
-      }
-      else {
-         if (recip < -1.884467e+019f) {
-            dst->f[i] = -1.884467e+019f;
-         }
-         else if (recip > -5.42101e-020f) {
-            dst->f[i] = -5.42101e-020f;
-         }
-         else {
-            dst->f[i] = recip;
-         }
-      }
+      if (recip > 0.0f)
+         dst->f[i] = CLAMP(recip, 5.42101e-020f, 1.884467e+019f);
+      else
+         dst->f[i] = CLAMP(recip, -1.884467e+019f, -5.42101e-020f);
    }
 }