#[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 }
});
}};
}