[][src]Macro wgpu_bind_dsl::binding_layout

macro_rules! binding_layout {
    ($($loc:tt => $fmt:tt,)*) => { ... };
    ([$($t:expr,)*] ; $name:expr ; $vis:tt => {
        $($loc:expr =>
            $binding:tt$(<$generic:ident>)?$(:$($trait1:ident$(<$tgen1:ident>)?)? $(+$trait2:tt$(<$tgen2:ident>)?)?)?,)*
    }, $($ll:tt => $ii:tt,)*) => { ... };
    ([$($t:expr,)*] ; $old_name:expr ;  Label => $name:expr, $($ll:tt => $ii:tt,)*) => { ... };
    ([$($t:expr,)*] ; $name:expr ; ) => { ... };
}

this macro builds a wgpu::BindingLayoutDescriptor with a format not unlike json.

Syntax

( visibility expression | field ) => { ( bind_location => type )* }

visibility expressions: Fragment, Vertex, Compute, None.

these can be enclosed in brackets and seperated with the binary or operator to use multiple visibility flags. this corresponds to the visibility field in the wgpu::BindGroupLayoutEntry struct.

fields: Label

instead of taking a binding label takes a &'static str literal. this field is totally optional and corresponds with the label field in the wgpu::BindGroupLayoutEntry struct

textures are described using their equivalent opengl samplers, in the form Tex{Dimension}{MS}? i.e. Tex2DArrayMS being an sampled texture with dimension D2Array with multisampling turned on.

type: Buffer: (Dyn)?, StorageBuffer: (Dyn)? + (Readonly)? , Sampler: (Cmp)?, glsl_sampler_decl: (Storage)? + (Readonly)?

Usage:

  let desc = binding_layout! {
     Label => "OptionalName",
     Vertex => {
        1 => Buffer,
        2 => StorageBuffer: Dyn,
     },
     Fragment => {
        2 => Sampler,
        3 => Sampler: Cmp,
     },
     Compute => {
        1 => Buffer: Dyn,
        2 => StorageBuffer: Dyn + Readonly,
     },
     { Compute | Fragment } => {
        5 => Tex2D<Sint>: Storage<R8Unorm> + Readonly,
     },
 };