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
168
169
170
171
172
#[macro_export]
#[cfg(feature = "gfx-backend-empty")]
macro_rules! rendy_with_empty_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-empty"))]
macro_rules! rendy_with_empty_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-empty"))]
macro_rules! rendy_without_empty_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(feature = "gfx-backend-empty")]
macro_rules! rendy_without_empty_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(feature = "gfx-backend-dx12")]
macro_rules! rendy_with_dx12_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-dx12"))]
macro_rules! rendy_with_dx12_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-dx12"))]
macro_rules! rendy_without_dx12_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(feature = "gfx-backend-dx12")]
macro_rules! rendy_without_dx12_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(feature = "gfx-backend-metal")]
macro_rules! rendy_with_metal_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-metal"))]
macro_rules! rendy_with_metal_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-metal"))]
macro_rules! rendy_without_metal_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(feature = "gfx-backend-metal")]
macro_rules! rendy_without_metal_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(feature = "gfx-backend-vulkan")]
macro_rules! rendy_with_vulkan_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-vulkan"))]
macro_rules! rendy_with_vulkan_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(not(feature = "gfx-backend-vulkan"))]
macro_rules! rendy_without_vulkan_backend {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(feature = "gfx-backend-vulkan")]
macro_rules! rendy_without_vulkan_backend {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(feature = "no-slow-safety-checks")]
macro_rules! rendy_without_slow_safety_checks {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(not(feature = "no-slow-safety-checks"))]
macro_rules! rendy_without_slow_safety_checks {
($($tt:tt)*) => {};
}
#[macro_export]
#[cfg(not(feature = "no-slow-safety-checks"))]
macro_rules! rendy_with_slow_safety_checks {
($($tt:tt)*) => { $($tt)* };
}
#[macro_export]
#[cfg(feature = "no-slow-safety-checks")]
macro_rules! rendy_with_slow_safety_checks {
($($tt:tt)*) => {};
}
#[macro_export]
macro_rules! rendy_backend_match {
($target:path {
$(empty => $empty_code:block)?
$(dx12 => $dx12_code:block)?
$(metal => $metal_code:block)?
$(vulkan => $vulkan_code:block)?
}) => {{
$($crate::rendy_with_empty_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::empty::Backend>() { return $empty_code; }))?;
$($crate::rendy_with_dx12_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::dx12::Backend>() { return $dx12_code; }))?;
$($crate::rendy_with_metal_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::metal::Backend>() { return $metal_code; }))?;
$($crate::rendy_with_vulkan_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::vulkan::Backend>() { return $vulkan_code; }))?;
panic!("
Undefined backend requested.
Make sure feature for required backend is enabled.
Try to add `--features=vulkan` or if on macos `--features=metal`.
")
}};
($target:path as $back:ident => $code:block) => {{
$crate::rendy_backend_match!($target {
empty => { use $crate::empty as $back; $code }
dx12 => { use $crate::dx12 as $back; $code }
metal => { use $crate::metal as $back; $code }
vulkan => { use $crate::vulkan as $back; $code }
});
}};
}