macro_rules! shader_struct {
{ $struct:ident [
$( $num:tt $field:ident => $ty:ident ),* $(,)?
] } => { ... };
}Expand description
Declare a shader struct (to use in a storage buffer).
shader_struct! { $NAME [
0 $FIELD => $TYPE,
1 $FIELD => $TYPE,
2 $FIELD => $TYPE,
...
] }$NAMEis the name of your struct.$FIELDis the struct’s public field name.$TYPEis the field’s primitive type (seeshaderprimitive).
Note that fields must be numbered correctly, starting from 0. This is because I don’t know how to teach macros how to count.
Also, the fields are not rearranged to be optimized to their alignment rules, though they should be padded correctly.