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
use crate::vk;
#[derive(Copy, Clone, Debug)]
#[deprecated]
pub struct InputAssembly {
pub topology: PrimitiveTopology,
pub primitive_restart_enable: bool,
}
impl InputAssembly {
#[inline]
pub fn triangle_list() -> InputAssembly {
InputAssembly {
topology: PrimitiveTopology::TriangleList,
primitive_restart_enable: false,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum PrimitiveTopology {
PointList,
LineList,
LineStrip,
TriangleList,
TriangleStrip,
TriangleFan,
LineListWithAdjacency,
LineStripWithAdjacency,
TriangleListWithAdjacency,
TriangleStripWithAdjacency,
PatchList { vertices_per_patch: u32 },
}
impl Into<vk::PrimitiveTopology> for PrimitiveTopology {
#[inline]
fn into(self) -> vk::PrimitiveTopology {
match self {
PrimitiveTopology::PointList => vk::PRIMITIVE_TOPOLOGY_POINT_LIST,
PrimitiveTopology::LineList => vk::PRIMITIVE_TOPOLOGY_LINE_LIST,
PrimitiveTopology::LineStrip => vk::PRIMITIVE_TOPOLOGY_LINE_STRIP,
PrimitiveTopology::TriangleList => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
PrimitiveTopology::TriangleStrip => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
PrimitiveTopology::TriangleFan => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_FAN,
PrimitiveTopology::LineListWithAdjacency => {
vk::PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY
}
PrimitiveTopology::LineStripWithAdjacency => {
vk::PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY
}
PrimitiveTopology::TriangleListWithAdjacency => {
vk::PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY
}
PrimitiveTopology::TriangleStripWithAdjacency => {
vk::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY
}
PrimitiveTopology::PatchList { .. } => vk::PRIMITIVE_TOPOLOGY_PATCH_LIST,
}
}
}
impl PrimitiveTopology {
#[inline]
pub fn supports_primitive_restart(&self) -> bool {
match *self {
PrimitiveTopology::LineStrip => true,
PrimitiveTopology::TriangleStrip => true,
PrimitiveTopology::TriangleFan => true,
PrimitiveTopology::LineStripWithAdjacency => true,
PrimitiveTopology::TriangleStripWithAdjacency => true,
_ => false,
}
}
}
pub unsafe trait Index {
fn ty() -> IndexType;
}
unsafe impl Index for u16 {
#[inline(always)]
fn ty() -> IndexType {
IndexType::U16
}
}
unsafe impl Index for u32 {
#[inline(always)]
fn ty() -> IndexType {
IndexType::U32
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
#[repr(u32)]
pub enum IndexType {
U16 = vk::INDEX_TYPE_UINT16,
U32 = vk::INDEX_TYPE_UINT32,
}