Branimir Karadžić 8 years ago
parent
commit
525801cdf8
4 changed files with 16 additions and 16 deletions
  1. 6 6
      include/bx/inline/math.inl
  2. 1 1
      include/bx/math.h
  3. 5 5
      src/math.cpp
  4. 4 4
      tests/simd_bench.cpp

+ 6 - 6
include/bx/inline/math.inl

@@ -154,8 +154,8 @@ namespace bx
 	inline bool fequal(float _a, float _b, float _epsilon)
 	inline bool fequal(float _a, float _b, float _epsilon)
 	{
 	{
 		// http://realtimecollisiondetection.net/blog/?p=89
 		// http://realtimecollisiondetection.net/blog/?p=89
-		const float lhs = fabsolute(_a - _b);
-		const float rhs = _epsilon * fmax3(1.0f, fabsolute(_a), fabsolute(_b) );
+		const float lhs = fabs(_a - _b);
+		const float rhs = _epsilon * fmax3(1.0f, fabs(_a), fabs(_b) );
 		return lhs <= rhs;
 		return lhs <= rhs;
 	}
 	}
 
 
@@ -226,9 +226,9 @@ namespace bx
 
 
 	inline void vec3Abs(float* _result, const float* _a)
 	inline void vec3Abs(float* _result, const float* _a)
 	{
 	{
-		_result[0] = fabsolute(_a[0]);
-		_result[1] = fabsolute(_a[1]);
-		_result[2] = fabsolute(_a[2]);
+		_result[0] = fabs(_a[0]);
+		_result[1] = fabs(_a[1]);
+		_result[2] = fabs(_a[2]);
 	}
 	}
 
 
 	inline void vec3Neg(float* _result, const float* _a)
 	inline void vec3Neg(float* _result, const float* _a)
@@ -348,7 +348,7 @@ namespace bx
 		const float ny = _n[1];
 		const float ny = _n[1];
 		const float nz = _n[2];
 		const float nz = _n[2];
 
 
-		if (bx::fabsolute(nx) > bx::fabsolute(nz) )
+		if (bx::fabs(nx) > bx::fabs(nz) )
 		{
 		{
 			float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz);
 			float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz);
 			_t[0] = -nz * invLen;
 			_t[0] = -nz * invLen;

+ 1 - 1
include/bx/math.h

@@ -113,7 +113,7 @@ namespace bx
 	float fsign(float _a);
 	float fsign(float _a);
 
 
 	///
 	///
-	float fabsolute(float _a);
+	float fabs(float _a);
 
 
 	///
 	///
 	float fsq(float _a);
 	float fsq(float _a);

+ 5 - 5
src/math.cpp

@@ -20,7 +20,7 @@ namespace bx
 	const float kHuge = HUGE_VALF;
 	const float kHuge = HUGE_VALF;
 #endif // BX_COMPILER_MSVC
 #endif // BX_COMPILER_MSVC
 
 
-	float fabsolute(float _a)
+	float fabs(float _a)
 	{
 	{
 		return ::fabsf(_a);
 		return ::fabsf(_a);
 	}
 	}
@@ -719,7 +719,7 @@ namespace bx
 		const float dd = qx - fmin(qw, qy);
 		const float dd = qx - fmin(qw, qy);
 		const float ee = 1.0e-10f;
 		const float ee = 1.0e-10f;
 
 
-		_hsv[0] = fabsolute(qz + (qw - qy) / (6.0f * dd + ee) );
+		_hsv[0] = fabs(qz + (qw - qy) / (6.0f * dd + ee) );
 		_hsv[1] = dd / (qx + ee);
 		_hsv[1] = dd / (qx + ee);
 		_hsv[2] = qx;
 		_hsv[2] = qx;
 	}
 	}
@@ -730,9 +730,9 @@ namespace bx
 		const float ss = _hsv[1];
 		const float ss = _hsv[1];
 		const float vv = _hsv[2];
 		const float vv = _hsv[2];
 
 
-		const float px = fabsolute(ffract(hh + 1.0f     ) * 6.0f - 3.0f);
-		const float py = fabsolute(ffract(hh + 2.0f/3.0f) * 6.0f - 3.0f);
-		const float pz = fabsolute(ffract(hh + 1.0f/3.0f) * 6.0f - 3.0f);
+		const float px = fabs(ffract(hh + 1.0f     ) * 6.0f - 3.0f);
+		const float py = fabs(ffract(hh + 2.0f/3.0f) * 6.0f - 3.0f);
+		const float pz = fabs(ffract(hh + 1.0f/3.0f) * 6.0f - 3.0f);
 
 
 		_rgb[0] = vv * flerp(1.0f, fsaturate(px - 1.0f), ss);
 		_rgb[0] = vv * flerp(1.0f, fsaturate(px - 1.0f), ss);
 		_rgb[1] = vv * flerp(1.0f, fsaturate(py - 1.0f), ss);
 		_rgb[1] = vv * flerp(1.0f, fsaturate(py - 1.0f), ss);

+ 4 - 4
tests/simd_bench.cpp

@@ -121,10 +121,10 @@ void simd_bench()
 	for (uint32_t ii = 0; ii < numVertices; ++ii)
 	for (uint32_t ii = 0; ii < numVertices; ++ii)
 	{
 	{
 		float* ptr = (float*)&src[ii];
 		float* ptr = (float*)&src[ii];
-		ptr[0] = bx::fabsolute(ptr[0]);
-		ptr[1] = bx::fabsolute(ptr[1]);
-		ptr[2] = bx::fabsolute(ptr[2]);
-		ptr[3] = bx::fabsolute(ptr[3]);
+		ptr[0] = bx::fabs(ptr[0]);
+		ptr[1] = bx::fabs(ptr[1]);
+		ptr[2] = bx::fabs(ptr[2]);
+		ptr[3] = bx::fabs(ptr[3]);
 	}
 	}
 
 
 	simd_bench_pass(dst, src, numVertices);
 	simd_bench_pass(dst, src, numVertices);