#[cfg(doc)]
use crate::{VertexAttribute, VertexBufferLayout, VertexFormat};
#[macro_export]
macro_rules! vertex_attr_array {
($($location:expr => $format:ident),* $(,)?) => {
$crate::_vertex_attr_array_helper!([] ; 0; $($location => $format ,)*)
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! _vertex_attr_array_helper {
([$($t:expr,)*] ; $off:expr ;) => { [$($t,)*] };
([$($t:expr,)*] ; $off:expr ; $location:expr => $format:ident, $($ll:expr => $ii:ident ,)*) => {
$crate::_vertex_attr_array_helper!(
[$($t,)*
$crate::VertexAttribute {
format: $crate::VertexFormat :: $format,
offset: $off,
shader_location: $location,
},];
$off + $crate::VertexFormat :: $format.size();
$($ll => $ii ,)*
)
};
}
#[test]
fn test_vertex_attr_array() {
let attrs = vertex_attr_array![0 => Float32x2, 3 => Uint16x4];
assert_eq!(attrs.len(), 2);
assert_eq!(attrs[0].offset, 0);
assert_eq!(attrs[0].shader_location, 0);
assert_eq!(attrs[1].offset, size_of::<(f32, f32)>() as u64);
assert_eq!(attrs[1].shader_location, 3);
}
#[macro_export]
#[cfg(feature = "spirv")]
macro_rules! include_spirv {
($($token:tt)*) => {
{
$crate::ShaderModuleDescriptor {
label: Some($($token)*),
source: $crate::util::make_spirv(include_bytes!($($token)*)),
}
}
};
}
#[macro_export]
macro_rules! include_spirv_raw {
($($token:tt)*) => {
{
$crate::ShaderModuleDescriptorPassthrough {
label: $crate::__macro_helpers::Some($($token)*),
spirv: Some($crate::util::make_spirv_raw($crate::__macro_helpers::include_bytes!($($token)*))),
entry_point: "".to_owned(),
num_workgroups: (0, 0, 0),
reflection: None,
shader_runtime_checks: $crate::ShaderRuntimeChecks::unchecked(),
dxil: None,
msl: None,
hlsl: None,
glsl: None,
wgsl: None,
}
}
};
}
#[macro_export]
macro_rules! include_wgsl {
($($token:tt)*) => {
{
$crate::ShaderModuleDescriptor {
label: $crate::__macro_helpers::Some($($token)*),
source: $crate::ShaderSource::Wgsl($crate::__macro_helpers::Cow::Borrowed($crate::__macro_helpers::include_str!($($token)*))),
}
}
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(dx12)]
macro_rules! hal_type_dx12 {
($ty: literal) => {
concat!("- [`hal::api::Dx12`] uses [`hal::dx12::", $ty, "`]")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(not(dx12))]
macro_rules! hal_type_dx12 {
($ty: literal) => {
concat!("- `hal::api::Dx12` uses `hal::dx12::", $ty, "`")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(metal)]
macro_rules! hal_type_metal {
($ty: literal) => {
concat!("- [`hal::api::Metal`] uses [`hal::metal::", $ty, "`]")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(not(metal))]
macro_rules! hal_type_metal {
($ty: literal) => {
concat!("- `hal::api::Metal` uses `hal::metal::", $ty, "`")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(vulkan)]
macro_rules! hal_type_vulkan {
($ty: literal) => {
concat!("- [`hal::api::Vulkan`] uses [`hal::vulkan::", $ty, "`]")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(not(vulkan))]
macro_rules! hal_type_vulkan {
($ty: literal) => {
concat!("- `hal::api::Vulkan` uses `hal::vulkan::", $ty, "`")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(gles)]
macro_rules! hal_type_gles {
($ty: literal) => {
concat!("- [`hal::api::Gles`] uses [`hal::gles::", $ty, "`]")
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(not(gles))]
macro_rules! hal_type_gles {
($ty: literal) => {
concat!("- `hal::api::Gles` uses `hal::gles::", $ty, "`")
};
}
#[doc(hidden)]
pub mod helpers {
pub use alloc::borrow::Cow;
pub use core::{include_bytes, include_str};
pub use Some;
}