Бранимир Караџић 1 year ago
parent
commit
6e87e0438c
4 changed files with 45 additions and 25 deletions
  1. 6 6
      include/bx/inline/float4x4_t.inl
  2. 4 4
      include/bx/inline/math.inl
  3. 14 14
      include/bx/simd_t.h
  4. 21 1
      tests/run_test.cpp

+ 6 - 6
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)

+ 4 - 4
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)

+ 14 - 14
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 <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

+ 21 - 1
tests/run_test.cpp

@@ -7,6 +7,7 @@
 #include "test.h"
 #include <bx/string.h>
 #include <bx/file.h>
+#include <bx/simd_t.h>
 
 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;