mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-18 20:28:01 +00:00
Use CLAY_DISABLE_SIMD
This commit is contained in:
parent
addea58fea
commit
222fd49793
@ -1,10 +1,7 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
// #define USE_INTRINSICS
|
#if !defined(CLAY_DISABLE_SIMD) && (defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64))
|
||||||
// #define USE_FAST_SQRT
|
#include <immintrin.h> // AVX intrinsincs for faster sqrtf
|
||||||
|
|
||||||
#if defined(USE_INTRINSICS)
|
|
||||||
#include <immintrin.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../clay.h"
|
#include "../../clay.h"
|
||||||
@ -20,23 +17,15 @@ bool gdi_fabulous = true;
|
|||||||
/*----------------------------------------------------------------------------+
|
/*----------------------------------------------------------------------------+
|
||||||
| Math stuff start |
|
| Math stuff start |
|
||||||
+----------------------------------------------------------------------------*/
|
+----------------------------------------------------------------------------*/
|
||||||
#if defined(USE_INTRINSICS)
|
// Intrinsincs wrappers
|
||||||
#define sqrtf_impl(x) intrin_sqrtf(x)
|
#if !defined(CLAY_DISABLE_SIMD) && (defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64))
|
||||||
#elif defined(USE_FAST_SQRT)
|
|
||||||
#define sqrtf_impl(x) fast_sqrtf(x)
|
|
||||||
#else
|
|
||||||
#define sqrtf_impl(x) sqrtf(x) // Fallback to std sqrtf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Use intrinsics
|
|
||||||
#if defined(USE_INTRINSICS)
|
|
||||||
inline float intrin_sqrtf(const float f)
|
inline float intrin_sqrtf(const float f)
|
||||||
{
|
{
|
||||||
__m128 temp = _mm_set_ss(f);
|
__m128 temp = _mm_set_ss(f);
|
||||||
temp = _mm_sqrt_ss(temp);
|
temp = _mm_sqrt_ss(temp);
|
||||||
return _mm_cvtss_f32(temp);
|
return _mm_cvtss_f32(temp);
|
||||||
}
|
}
|
||||||
#endif // defined(USE_INTRINSICS)
|
#endif
|
||||||
|
|
||||||
// Use fast inverse square root
|
// Use fast inverse square root
|
||||||
#if defined(USE_FAST_SQRT)
|
#if defined(USE_FAST_SQRT)
|
||||||
@ -65,6 +54,15 @@ float fast_sqrtf(float number)
|
|||||||
return number * fast_inv_sqrtf(number);
|
return number * fast_inv_sqrtf(number);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// sqrtf_impl implementation chooser
|
||||||
|
#if !defined(CLAY_DISABLE_SIMD) && (defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64))
|
||||||
|
#define sqrtf_impl(x) intrin_sqrtf(x)
|
||||||
|
#elif defined(USE_FAST_SQRT)
|
||||||
|
#define sqrtf_impl(x) fast_sqrtf(x)
|
||||||
|
#else
|
||||||
|
#define sqrtf_impl(x) sqrtf(x) // Fallback to std sqrtf
|
||||||
|
#endif
|
||||||
/*----------------------------------------------------------------------------+
|
/*----------------------------------------------------------------------------+
|
||||||
| Math stuff end |
|
| Math stuff end |
|
||||||
+----------------------------------------------------------------------------*/
|
+----------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user