Repository navigation
[Merged by Bors] - Make AsBindGroup unsized - #6937
Closed
JonahPlusPlus wants to merge 2 commits into
Closed
JonahPlusPlus wants to merge 2 commits into
JonahPlusPlus wants to merge 2 commits into
Conversation
Contributor
Author
|
Also, I've confirmed these changes to fix my problem in |
JonahPlusPlus
marked this pull request as ready for review
December 13, 2022 03:37
alice-i-cecile
approved these changes
Dec 13, 2022
james7132
approved these changes
Dec 14, 2022
cart
approved these changes
Dec 16, 2022
cart
left a comment
Member
There was a problem hiding this comment.
Yeah I'm definitely cool with this!
Member
|
bors r+ |
bors Bot
pushed a commit
that referenced
this pull request
Dec 16, 2022
# Objective `AsBindGroup` can't be used as a trait object because of the constraint `Sized` and because of the associated function. This is a problem for [`bevy_atmosphere`](https://github.com/JonahPlusPlus/bevy_atmosphere) because it needs to use a trait that depends on `AsBindGroup` as a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining to `AsBindGroup`. ## Solution Remove the `Sized` constraint from `AsBindGroup` and add the constraint `where Self: Sized` to the associated function `bind_group_layout`. Also change `PreparedBindGroup<T: AsBindGroup>` to `PreparedBindGroup<T>` and use it as `PreparedBindGroup<Self::Data>` instead of `PreparedBindGroup<Self>`. This weakens the constraints, but increases the flexibility of `AsBindGroup`. I'm not entirely sure why the `Sized` constraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases for `AsBindGroup` as a trait object or this was just leftover from legacy code?). --- ## Changelog - `AsBindGroup` can be used as a trait object.
AsBindGroup unsizedAsBindGroup unsized
james7132
pushed a commit
to james7132/bevy
that referenced
this pull request
Dec 16, 2022
# Objective `AsBindGroup` can't be used as a trait object because of the constraint `Sized` and because of the associated function. This is a problem for [`bevy_atmosphere`](https://github.com/JonahPlusPlus/bevy_atmosphere) because it needs to use a trait that depends on `AsBindGroup` as a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining to `AsBindGroup`. ## Solution Remove the `Sized` constraint from `AsBindGroup` and add the constraint `where Self: Sized` to the associated function `bind_group_layout`. Also change `PreparedBindGroup<T: AsBindGroup>` to `PreparedBindGroup<T>` and use it as `PreparedBindGroup<Self::Data>` instead of `PreparedBindGroup<Self>`. This weakens the constraints, but increases the flexibility of `AsBindGroup`. I'm not entirely sure why the `Sized` constraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases for `AsBindGroup` as a trait object or this was just leftover from legacy code?). --- ## Changelog - `AsBindGroup` can be used as a trait object.
3 of 10 tasks
alradish
pushed a commit
to alradish/bevy
that referenced
this pull request
Jan 22, 2023
# Objective `AsBindGroup` can't be used as a trait object because of the constraint `Sized` and because of the associated function. This is a problem for [`bevy_atmosphere`](https://github.com/JonahPlusPlus/bevy_atmosphere) because it needs to use a trait that depends on `AsBindGroup` as a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining to `AsBindGroup`. ## Solution Remove the `Sized` constraint from `AsBindGroup` and add the constraint `where Self: Sized` to the associated function `bind_group_layout`. Also change `PreparedBindGroup<T: AsBindGroup>` to `PreparedBindGroup<T>` and use it as `PreparedBindGroup<Self::Data>` instead of `PreparedBindGroup<Self>`. This weakens the constraints, but increases the flexibility of `AsBindGroup`. I'm not entirely sure why the `Sized` constraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases for `AsBindGroup` as a trait object or this was just leftover from legacy code?). --- ## Changelog - `AsBindGroup` can be used as a trait object.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Feb 1, 2023
# Objective `AsBindGroup` can't be used as a trait object because of the constraint `Sized` and because of the associated function. This is a problem for [`bevy_atmosphere`](https://github.com/JonahPlusPlus/bevy_atmosphere) because it needs to use a trait that depends on `AsBindGroup` as a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining to `AsBindGroup`. ## Solution Remove the `Sized` constraint from `AsBindGroup` and add the constraint `where Self: Sized` to the associated function `bind_group_layout`. Also change `PreparedBindGroup<T: AsBindGroup>` to `PreparedBindGroup<T>` and use it as `PreparedBindGroup<Self::Data>` instead of `PreparedBindGroup<Self>`. This weakens the constraints, but increases the flexibility of `AsBindGroup`. I'm not entirely sure why the `Sized` constraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases for `AsBindGroup` as a trait object or this was just leftover from legacy code?). --- ## Changelog - `AsBindGroup` can be used as a trait object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
AsBindGroupcan't be used as a trait object because of the constraintSizedand because of the associated function.This is a problem for
bevy_atmospherebecause it needs to use a trait that depends onAsBindGroupas a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining toAsBindGroup.Solution
Remove the
Sizedconstraint fromAsBindGroupand add the constraintwhere Self: Sizedto the associated functionbind_group_layout. Also changePreparedBindGroup<T: AsBindGroup>toPreparedBindGroup<T>and use it asPreparedBindGroup<Self::Data>instead ofPreparedBindGroup<Self>.This weakens the constraints, but increases the flexibility of
AsBindGroup.I'm not entirely sure why the
Sizedconstraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases forAsBindGroupas a trait object or this was just leftover from legacy code?).Changelog
AsBindGroupcan be used as a trait object.