Branimir Karadžić 9 лет назад
Родитель
Сommit
bb15438be4
9 измененных файлов с 34 добавлено и 46 удалено
  1. 0 1
      include/bx/fpumath.h
  2. 12 16
      include/bx/fpumath.inl
  3. 4 4
      include/bx/radixsort.inl
  4. 8 10
      include/bx/simd128_ref.inl
  5. 1 0
      include/bx/simd_t.h
  6. 0 2
      include/bx/timer.h
  7. 4 4
      src/dtoa.cpp
  8. 2 2
      src/os.cpp
  9. 3 7
      src/timer.cpp

+ 0 - 1
include/bx/fpumath.h

@@ -10,7 +10,6 @@
 
 
 #include "bx.h"
 #include "bx.h"
 #include <math.h>
 #include <math.h>
-#include <string.h>
 
 
 namespace bx
 namespace bx
 {
 {

+ 12 - 16
include/bx/fpumath.inl

@@ -9,10 +9,6 @@
 #	error "Must be included from bx/fpumath.h!"
 #	error "Must be included from bx/fpumath.h!"
 #endif // BX_FPU_MATH_H_HEADER_GUARD
 #endif // BX_FPU_MATH_H_HEADER_GUARD
 
 
-#include "bx.h"
-#include <math.h>
-#include <string.h>
-
 namespace bx
 namespace bx
 {
 {
 	inline float toRad(float _deg)
 	inline float toRad(float _deg)
@@ -597,7 +593,7 @@ namespace bx
 
 
 	inline void mtxIdentity(float* _result)
 	inline void mtxIdentity(float* _result)
 	{
 	{
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[0] = _result[5] = _result[10] = _result[15] = 1.0f;
 		_result[0] = _result[5] = _result[10] = _result[15] = 1.0f;
 	}
 	}
 
 
@@ -611,7 +607,7 @@ namespace bx
 
 
 	inline void mtxScale(float* _result, float _sx, float _sy, float _sz)
 	inline void mtxScale(float* _result, float _sx, float _sy, float _sz)
 	{
 	{
-		memset(_result, 0, sizeof(float) * 16);
+		memSet(_result, 0, sizeof(float) * 16);
 		_result[0]  = _sx;
 		_result[0]  = _sx;
 		_result[5]  = _sy;
 		_result[5]  = _sy;
 		_result[10] = _sz;
 		_result[10] = _sz;
@@ -738,7 +734,7 @@ namespace bx
 
 
 		vec3Cross(up, _view, right);
 		vec3Cross(up, _view, right);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = right[0];
 		_result[ 0] = right[0];
 		_result[ 1] = up[0];
 		_result[ 1] = up[0];
 		_result[ 2] = _view[0];
 		_result[ 2] = _view[0];
@@ -791,7 +787,7 @@ namespace bx
 		const float aa = _oglNdc ?       (_far+_near)/diff : _far/diff;
 		const float aa = _oglNdc ?       (_far+_near)/diff : _far/diff;
 		const float bb = _oglNdc ?  (2.0f*_far*_near)/diff : _near*aa;
 		const float bb = _oglNdc ?  (2.0f*_far*_near)/diff : _near*aa;
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = _width;
 		_result[ 0] = _width;
 		_result[ 5] = _height;
 		_result[ 5] = _height;
 		_result[ 8] = (Handness::Right == HandnessT) ?    _x :  -_x;
 		_result[ 8] = (Handness::Right == HandnessT) ?    _x :  -_x;
@@ -888,7 +884,7 @@ namespace bx
 			bb = _oglNdc ? 2.0f*_near : _near;
 			bb = _oglNdc ? 2.0f*_near : _near;
 		}
 		}
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = _width;
 		_result[ 0] = _width;
 		_result[ 5] = _height;
 		_result[ 5] = _height;
 		_result[ 8] = (Handness::Right == HandnessT) ?    _x :  -_x;
 		_result[ 8] = (Handness::Right == HandnessT) ?    _x :  -_x;
@@ -1009,7 +1005,7 @@ namespace bx
 		const float ee = (_top + _bottom)/(_bottom - _top);
 		const float ee = (_top + _bottom)/(_bottom - _top);
 		const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
 		const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = aa;
 		_result[ 0] = aa;
 		_result[ 5] = bb;
 		_result[ 5] = bb;
 		_result[10] = (Handness::Right == HandnessT) ? -cc : cc;
 		_result[10] = (Handness::Right == HandnessT) ? -cc : cc;
@@ -1039,7 +1035,7 @@ namespace bx
 		const float sx = fsin(_ax);
 		const float sx = fsin(_ax);
 		const float cx = fcos(_ax);
 		const float cx = fcos(_ax);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = 1.0f;
 		_result[ 0] = 1.0f;
 		_result[ 5] = cx;
 		_result[ 5] = cx;
 		_result[ 6] = -sx;
 		_result[ 6] = -sx;
@@ -1053,7 +1049,7 @@ namespace bx
 		const float sy = fsin(_ay);
 		const float sy = fsin(_ay);
 		const float cy = fcos(_ay);
 		const float cy = fcos(_ay);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = cy;
 		_result[ 0] = cy;
 		_result[ 2] = sy;
 		_result[ 2] = sy;
 		_result[ 5] = 1.0f;
 		_result[ 5] = 1.0f;
@@ -1067,7 +1063,7 @@ namespace bx
 		const float sz = fsin(_az);
 		const float sz = fsin(_az);
 		const float cz = fcos(_az);
 		const float cz = fcos(_az);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = cz;
 		_result[ 0] = cz;
 		_result[ 1] = -sz;
 		_result[ 1] = -sz;
 		_result[ 4] = sz;
 		_result[ 4] = sz;
@@ -1083,7 +1079,7 @@ namespace bx
 		const float sy = fsin(_ay);
 		const float sy = fsin(_ay);
 		const float cy = fcos(_ay);
 		const float cy = fcos(_ay);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = cy;
 		_result[ 0] = cy;
 		_result[ 2] = sy;
 		_result[ 2] = sy;
 		_result[ 4] = sx*sy;
 		_result[ 4] = sx*sy;
@@ -1104,7 +1100,7 @@ namespace bx
 		const float sz = fsin(_az);
 		const float sz = fsin(_az);
 		const float cz = fcos(_az);
 		const float cz = fcos(_az);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = cy*cz;
 		_result[ 0] = cy*cz;
 		_result[ 1] = -cy*sz;
 		_result[ 1] = -cy*sz;
 		_result[ 2] = sy;
 		_result[ 2] = sy;
@@ -1126,7 +1122,7 @@ namespace bx
 		const float sz = fsin(_az);
 		const float sz = fsin(_az);
 		const float cz = fcos(_az);
 		const float cz = fcos(_az);
 
 
-		memset(_result, 0, sizeof(float)*16);
+		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = cy*cz;
 		_result[ 0] = cy*cz;
 		_result[ 1] = cz*sx*sy-cx*sz;
 		_result[ 1] = cz*sx*sy-cx*sz;
 		_result[ 2] = cx*cz*sy+sx*sz;
 		_result[ 2] = cx*cz*sy+sx*sz;

+ 4 - 4
include/bx/radixsort.inl

@@ -23,7 +23,7 @@ namespace bx
 		uint32_t pass = 0;
 		uint32_t pass = 0;
 		for (; pass < 3; ++pass)
 		for (; pass < 3; ++pass)
 		{
 		{
-			memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+			memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
 
 
 			bool sorted = true;
 			bool sorted = true;
 			{
 			{
@@ -87,7 +87,7 @@ done:
 		uint32_t pass = 0;
 		uint32_t pass = 0;
 		for (; pass < 3; ++pass)
 		for (; pass < 3; ++pass)
 		{
 		{
-			memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+			memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
 
 
 			bool sorted = true;
 			bool sorted = true;
 			{
 			{
@@ -157,7 +157,7 @@ done:
 		uint32_t pass = 0;
 		uint32_t pass = 0;
 		for (; pass < 6; ++pass)
 		for (; pass < 6; ++pass)
 		{
 		{
-			memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+			memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
 
 
 			bool sorted = true;
 			bool sorted = true;
 			{
 			{
@@ -221,7 +221,7 @@ done:
 		uint32_t pass = 0;
 		uint32_t pass = 0;
 		for (; pass < 6; ++pass)
 		for (; pass < 6; ++pass)
 		{
 		{
-			memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+			memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
 
 
 			bool sorted = true;
 			bool sorted = true;
 			{
 			{

+ 8 - 10
include/bx/simd128_ref.inl

@@ -6,8 +6,6 @@
 #ifndef BX_SIMD128_REF_H_HEADER_GUARD
 #ifndef BX_SIMD128_REF_H_HEADER_GUARD
 #define BX_SIMD128_REF_H_HEADER_GUARD
 #define BX_SIMD128_REF_H_HEADER_GUARD
 
 
-#include <math.h> // sqrtf
-
 #define simd_shuf_xAzC simd_shuf_xAzC_ni
 #define simd_shuf_xAzC simd_shuf_xAzC_ni
 #define simd_shuf_yBwD simd_shuf_yBwD_ni
 #define simd_shuf_yBwD simd_shuf_yBwD_ni
 #define simd_rcp simd_rcp_ni
 #define simd_rcp simd_rcp_ni
@@ -396,10 +394,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf);
 	BX_SIMD_FORCE_INLINE simd128_ref_t simd_sqrt(simd128_ref_t _a)
 	BX_SIMD_FORCE_INLINE simd128_ref_t simd_sqrt(simd128_ref_t _a)
 	{
 	{
 		simd128_ref_t result;
 		simd128_ref_t result;
-		result.fxyzw[0] = sqrtf(_a.fxyzw[0]);
-		result.fxyzw[1] = sqrtf(_a.fxyzw[1]);
-		result.fxyzw[2] = sqrtf(_a.fxyzw[2]);
-		result.fxyzw[3] = sqrtf(_a.fxyzw[3]);
+		result.fxyzw[0] = fsqrt(_a.fxyzw[0]);
+		result.fxyzw[1] = fsqrt(_a.fxyzw[1]);
+		result.fxyzw[2] = fsqrt(_a.fxyzw[2]);
+		result.fxyzw[3] = fsqrt(_a.fxyzw[3]);
 		return result;
 		return result;
 	}
 	}
 
 
@@ -407,10 +405,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf);
 	BX_SIMD_FORCE_INLINE simd128_ref_t simd_rsqrt_est(simd128_ref_t _a)
 	BX_SIMD_FORCE_INLINE simd128_ref_t simd_rsqrt_est(simd128_ref_t _a)
 	{
 	{
 		simd128_ref_t result;
 		simd128_ref_t result;
-		result.fxyzw[0] = 1.0f / sqrtf(_a.fxyzw[0]);
-		result.fxyzw[1] = 1.0f / sqrtf(_a.fxyzw[1]);
-		result.fxyzw[2] = 1.0f / sqrtf(_a.fxyzw[2]);
-		result.fxyzw[3] = 1.0f / sqrtf(_a.fxyzw[3]);
+		result.fxyzw[0] = 1.0f / fsqrt(_a.fxyzw[0]);
+		result.fxyzw[1] = 1.0f / fsqrt(_a.fxyzw[1]);
+		result.fxyzw[2] = 1.0f / fsqrt(_a.fxyzw[2]);
+		result.fxyzw[3] = 1.0f / fsqrt(_a.fxyzw[3]);
 		return result;
 		return result;
 	}
 	}
 
 

+ 1 - 0
include/bx/simd_t.h

@@ -7,6 +7,7 @@
 #define BX_SIMD_T_H_HEADER_GUARD
 #define BX_SIMD_T_H_HEADER_GUARD
 
 
 #include "bx.h"
 #include "bx.h"
+#include "fpumath.h"
 
 
 #define BX_SIMD_FORCE_INLINE BX_FORCE_INLINE
 #define BX_SIMD_FORCE_INLINE BX_FORCE_INLINE
 #define BX_SIMD_INLINE inline
 #define BX_SIMD_INLINE inline

+ 0 - 2
include/bx/timer.h

@@ -18,6 +18,4 @@ namespace bx
 
 
 } // namespace bx
 } // namespace bx
 
 
-#include "timer.inl"
-
 #endif // BX_TIMER_H_HEADER_GUARD
 #endif // BX_TIMER_H_HEADER_GUARD

+ 4 - 4
src/dtoa.cpp

@@ -384,7 +384,7 @@ namespace bx
 		if (0 < kk && kk <= 21)
 		if (0 < kk && kk <= 21)
 		{
 		{
 			// 1234e-2 -> 12.34
 			// 1234e-2 -> 12.34
-			memmove(&buffer[kk + 1], &buffer[kk], length - kk);
+			memMove(&buffer[kk + 1], &buffer[kk], length - kk);
 			buffer[kk] = '.';
 			buffer[kk] = '.';
 			buffer[length + 1] = '\0';
 			buffer[length + 1] = '\0';
 			return length + 1;
 			return length + 1;
@@ -394,7 +394,7 @@ namespace bx
 		{
 		{
 			// 1234e-6 -> 0.001234
 			// 1234e-6 -> 0.001234
 			const int32_t offset = 2 - kk;
 			const int32_t offset = 2 - kk;
-			memmove(&buffer[offset], &buffer[0], length);
+			memMove(&buffer[offset], &buffer[0], length);
 			buffer[0] = '0';
 			buffer[0] = '0';
 			buffer[1] = '.';
 			buffer[1] = '.';
 			for (int32_t i = 2; i < offset; i++)
 			for (int32_t i = 2; i < offset; i++)
@@ -415,7 +415,7 @@ namespace bx
 		}
 		}
 
 
 		// 1234e30 -> 1.234e33
 		// 1234e30 -> 1.234e33
-		memmove(&buffer[2], &buffer[1], length - 1);
+		memMove(&buffer[2], &buffer[1], length - 1);
 		buffer[1] = '.';
 		buffer[1] = '.';
 		buffer[length + 1] = 'e';
 		buffer[length + 1] = 'e';
 		int32_t exp = WriteExponent(kk - 1, &buffer[length + 2]);
 		int32_t exp = WriteExponent(kk - 1, &buffer[length + 2]);
@@ -520,7 +520,7 @@ namespace bx
 
 
 		reverse(data, len);
 		reverse(data, len);
 
 
-		memcpy(_dst, data, len);
+		memCopy(_dst, data, len);
 		_dst[len] = '\0';
 		_dst[len] = '\0';
 		return int32_t(len);
 		return int32_t(len);
 	}
 	}

+ 2 - 2
src/os.cpp

@@ -406,11 +406,11 @@ namespace bx
 		return (void*)uintptr_t(pid);
 		return (void*)uintptr_t(pid);
 #elif BX_PLATFORM_WINDOWS
 #elif BX_PLATFORM_WINDOWS
 		STARTUPINFO si;
 		STARTUPINFO si;
-		memset(&si, 0, sizeof(STARTUPINFO) );
+		memSet(&si, 0, sizeof(STARTUPINFO) );
 		si.cb = sizeof(STARTUPINFO);
 		si.cb = sizeof(STARTUPINFO);
 
 
 		PROCESS_INFORMATION pi;
 		PROCESS_INFORMATION pi;
-		memset(&pi, 0, sizeof(PROCESS_INFORMATION) );
+		memSet(&pi, 0, sizeof(PROCESS_INFORMATION) );
 
 
 		int32_t total = 0;
 		int32_t total = 0;
 		for (uint32_t ii = 0; NULL != _argv[ii]; ++ii)
 		for (uint32_t ii = 0; NULL != _argv[ii]; ++ii)

+ 3 - 7
include/bx/timer.inl → src/timer.cpp

@@ -3,11 +3,7 @@
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
-#ifndef BX_TIMER_H_HEADER_GUARD
-#	error "Must be included from bx/timer.h!"
-#endif // BX_TIMER_H_HEADER_GUARD
-
-#include "bx.h"
+#include <bx/timer.h>
 
 
 #if BX_PLATFORM_ANDROID
 #if BX_PLATFORM_ANDROID
 #	include <time.h> // clock, clock_gettime
 #	include <time.h> // clock, clock_gettime
@@ -21,7 +17,7 @@
 
 
 namespace bx
 namespace bx
 {
 {
-	inline int64_t getHPCounter()
+	int64_t getHPCounter()
 	{
 	{
 #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
 #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
 		LARGE_INTEGER li;
 		LARGE_INTEGER li;
@@ -43,7 +39,7 @@ namespace bx
 		return i64;
 		return i64;
 	}
 	}
 
 
-	inline int64_t getHPFrequency()
+	int64_t getHPFrequency()
 	{
 	{
 #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
 #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
 		LARGE_INTEGER li;
 		LARGE_INTEGER li;