From d8ed86dbd7be0d866f489e18e65895b1204eb030 Mon Sep 17 00:00:00 2001 From: Swoorup Joshi Date: Fri, 5 Jul 2024 19:45:48 +1000 Subject: [PATCH] Fix `min_binding_size` when invoking entry module contains symbols. --- wgsl_bindgen/src/generate/bind_group/mod.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/wgsl_bindgen/src/generate/bind_group/mod.rs b/wgsl_bindgen/src/generate/bind_group/mod.rs index 722f578..f9fec7f 100644 --- a/wgsl_bindgen/src/generate/bind_group/mod.rs +++ b/wgsl_bindgen/src/generate/bind_group/mod.rs @@ -23,7 +23,8 @@ pub struct GroupBinding<'a> { #[derive(Constructor)] struct BindGroupBuilder<'a> { - entry_name: &'a str, + invoking_entry_name: &'a str, + sanitized_entry_name: &'a str, group_no: u32, data: &'a GroupData<'a>, shader_stages: wgpu::ShaderStages, @@ -39,7 +40,7 @@ impl<'a> BindGroupBuilder<'a> { .iter() .map(|binding| { bind_group_layout_entry( - &self.entry_name, + &self.invoking_entry_name, self.naga_module, self.options, self.shader_stages, @@ -48,8 +49,10 @@ impl<'a> BindGroupBuilder<'a> { }) .collect(); - let bind_group_label = - format!("{}::BindGroup{}::LayoutDescriptor", self.entry_name, self.group_no); + let bind_group_label = format!( + "{}::BindGroup{}::LayoutDescriptor", + self.sanitized_entry_name, self.group_no + ); quote! { wgpu::BindGroupLayoutDescriptor { @@ -89,7 +92,8 @@ impl<'a> BindGroupBuilder<'a> { let bind_group_layout_descriptor = self.bind_group_layout_descriptor(); let group_no = Index::from(self.group_no as usize); - let bind_group_label = format!("{}::BindGroup{}", self.entry_name, self.group_no); + let bind_group_label = + format!("{}::BindGroup{}", self.sanitized_entry_name, self.group_no); quote! { impl #bind_group_name { @@ -142,7 +146,7 @@ pub fn bind_groups_module( bind_group_data: &BTreeMap, shader_stages: wgpu::ShaderStages, ) -> TokenStream { - let entry_name = sanitize_and_pascal_case(invoking_entry_module); + let sanitized_entry_name = sanitize_and_pascal_case(invoking_entry_module); let bind_groups: Vec<_> = bind_group_data .iter() .map(|(group_no, group)| { @@ -170,7 +174,8 @@ pub fn bind_groups_module( }; let bindgroup = BindGroupBuilder::new( - &entry_name, + &invoking_entry_module, + &sanitized_entry_name, *group_no, group, shader_stages,