Reduce math function duplication.

Change-Id: If0fe05eff397c8d88753fb2b1a1852722c73602e
Reviewed-on: https://swiftshader-review.googlesource.com/4979
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Common/Math.hpp b/src/Common/Math.hpp
index 4735a29..47a13f5 100644
--- a/src/Common/Math.hpp
+++ b/src/Common/Math.hpp
@@ -174,6 +174,11 @@
 		return x;

 	}

 

+	inline float clamp01(float x)

+	{

+		return clamp(x, 0.0f, 1.0f);

+	}

+

 	inline int ceilPow2(int x)

 	{

 		int i = 1;

diff --git a/src/OpenGL/libGL/mathutil.h b/src/OpenGL/libGL/mathutil.h
index 1055845..c0856e2 100644
--- a/src/OpenGL/libGL/mathutil.h
+++ b/src/OpenGL/libGL/mathutil.h
@@ -44,16 +44,8 @@
     return x;
 }
 
-template<typename T, typename MIN, typename MAX>
-inline T clamp(T x, MIN min, MAX max)
-{
-    return x < min ? min : (x > max ? max : x);
-}
-
-inline float clamp01(float x)
-{
-    return clamp(x, 0.0f, 1.0f);
-}
+using sw::clamp;
+using sw::clamp01;
 
 template<const int n>
 inline unsigned int unorm(float x)
diff --git a/src/OpenGL/libGLES_CM/mathutil.h b/src/OpenGL/libGLES_CM/mathutil.h
index b88bcca..89c2e54 100644
--- a/src/OpenGL/libGLES_CM/mathutil.h
+++ b/src/OpenGL/libGLES_CM/mathutil.h
@@ -44,16 +44,8 @@
     return x;
 }
 
-template<typename T, typename MIN, typename MAX>
-inline T clamp(T x, MIN min, MAX max)
-{
-    return x < min ? min : (x > max ? max : x);
-}
-
-inline float clamp01(float x)
-{
-    return clamp(x, 0.0f, 1.0f);
-}
+using sw::clamp;
+using sw::clamp01;
 
 template<const int n>
 inline unsigned int unorm(float x)
diff --git a/src/OpenGL/libGLESv2/mathutil.h b/src/OpenGL/libGLESv2/mathutil.h
index 3fbbff5..6e5ddab 100644
--- a/src/OpenGL/libGLESv2/mathutil.h
+++ b/src/OpenGL/libGLESv2/mathutil.h
@@ -44,24 +44,9 @@
     return x;
 }
 
-template<typename T, typename MIN, typename MAX>
-inline T clamp(T x, MIN min, MAX max)
-{
-    return x < min ? min : (x > max ? max : x);
-}
-
-template<class T>
-inline void swap(T &a, T &b)
-{
-	T t = a;
-	a = b;
-	b = t;
-}
-
-inline float clamp01(float x)
-{
-    return clamp(x, 0.0f, 1.0f);
-}
+using sw::swap;
+using sw::clamp;
+using sw::clamp01;
 
 template<const int n>
 inline unsigned int unorm(float x)