Macro bind_group

Source
macro_rules! bind_group {
    { @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, tuples are used and counting is hard in 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,
] }

// TODO: Create buffers (see buffer docs)
let bind_group: StuffBindGroup = render_context.new_bind_group((matrix_buffer, ..));

queue.write_buffer(&stuff_bind_group.something_else_buffer, 0, &[1, 2, 3, ..]);