This commit is contained in:
Бранимир Караџић
2024-10-26 08:25:54 -07:00
parent cc5a21ef3d
commit 6e87e0438c
4 changed files with 45 additions and 25 deletions

View File

@@ -40,7 +40,7 @@ namespace bx
BX_SIMD_INLINE void float4x4_mul(float4x4_t* _result, const float4x4_t* _a, const float4x4_t* _b)
{
#if BX_CONFIG_SUPPORTS_SIMD
#if BX_SIMD_SUPPORTED
_result->col[0] = simd_mul(_a->col[0], _b);
_result->col[1] = simd_mul(_a->col[1], _b);
_result->col[2] = simd_mul(_a->col[2], _b);
@@ -69,12 +69,12 @@ namespace bx
rr[13] = aa[12]*bb[ 1] + aa[13]*bb[ 5] + aa[14]*bb[ 9] + aa[15]*bb[13];
rr[14] = aa[12]*bb[ 2] + aa[13]*bb[ 6] + aa[14]*bb[10] + aa[15]*bb[14];
rr[15] = aa[12]*bb[ 3] + aa[13]*bb[ 7] + aa[14]*bb[11] + aa[15]*bb[15];
#endif // BX_CONFIG_SUPPORTS_SIMD
#endif // BX_SIMD_SUPPORTED
}
BX_SIMD_INLINE void model4x4_mul(float4x4_t* _result, const float4x4_t* _a, const float4x4_t* _b)
{
#if BX_CONFIG_SUPPORTS_SIMD
#if BX_SIMD_SUPPORTED
// With SIMD faster to do the general 4x4 form:
float4x4_mul(_result, _a, _b);
#else
@@ -101,12 +101,12 @@ namespace bx
rr[13] = aa[12]*bb[ 1] + aa[13]*bb[ 5] + aa[14]*bb[ 9] + bb[13];
rr[14] = aa[12]*bb[ 2] + aa[13]*bb[ 6] + aa[14]*bb[10] + bb[14];
rr[15] = 1.0f;
#endif // BX_CONFIG_SUPPORTS_SIMD
#endif // BX_SIMD_SUPPORTED
}
BX_SIMD_INLINE void model4x4_mul_viewproj4x4(float4x4_t* _result, const float4x4_t* _model, const float4x4_t* _viewProj)
{
#if BX_CONFIG_SUPPORTS_SIMD
#if BX_SIMD_SUPPORTED
// With SIMD faster to do the general 4x4 form:
float4x4_mul(_result, _model, _viewProj);
#else
@@ -132,7 +132,7 @@ namespace bx
rr[13] = aa[12]*bb[ 1] + aa[13]*bb[ 5] + aa[14]*bb[ 9] + bb[13];
rr[14] = aa[12]*bb[ 2] + aa[13]*bb[ 6] + aa[14]*bb[10] + bb[14];
rr[15] = aa[12]*bb[ 3] + aa[13]*bb[ 7] + aa[14]*bb[11] + bb[15];
#endif // BX_CONFIG_SUPPORTS_SIMD
#endif // BX_SIMD_SUPPORTED
}
BX_SIMD_FORCE_INLINE void float4x4_transpose(float4x4_t* _result, const float4x4_t* _mtx)

View File

@@ -471,20 +471,20 @@ namespace bx
inline BX_CONST_FUNC float rsqrt(float _a)
{
#if BX_CONFIG_SUPPORTS_SIMD
#if BX_SIMD_SUPPORTED
return rsqrtSimd(_a);
#else
return rsqrtRef(_a);
#endif // BX_CONFIG_SUPPORTS_SIMD
#endif // BX_SIMD_SUPPORTED
}
inline BX_CONST_FUNC float sqrt(float _a)
{
#if BX_CONFIG_SUPPORTS_SIMD
#if BX_SIMD_SUPPORTED
return sqrtSimd(_a);
#else
return sqrtRef(_a);
#endif // BX_CONFIG_SUPPORTS_SIMD
#endif // BX_SIMD_SUPPORTED
}
inline BX_CONSTEXPR_FUNC float trunc(float _a)

View File

@@ -16,7 +16,7 @@
#define BX_SIMD_NEON 0
#define BX_SIMD_SSE 0
#define BX_CONFIG_SUPPORTS_SIMD 0
#define BX_SIMD_SUPPORTED 0
#if defined(__AVX__) || defined(__AVX2__)
# include <immintrin.h>
@@ -36,15 +36,24 @@
# include <arm_neon.h>
# undef BX_SIMD_NEON
# define BX_SIMD_NEON 1
#elif BX_COMPILER_CLANG \
#elif BX_COMPILER_CLANG \
&& !BX_PLATFORM_EMSCRIPTEN \
&& !BX_PLATFORM_IOS \
&& !BX_PLATFORM_VISIONOS \
&& !BX_PLATFORM_IOS \
&& !BX_PLATFORM_VISIONOS \
&& BX_CLANG_HAS_EXTENSION(attribute_ext_vector_type)
# undef BX_SIMD_LANGEXT
# define BX_SIMD_LANGEXT 1
#endif //
#if ( BX_SIMD_AVX \
|| BX_SIMD_LANGEXT \
|| BX_SIMD_NEON \
|| BX_SIMD_SSE \
)
# undef BX_SIMD_SUPPORTED
# define BX_SIMD_SUPPORTED 1
#endif // BX_SIMD_*
namespace bx
{
#define ELEMx 0
@@ -492,15 +501,6 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw);
# include "inline/simd128_sse.inl"
#endif // BX_SIMD_SSE
#if ( BX_SIMD_LANGEXT \
|| BX_SIMD_NEON \
|| BX_SIMD_SSE \
|| BX_SIMD_AVX \
)
# undef BX_CONFIG_SUPPORTS_SIMD
# define BX_CONFIG_SUPPORTS_SIMD 1
#endif // BX_SIMD_*
namespace bx
{
union simd128_ref_t
@@ -514,7 +514,7 @@ namespace bx
# define BX_SIMD_WARN_REFERENCE_IMPL 0
#endif // BX_SIMD_WARN_REFERENCE_IMPL
#if !BX_CONFIG_SUPPORTS_SIMD
#if !BX_SIMD_SUPPORTED
# if BX_SIMD_WARN_REFERENCE_IMPL
# pragma message("*** Using SIMD128 reference implementation! ***")
# endif // BX_SIMD_WARN_REFERENCE_IMPL