From 6e87e0438ce333325b8a092538f12829f3f48e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 26 Oct 2024 08:25:54 -0700 Subject: [PATCH] Cleanup. --- include/bx/inline/float4x4_t.inl | 12 ++++++------ include/bx/inline/math.inl | 8 ++++---- include/bx/simd_t.h | 28 ++++++++++++++-------------- tests/run_test.cpp | 22 +++++++++++++++++++++- 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/include/bx/inline/float4x4_t.inl b/include/bx/inline/float4x4_t.inl index 1cd7c36..1c1d296 100644 --- a/include/bx/inline/float4x4_t.inl +++ b/include/bx/inline/float4x4_t.inl @@ -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) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 10f9c95..f33b873 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -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) diff --git a/include/bx/simd_t.h b/include/bx/simd_t.h index a0d129c..4c8caf3 100644 --- a/include/bx/simd_t.h +++ b/include/bx/simd_t.h @@ -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 @@ -36,15 +36,24 @@ # include # 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 diff --git a/tests/run_test.cpp b/tests/run_test.cpp index 43718d2..a3c3fcf 100644 --- a/tests/run_test.cpp +++ b/tests/run_test.cpp @@ -7,6 +7,7 @@ #include "test.h" #include #include +#include bool testAssertHandler(const bx::Location& _location, const char* _format, va_list _argList) { @@ -29,15 +30,34 @@ int runAllTests(int _argc, const char* _argv[]) { bx::setAssertHandler(testAssertHandler); - DBG("Compiler: " BX_COMPILER_NAME + bx::printf( + "\nCompiler: " BX_COMPILER_NAME ", CPU: " BX_CPU_NAME ", Arch: " BX_ARCH_NAME ", OS: " BX_PLATFORM_NAME ", CRT: " BX_CRT_NAME ", C++: " BX_CPP_NAME + ", SIMD" +#if BX_SIMD_SUPPORTED +# if BX_SIMD_AVX + ", AVX" +# endif // BX_SIMD_AVX +# if BX_SIMD_LANGEXT + ", LangExt" +# endif // BX_SIMD_LANGEXT +# if BX_SIMD_NEON + ", Neon" +# endif // BX_SIMD_NEON +# if BX_SIMD_SSE + ", SSE" +# endif // BX_SIMD_SSE +#else + ": Not supported." +#endif // BX_SIMD_SUPPORTED ", Date: " __DATE__ ", Time: " __TIME__ + "\n\n" ); using namespace Catch;