Macro pipeline

Source
macro_rules! pipeline {
    { @texturefmt $var:ident , SURFACE } => { ... };
    { @texturefmt $var:ident , $fragmentfmt:ident } => { ... };
    { $struct:ident {
        bind_groups : [
            $( $bindgroupnum:tt => $bindgroup:ty ),* $(,)?
        ],
        vertex_types: [
            $( $vertexnum:tt => $vertexty:ty ),* $(,)?
        ],
        fragment_targets: [
            $( $fragmentnum:tt => $blend:ident $mask:ident as $fragmentfmt:ident ),* $(,)?
        ],
        push_constants: [
            $( $pushfrom:literal .. $pushto:literal @ $pushshaderstage:ident ),* $(,)?
        ],
        depth: $depthfmt:expr,
        cull: $cull:expr,
    } } => { ... };
}
Expand description

Define a pipeline, with internal bind group and vertex types.

You need to number each field and include the total count of bind groups, it’s just a limitation of macros.

pipeline! { CoolPipeline {
    bind_groups: [
        0 => CirniumGroup,
    ],
    vertex_types: [
        0 => Vertex,
    ],
    fragment_targets: [
        0 => ALPHA_BLENDING ALL as SURFACE,
    ],
    push_constants: [],
    depth: None,
    cull: Some(Front),
} }

let pipeline: CoolPipeline = render_context.new_pipeline(None, shader, None, None);

render_pass.set_pipeline(&pipeline);