Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make buffer binding arrays emit bind group layout entries and bindless resource descriptors again. #18125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion crates/bevy_render/macros/src/as_bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,29 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result<TokenStream> {
}
_ => {}
}

let binding_array_binding = binding_array_binding.unwrap_or(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0? Why is 0 implicitly correct? I thought the data is automatically serialised into a buffer at binding 0?

Copy link
Contributor Author

@pcwalton pcwalton Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not. I just need a dummy value to insert into bindless_binding_layouts, because we populate that array anyway even in the non-bindless case, for simplicity. Maybe that should be refactored though. (This macro is a mess in general, unfortunately.)

bindless_binding_layouts.push(quote! {
#bind_group_layout_entries.push(
#render_path::render_resource::BindGroupLayoutEntry {
binding: #binding_array_binding,
visibility: #render_path::render_resource::ShaderStages::all(),
ty: #render_path::render_resource::BindingType::Buffer {
ty: #uniform_binding_type,
has_dynamic_offset: false,
min_binding_size: Some(<#converted_shader_type as #render_path::render_resource::ShaderType>::min_size()),
},
count: #actual_bindless_slot_count,
}
);
});

add_bindless_resource_type(
&render_path,
&mut bindless_resource_types,
binding_index,
quote! { #render_path::render_resource::BindlessResourceType::Buffer },
);
}

UniformBindingAttrType::Data => {
Expand Down Expand Up @@ -201,7 +224,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result<TokenStream> {
},
count: None,
}
)
);
});

add_bindless_resource_type(
Expand Down