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
34
35
36
37
38
39
40
41
42
43
use super::*;
#[derive(Debug, Clone, Copy)]
#[repr(align(16))]
pub struct Vec4 {
#[cfg(target_feature = "sse")]
raw: m128,
#[cfg(not(target_feature = "sse"))]
raw: [f32; 4],
}
unsafe impl Zeroable for Vec4 {}
unsafe impl Pod for Vec4 {}
impl Default for Vec4 {
fn default() -> Self {
Self::zeroed()
}
}
impl From<[f32; 4]> for Vec4 {
fn from(val: [f32; 4]) -> Self {
Self { raw: cast(val) }
}
}
impl Vec4 {
pub fn abs(self) -> Self {
if_sse! {{
Self { raw: self.raw.abs() }
} else {
Self {
raw:
[
lokacore::abs_f32(self.raw[0]),
lokacore::abs_f32(self.raw[1]),
lokacore::abs_f32(self.raw[2]),
lokacore::abs_f32(self.raw[3]),
]
}
}}
}
}