1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pub use glam::*;

#[inline(always)]
pub fn vec4_sqrt(vec: Vec4) -> Vec4 {
    #[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
    unsafe {
        use std::arch::x86_64::_mm_sqrt_ps;
        _mm_sqrt_ps(vec.into()).into()
    }
    #[cfg(any(
        all(not(target_arch = "x86_64"), not(target_arch = "x86")),
        target_arch = "wasm32-unknown-unknown"
    ))]
    {
        Vec4::new(vec[0].sqrt(), vec[1].sqrt(), vec[2].sqrt(), vec[3].sqrt())
    }
}

#[inline(always)]
pub fn vec4_rsqrt(vec: Vec4) -> Vec4 {
    #[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
    unsafe {
        use std::arch::x86_64::_mm_rsqrt_ps;
        _mm_rsqrt_ps(vec.into()).into()
    }
    #[cfg(any(
        all(not(target_arch = "x86_64"), not(target_arch = "x86")),
        target_arch = "wasm32-unknown-unknown"
    ))]
    {
        Vec4::new(vec[0].sqrt(), vec[1].sqrt(), vec[2].sqrt(), vec[3].sqrt())
    }
}