glam/
f32.rs

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
mod affine2;
mod affine3a;
mod float;
mod mat3;
pub(crate) mod math;
mod vec2;
mod vec3;

#[cfg(all(feature = "core-simd", not(feature = "scalar-math")))]
mod coresimd;

#[cfg(any(
    not(any(
        feature = "core-simd",
        target_feature = "sse2",
        target_feature = "simd128"
    )),
    feature = "scalar-math"
))]
mod scalar;

#[cfg(all(
    target_feature = "sse2",
    not(any(feature = "core-simd", feature = "scalar-math"))
))]
mod sse2;

#[cfg(all(
    target_feature = "simd128",
    not(any(feature = "core-simd", feature = "scalar-math"))
))]
mod wasm32;

#[cfg(any(
    not(any(
        feature = "core-simd",
        target_feature = "sse2",
        target_feature = "simd128"
    )),
    feature = "scalar-math"
))]
use scalar::*;

#[cfg(all(
    target_feature = "sse2",
    not(any(feature = "core-simd", feature = "scalar-math"))
))]
use sse2::*;

#[cfg(all(
    target_feature = "simd128",
    not(any(feature = "core-simd", feature = "scalar-math"))
))]
use wasm32::*;

#[cfg(all(feature = "core-simd", not(feature = "scalar-math")))]
use coresimd::*;

pub use affine2::Affine2;
pub use affine3a::Affine3A;
pub use mat2::{mat2, Mat2};
pub use mat3::{mat3, Mat3};
pub use mat3a::{mat3a, Mat3A};
pub use mat4::{mat4, Mat4};
pub use quat::{quat, Quat};
pub use vec2::{vec2, Vec2};
pub use vec3::{vec3, Vec3};
pub use vec3a::{vec3a, Vec3A};
pub use vec4::{vec4, Vec4};

#[cfg(not(target_arch = "spirv"))]
mod test {
    use super::*;

    #[cfg(all(not(feature = "cuda"), feature = "scalar-math"))]
    mod const_test_affine2 {
        const_assert_eq!(
            core::mem::align_of::<super::Vec2>(),
            core::mem::align_of::<super::Affine2>()
        );
        const_assert_eq!(24, core::mem::size_of::<super::Affine2>());
    }

    #[cfg(not(feature = "scalar-math"))]
    mod const_test_affine2 {
        const_assert_eq!(16, core::mem::align_of::<super::Affine2>());
        const_assert_eq!(32, core::mem::size_of::<super::Affine2>());
    }

    mod const_test_mat2 {
        #[cfg(feature = "scalar-math")]
        const_assert_eq!(
            core::mem::align_of::<super::Vec2>(),
            core::mem::align_of::<super::Mat2>()
        );
        #[cfg(not(any(feature = "scalar-math", target_arch = "spirv")))]
        const_assert_eq!(16, core::mem::align_of::<super::Mat2>());
        const_assert_eq!(16, core::mem::size_of::<super::Mat2>());
    }

    mod const_test_mat3 {
        const_assert_eq!(
            core::mem::align_of::<f32>(),
            core::mem::align_of::<super::Mat3>()
        );
        const_assert_eq!(36, core::mem::size_of::<super::Mat3>());
    }

    mod const_test_mat3a {
        const_assert_eq!(16, core::mem::align_of::<super::Mat3A>());
        const_assert_eq!(48, core::mem::size_of::<super::Mat3A>());
    }

    mod const_test_mat4 {
        const_assert_eq!(
            core::mem::align_of::<super::Vec4>(),
            core::mem::align_of::<super::Mat4>()
        );
        const_assert_eq!(64, core::mem::size_of::<super::Mat4>());
    }

    mod const_test_quat {
        #[cfg(feature = "scalar-math")]
        const_assert_eq!(
            core::mem::align_of::<f32>(),
            core::mem::align_of::<super::Quat>()
        );
        #[cfg(not(any(feature = "scalar-math", target_arch = "spirv")))]
        const_assert_eq!(16, core::mem::align_of::<super::Quat>());
        const_assert_eq!(16, core::mem::size_of::<super::Quat>());
    }

    mod const_test_vec2 {
        #[cfg(not(feature = "cuda"))]
        const_assert_eq!(
            core::mem::align_of::<f32>(),
            core::mem::align_of::<super::Vec2>()
        );
        #[cfg(feature = "cuda")]
        const_assert_eq!(8, core::mem::align_of::<super::Vec2>());
        const_assert_eq!(8, core::mem::size_of::<super::Vec2>());
    }

    mod const_test_vec3 {
        const_assert_eq!(
            core::mem::align_of::<f32>(),
            core::mem::align_of::<super::Vec3>()
        );
        const_assert_eq!(12, core::mem::size_of::<super::Vec3>());
    }

    mod const_test_vec3a {
        const_assert_eq!(16, core::mem::align_of::<super::Vec3A>());
        const_assert_eq!(16, core::mem::size_of::<super::Vec3A>());
    }

    mod const_test_vec4 {
        #[cfg(all(feature = "scalar-math", not(feature = "cuda")))]
        const_assert_eq!(
            core::mem::align_of::<f32>(),
            core::mem::align_of::<super::Vec4>()
        );
        #[cfg(not(feature = "scalar-math"))]
        const_assert_eq!(16, core::mem::align_of::<super::Vec4>());
        const_assert_eq!(16, core::mem::size_of::<super::Vec4>());
    }
}