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
/// A marker type specifying SIMD alignment.
///
/// See [`Alignment`] for more details.
;
/// A marker type specifying lack of SIMD alignment.
///
/// See [`Alignment`] for more details.
;
/// A marker trait controlling SIMD alignment for types.
///
/// Types like [`Vector<N, T, A>`] are generic over `A: Alignment` which
/// controls SIMD alignment and is either [`Aligned`] or [`Unaligned`].
///
/// Appropriate [`Aligned`] types have increased memory alignment in order to
/// take advantage of SIMD instructions that improve performance. For example,
/// [`Vec3<f32>`], [`Vec4<f32>`], [`Mat3<f32>`] and [`Mat4<f32>`] are aligned to
/// 16 bytes on x86 targets in order to take advantage of the SSE instruction
/// set.
///
/// Although SIMD alignment generally results better performance, it can also
/// result in wasted space. For example, due to 16-byte alignment, [`Vec3<f32>`]
/// has 4 bytes of padding, and consequently [`Mat3<f32>`] has 12 bytes of
/// padding.
///
/// [`Unaligned`] types do not have SIMD alignment. They are optimal when better
/// performance is not worth wasted space, for example when storing 3D models.
/// In all other cases, [`Aligned`] types are optimal and result in better
/// performance than [`Unaligned`] types.
///
/// [`Vector<N, T, A>`]: crate::Vector
/// [`Vec3<f32>`]: crate::Vec3
/// [`Vec4<f32>`]: crate::Vec4
/// [`Mat3<f32>`]: crate::Mat3
/// [`Mat4<f32>`]: crate::Mat4