wgpu_bind_dsl 0.1.1

An experimental macro dsl for describing Bind layouts in wgpu-rs
Documentation
  • Coverage
  • 83.33%
    5 out of 6 items documented1 out of 1 items with examples
  • Size
  • Source code size: 21.66 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.35 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mobile-bungalow

wgpu_bind_dsl

a macro for working with the wgpu-rs library. allows for declarative binding descriptors!

previously you would have to describe a (deep breath) wgpu::BindLayoutDescriptor as such

 &wgpu::BindGroupLayoutDescriptor {
          bindings: &[
              wgpu::BindGroupLayoutEntry {
                  binding: 0, // global
                  visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
                  ty: wgpu::BindingType::UniformBuffer { dynamic: false },
              },
              wgpu::BindGroupLayoutEntry {
                  binding: 1, // lights
                  visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
                  ty: wgpu::BindingType::UniformBuffer { dynamic: false },
              },
              wgpu::BindGroupLayoutEntry {
                  binding: 2,
                  visibility: wgpu::ShaderStage::FRAGMENT,
                  ty: wgpu::BindingType::SampledTexture {
                      multisampled: false,
                      component_type: wgpu::TextureComponentType::Float,
                      dimension: wgpu::TextureViewDimension::D2Array,
                  },
              },
              wgpu::BindGroupLayoutEntry {
                  binding: 3,
                  visibility: wgpu::ShaderStage::FRAGMENT,
                  ty: wgpu::BindingType::Sampler { comparison: true },
              },
          ],
          label: None,
      }

but now you can simply write

binding_layout! {
  { Vertex |  Fragment } => {
      0 => Buffer,
      1 => Buffer,
  },
  Fragment => {
     2 => Tex2DArray<Float>,
     3 => Sampler: Cmp,
  },
};