macro_rules! bind_group {
{ @len } => { ... };
{ @len $last:tt } => { ... };
{ @len $first:tt $( $rest:tt )+ } => { ... };
{ @bufferout $ty:ty } => { ... };
{ @bufferout $out:ty as $in:ty } => { ... };
{ @bufferin $ty:ty } => { ... };
{ @bufferin $out:ty as $in:ty } => { ... };
{ $struct:ident [
$( $num:tt $name:ident @ $( $shaderstage:ident )|+ => $buffer:ty $( as $bufferinner:ty )? ),* $(,)?
] } => { ... };
}
Expand description
Define a bind group, with internal buffer types (and their field names), and
their shader visibility (see [wgpu::ShaderStages
]).
You need to number each field and include the total count of buffers, it’s just a limitation of macros.
bind_group! { StuffBindGroup [
0 matrix_buffer @ VERTEX | COMPUTE => MatrixBuffer,
1 something_else_buffer @ FRAGMENT => Arc<SomethingElseBuffer> as SomethingElseBuffer,
2 another_matrix_buffer @ VERTEX_FRAGMENT => MatrixBuffer,
] }
let stuff_bind_group = StuffBindGroup::new(...);
queue.write_buffer(&stuff_bind_group.something_else_buffer, 0, &[1, 2, 3, ..]);