simd128: handle both sse2 and simd128 enabled by Emscripten

https://github.com/recp/cglm/pull/286#issuecomment-1492985403
This commit is contained in:
myfreeer
2023-04-02 12:39:20 +08:00
parent 7ca9a64ecf
commit 3a9e4df393
8 changed files with 171 additions and 170 deletions

View File

@@ -242,21 +242,7 @@ glm_quat_norm(versor q) {
CGLM_INLINE
void
glm_quat_normalize_to(versor q, versor dest) {
#if defined( __SSE2__ ) || defined( __SSE2__ )
__m128 xdot, x0;
float dot;
x0 = glmm_load(q);
xdot = glmm_vdot(x0, x0);
dot = _mm_cvtss_f32(xdot);
if (dot <= 0.0f) {
glm_quat_identity(dest);
return;
}
glmm_store(dest, _mm_div_ps(x0, _mm_sqrt_ps(xdot)));
#elif defined(__wasm__) && defined(__wasm_simd128__)
#if defined(__wasm__) && defined(__wasm_simd128__)
glmm_128 xdot, x0;
float dot;
@@ -271,6 +257,20 @@ glm_quat_normalize_to(versor q, versor dest) {
}
glmm_store(dest, wasm_f32x4_div(x0, wasm_f32x4_sqrt(xdot)));
#elif defined( __SSE2__ ) || defined( __SSE2__ )
__m128 xdot, x0;
float dot;
x0 = glmm_load(q);
xdot = glmm_vdot(x0, x0);
dot = _mm_cvtss_f32(xdot);
if (dot <= 0.0f) {
glm_quat_identity(dest);
return;
}
glmm_store(dest, _mm_div_ps(x0, _mm_sqrt_ps(xdot)));
#else
float dot;
@@ -457,10 +457,10 @@ glm_quat_mul(versor p, versor q, versor dest) {
+ (a1 d2 + b1 c2 c1 b2 + d1 a2)k
a1 a2 b1 b2 c1 c2 d1 d2
*/
#if defined( __SSE__ ) || defined( __SSE2__ )
glm_quat_mul_sse2(p, q, dest);
#elif defined(__wasm__) && defined(__wasm_simd128__)
#if defined(__wasm__) && defined(__wasm_simd128__)
glm_quat_mul_wasm(p, q, dest);
#elif defined( __SSE__ ) || defined( __SSE2__ )
glm_quat_mul_sse2(p, q, dest);
#elif defined(CGLM_NEON_FP)
glm_quat_mul_neon(p, q, dest);
#else