Browse Source

Added ULP comparison between lowp and highp for inversesqrt

Christophe Riccio 12 years ago
parent
commit
71035db795
1 changed files with 28 additions and 2 deletions
  1. 28 2
      test/core/core_func_exponential.cpp

+ 28 - 2
test/core/core_func_exponential.cpp

@@ -7,12 +7,38 @@
 // File    : test/core/func_exponential.cpp
 // File    : test/core/func_exponential.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 
+#include <glm/common.hpp>
 #include <glm/exponential.hpp>
 #include <glm/exponential.hpp>
+#include <glm/gtc/ulp.hpp>
+
+namespace inversesqrt
+{
+	int test()
+	{
+		int Error(0);
+
+		glm::uint ulp(0);
+		float diff(0.0f);
+
+		for(float f = 0.001f; f < 10.f; f *= 1.001f)
+		{
+			glm::lowp_fvec1 lowp_v = glm::inversesqrt(glm::lowp_fvec1(f));
+			float defaultp_v = glm::inversesqrt(f);
+
+			ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
+			diff = glm::abs(lowp_v.x - defaultp_v);
+		}
+
+		return Error;
+	}
+}//namespace inversesqrt
 
 
 int main()
 int main()
 {
 {
-	int Failed = 0;
+	int Error(0);
+
+	Error += inversesqrt::test();
 
 
-	return Failed;
+	return Error;
 }
 }