Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Oct 26, 2024
1 parent cc5a21e commit 6e87e04
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
12 changes: 6 additions & 6 deletions include/bx/inline/float4x4_t.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions include/bx/inline/math.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 14 additions & 14 deletions include/bx/simd_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 21 additions & 1 deletion tests/run_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 6e87e04

Please sign in to comment.