1#[macro_export]
3#[cfg(feature = "gfx-backend-empty")]
4macro_rules! rendy_with_empty_backend {
5 ($($tt:tt)*) => { $($tt)* };
6}
7
8#[macro_export]
10#[cfg(not(feature = "gfx-backend-empty"))]
11macro_rules! rendy_with_empty_backend {
12 ($($tt:tt)*) => {};
13}
14
15#[macro_export]
17#[cfg(not(feature = "gfx-backend-empty"))]
18macro_rules! rendy_without_empty_backend {
19 ($($tt:tt)*) => { $($tt)* };
20}
21
22#[macro_export]
24#[cfg(feature = "gfx-backend-empty")]
25macro_rules! rendy_without_empty_backend {
26 ($($tt:tt)*) => {};
27}
28
29#[macro_export]
31#[cfg(feature = "gfx-backend-dx12")]
32macro_rules! rendy_with_dx12_backend {
33 ($($tt:tt)*) => { $($tt)* };
34}
35
36#[macro_export]
38#[cfg(not(feature = "gfx-backend-dx12"))]
39macro_rules! rendy_with_dx12_backend {
40 ($($tt:tt)*) => {};
41}
42
43#[macro_export]
45#[cfg(not(feature = "gfx-backend-dx12"))]
46macro_rules! rendy_without_dx12_backend {
47 ($($tt:tt)*) => { $($tt)* };
48}
49
50#[macro_export]
52#[cfg(feature = "gfx-backend-dx12")]
53macro_rules! rendy_without_dx12_backend {
54 ($($tt:tt)*) => {};
55}
56
57#[macro_export]
59#[cfg(feature = "gfx-backend-metal")]
60macro_rules! rendy_with_metal_backend {
61 ($($tt:tt)*) => { $($tt)* };
62}
63
64#[macro_export]
66#[cfg(not(feature = "gfx-backend-metal"))]
67macro_rules! rendy_with_metal_backend {
68 ($($tt:tt)*) => {};
69}
70
71#[macro_export]
73#[cfg(not(feature = "gfx-backend-metal"))]
74macro_rules! rendy_without_metal_backend {
75 ($($tt:tt)*) => { $($tt)* };
76}
77
78#[macro_export]
80#[cfg(feature = "gfx-backend-metal")]
81macro_rules! rendy_without_metal_backend {
82 ($($tt:tt)*) => {};
83}
84
85#[macro_export]
87#[cfg(feature = "gfx-backend-vulkan")]
88macro_rules! rendy_with_vulkan_backend {
89 ($($tt:tt)*) => { $($tt)* };
90}
91
92#[macro_export]
94#[cfg(not(feature = "gfx-backend-vulkan"))]
95macro_rules! rendy_with_vulkan_backend {
96 ($($tt:tt)*) => {};
97}
98
99#[macro_export]
101#[cfg(not(feature = "gfx-backend-vulkan"))]
102macro_rules! rendy_without_vulkan_backend {
103 ($($tt:tt)*) => { $($tt)* };
104}
105
106#[macro_export]
108#[cfg(feature = "gfx-backend-vulkan")]
109macro_rules! rendy_without_vulkan_backend {
110 ($($tt:tt)*) => {};
111}
112
113#[macro_export]
115#[cfg(feature = "no-slow-safety-checks")]
116macro_rules! rendy_without_slow_safety_checks {
117 ($($tt:tt)*) => { $($tt)* };
118}
119
120#[macro_export]
122#[cfg(not(feature = "no-slow-safety-checks"))]
123macro_rules! rendy_without_slow_safety_checks {
124 ($($tt:tt)*) => {};
125}
126
127#[macro_export]
129#[cfg(not(feature = "no-slow-safety-checks"))]
130macro_rules! rendy_with_slow_safety_checks {
131 ($($tt:tt)*) => { $($tt)* };
132}
133
134#[macro_export]
136#[cfg(feature = "no-slow-safety-checks")]
137macro_rules! rendy_with_slow_safety_checks {
138 ($($tt:tt)*) => {};
139}
140
141#[macro_export]
145macro_rules! rendy_backend_match {
146 ($target:path {
147 $(empty => $empty_code:block)?
148 $(dx12 => $dx12_code:block)?
149 $(metal => $metal_code:block)?
150 $(vulkan => $vulkan_code:block)?
151 }) => {{
152 $($crate::rendy_with_empty_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::empty::Backend>() { return $empty_code; }))?;
153 $($crate::rendy_with_dx12_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::dx12::Backend>() { return $dx12_code; }))?;
154 $($crate::rendy_with_metal_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::metal::Backend>() { return $metal_code; }))?;
155 $($crate::rendy_with_vulkan_backend!(if std::any::TypeId::of::<$target>() == std::any::TypeId::of::<$crate::vulkan::Backend>() { return $vulkan_code; }))?;
156
157 panic!("
158 Undefined backend requested.
159 Make sure feature for required backend is enabled.
160 Try to add `--features=vulkan` or if on macos `--features=metal`.
161 ")
162 }};
163
164 ($target:path as $back:ident => $code:block) => {{
165 $crate::rendy_backend_match!($target {
166 empty => { use $crate::empty as $back; $code }
167 dx12 => { use $crate::dx12 as $back; $code }
168 metal => { use $crate::metal as $back; $code }
169 vulkan => { use $crate::vulkan as $back; $code }
170 });
171 }};
172}