Macro shader_struct

Source
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,
    ...
] }
  • $NAME is the name of your struct.
  • $FIELD is the struct’s public field name.
  • $TYPE is the field’s primitive type (see shaderprimitive).

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.