From 38600c7ac64c84b0a1b8100326fee3317ada4000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 26 May 2018 08:45:00 -0700 Subject: [PATCH] Fixed issue #182. --- include/bx/inline/math.inl | 12 ++++++------ include/bx/inline/simd128_langext.inl | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index cb8cb26..250e79f 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -179,6 +179,11 @@ namespace bx return log(_a) * kInvLogNat2; } + inline BX_CONST_FUNC float rsqrtRef(float _a) + { + return pow(_a, -0.5f); + } + inline BX_CONST_FUNC float sqrtRef(float _a) { if (_a < kNearZero) @@ -186,7 +191,7 @@ namespace bx return 0.0f; } - return 1.0f/rsqrt(_a); + return 1.0f/rsqrtRef(_a); } inline BX_CONST_FUNC float sqrtSimd(float _a) @@ -208,11 +213,6 @@ namespace bx #endif // BX_CONFIG_SUPPORTS_SIMD } - inline BX_CONST_FUNC float rsqrtRef(float _a) - { - return pow(_a, -0.5f); - } - inline BX_CONST_FUNC float rsqrtSimd(float _a) { if (_a < kNearZero) diff --git a/include/bx/inline/simd128_langext.inl b/include/bx/inline/simd128_langext.inl index 457b108..ac08ba7 100644 --- a/include/bx/inline/simd128_langext.inl +++ b/include/bx/inline/simd128_langext.inl @@ -9,7 +9,7 @@ namespace bx { - BX_CONST_FUNC float sqrt(float); + BX_CONST_FUNC float sqrtRef(float); #define ELEMx 0 #define ELEMy 1 @@ -320,10 +320,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf); BX_SIMD_FORCE_INLINE simd128_langext_t simd_sqrt(simd128_langext_t _a) { simd128_langext_t result; - result.vf[0] = sqrt(_a.vf[0]); - result.vf[1] = sqrt(_a.vf[1]); - result.vf[2] = sqrt(_a.vf[2]); - result.vf[3] = sqrt(_a.vf[3]); + result.vf[0] = sqrtRef(_a.vf[0]); + result.vf[1] = sqrtRef(_a.vf[1]); + result.vf[2] = sqrtRef(_a.vf[2]); + result.vf[3] = sqrtRef(_a.vf[3]); return result; } @@ -331,10 +331,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf); BX_SIMD_FORCE_INLINE simd128_langext_t simd_rsqrt_est(simd128_langext_t _a) { simd128_langext_t result; - result.vf[0] = 1.0f / sqrt(_a.vf[0]); - result.vf[1] = 1.0f / sqrt(_a.vf[1]); - result.vf[2] = 1.0f / sqrt(_a.vf[2]); - result.vf[3] = 1.0f / sqrt(_a.vf[3]); + result.vf[0] = 1.0f / sqrtRef(_a.vf[0]); + result.vf[1] = 1.0f / sqrtRef(_a.vf[1]); + result.vf[2] = 1.0f / sqrtRef(_a.vf[2]); + result.vf[3] = 1.0f / sqrtRef(_a.vf[3]); return result; }