Swoorup / wgsl-bindgen

Generate typesafe Rust bindings for wgsl shaders in wgpu
https://crates.io/crates/wgsl_bindgen
MIT License
33 stars 6 forks source link

Provide `min_binding_size` when generating the Bind Group Layout Descriptor. #14

Closed Swoorup closed 3 months ago

Swoorup commented 4 months ago

We should probably provide a min_binding_size for uniform buffer when generating the Bind Group Layout Descriptor.

wgpu::BindGroupLayoutEntry {
  binding: 0,
  visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
  ty: wgpu::BindingType::Buffer {
    ty: wgpu::BufferBindingType::Uniform,
    has_dynamic_offset: false,
    min_binding_size: NonZeroU64::new(std::mem::size_of::<gpu_data::BatchUniformBuffer>() as _),
  },
   count: None,
}
Swoorup commented 3 months ago

Comment from the man himself: https://matrix.to/#/!FZyQrssSlHEZqrYcOb:matrix.org/$8OeoKDnC8ZI4SDsAd0oXHiWRmSxhT-TWgctUYWmffKY?via=matrix.org&via=mozilla.org&via=envs.net

image
Swoorup commented 3 months ago

For binding layout entries, also might be useful to generate comments for each layout entry. This helps especially when correlating large number of bindings.