-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Allow other plugins to create renderer resources #9925
Conversation
works for me on macOS, iOS, Android, WebGL2 and WebGPU |
crates/bevy_render/src/settings.rs
Outdated
@@ -93,6 +96,45 @@ impl Default for WgpuSettings { | |||
} | |||
} | |||
|
|||
/// An enum describing how the renderer will initialize resources. This is used when creating the [`RenderPlugin`](crate::RenderPlugin). | |||
pub enum RenderSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The manual mode doesn't contain settings. @mockersf suggested calling it RenderCreation
instead. I much prefer that. With manual creation you provide the handles. With automatic, you provide the settings.
And I think maybe the Default trait can be derived if you annotate the Automatic variant with #[default]
, right? If not, keep the manual implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the #[default]
attribute can only be used on unit variants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the renaming of RenderSettings to RenderCreation and this is good to go I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still one minor variable name change that was missed.
Co-authored-by: Robert Swain <robert.swain@gmail.com>
Head branch was pushed to by a user without write access
I could be wrong, but should the migration guide be updated to reflect RenderCreation vs RenderSettings? |
This is a duplicate of bevyengine#9632, it was created since I forgot to make a new branch when I first made this PR, so I was having trouble resolving merge conflicts, meaning I had to rebuild my PR. # Objective - Allow other plugins to create the renderer resources. An example of where this would be required is my [OpenXR plugin](https://github.com/awtterpip/bevy_openxr) ## Solution - Changed the bevy RenderPlugin to optionally take precreated render resources instead of a configuration. ## Migration Guide The `RenderPlugin` now takes a `RenderCreation` enum instead of `WgpuSettings`. `RenderSettings::default()` returns `RenderSettings::Automatic(WgpuSettings::default())`. `RenderSettings` also implements `From<WgpuSettings>`. ```rust // before RenderPlugin { wgpu_settings: WgpuSettings { ... }, } // now RenderPlugin { render_creation: RenderCreation::Automatic(WgpuSettings { ... }), } // or RenderPlugin { render_creation: WgpuSettings { ... }.into(), } ``` --------- Co-authored-by: Malek <pocmalek@gmail.com> Co-authored-by: Robert Swain <robert.swain@gmail.com>
This is a duplicate of #9632, it was created since I forgot to make a new branch when I first made this PR, so I was having trouble resolving merge conflicts, meaning I had to rebuild my PR.
Objective
Solution
Migration Guide
The
RenderPlugin
now takes aRenderCreation
enum instead ofWgpuSettings
.RenderSettings::default()
returnsRenderSettings::Automatic(WgpuSettings::default())
.RenderSettings
also implementsFrom<WgpuSettings>
.