rfw_math/
lib.rs

1pub use glam::*;
2
3#[inline(always)]
4pub fn vec4_sqrt(vec: Vec4) -> Vec4 {
5    #[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
6    unsafe {
7        use std::arch::x86_64::_mm_sqrt_ps;
8        _mm_sqrt_ps(vec.into()).into()
9    }
10    #[cfg(any(
11        all(not(target_arch = "x86_64"), not(target_arch = "x86")),
12        target_arch = "wasm32-unknown-unknown"
13    ))]
14    {
15        Vec4::new(vec[0].sqrt(), vec[1].sqrt(), vec[2].sqrt(), vec[3].sqrt())
16    }
17}
18
19#[inline(always)]
20pub fn vec4_rsqrt(vec: Vec4) -> Vec4 {
21    #[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
22    unsafe {
23        use std::arch::x86_64::_mm_rsqrt_ps;
24        _mm_rsqrt_ps(vec.into()).into()
25    }
26    #[cfg(any(
27        all(not(target_arch = "x86_64"), not(target_arch = "x86")),
28        target_arch = "wasm32-unknown-unknown"
29    ))]
30    {
31        Vec4::new(vec[0].sqrt(), vec[1].sqrt(), vec[2].sqrt(), vec[3].sqrt())
32    }
33}