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

[Merged by Bors] - Make AsBindGroup unsized #6937

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion crates/bevy_render/macros/src/as_bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result<TokenStream> {
render_device: &#render_path::renderer::RenderDevice,
images: &#render_path::render_asset::RenderAssets<#render_path::texture::Image>,
fallback_image: &#render_path::texture::FallbackImage,
) -> Result<#render_path::render_resource::PreparedBindGroup<Self>, #render_path::render_resource::AsBindGroupError> {
) -> Result<#render_path::render_resource::PreparedBindGroup<Self::Data>, #render_path::render_resource::AsBindGroupError> {
let bindings = vec![#(#binding_impls,)*];

let bind_group = {
Expand Down
12 changes: 7 additions & 5 deletions crates/bevy_render/src/render_resource/bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl Deref for BindGroup {
/// }
/// }
/// ```
pub trait AsBindGroup: Sized {
pub trait AsBindGroup {
/// Data that will be stored alongside the "prepared" bind group.
type Data: Send + Sync;

Expand All @@ -264,10 +264,12 @@ pub trait AsBindGroup: Sized {
render_device: &RenderDevice,
images: &RenderAssets<Image>,
fallback_image: &FallbackImage,
) -> Result<PreparedBindGroup<Self>, AsBindGroupError>;
) -> Result<PreparedBindGroup<Self::Data>, AsBindGroupError>;

/// Creates the bind group layout matching all bind groups returned by [`AsBindGroup::as_bind_group`]
fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayout;
fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayout
where
Self: Sized;
}

/// An error that occurs during [`AsBindGroup::as_bind_group`] calls.
Expand All @@ -277,10 +279,10 @@ pub enum AsBindGroupError {
}

/// A prepared bind group returned as a result of [`AsBindGroup::as_bind_group`].
pub struct PreparedBindGroup<T: AsBindGroup> {
pub struct PreparedBindGroup<T> {
pub bindings: Vec<OwnedBindingResource>,
pub bind_group: BindGroup,
pub data: T::Data,
pub data: T,
}

/// An owned binding resource of any type (ex: a [`Buffer`], [`TextureView`], etc).
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/skybox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl AsBindGroup for CubemapMaterial {
render_device: &RenderDevice,
images: &RenderAssets<Image>,
_fallback_image: &FallbackImage,
) -> Result<PreparedBindGroup<Self>, AsBindGroupError> {
) -> Result<PreparedBindGroup<Self::Data>, AsBindGroupError> {
let base_color_texture = self
.base_color_texture
.as_ref()
Expand Down