-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 #9632
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
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.
I'm for these changes overall. It'll also make DLSS nicer when I get around to implementing that again :)
I do have some small code refactor suggestions that would be nice, if you don't mind doing them while you're here.
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.
I think we can and should make the API better, by swapping to a "field on RenderPlugin" strategy.
More importantly though, the extracted function needs to be unsafe
.
i believe i have implemented a better way to accomplish this |
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
I like the new initialization pattern a lot! Once there's a simple migration guide plus a SAFETY comment, this LGTM. |
where should i write the migration guide? |
It goes in the PR description, here's an example from one of mine: #9516 The migration guides get created from a script that scrapes these from the PRs so make sure the header is exact. E.g.
|
I want to carefully review this before it is merged. What is the reason for needing to provide the ‘future render resources’ from outside bevy? What configurability is missing? |
@superdump so the solution ended up actually changing. originally, i made |
It's mainly for importing rendering resources from outside of bevy. For instance, with XR, you have a specific vulkan resource, that you then map to a wgpu resource in a specific manner. For DLSS, I needed to use raw vulkan to load some extra nvidia-dlss-only extensions (so, stuff wgpu would never get) as part of device creation, and then create a wgpu device wrapping it. It's the kind of stuff bevy_render is never going to handle itself, for very specific platforms with custom rendering devices. |
i believe that is a satisfactory migration guide. if it needs improving please let me know |
Is there anything else holding this up now? |
Waiting on final review from |
crates/bevy_render/src/settings.rs
Outdated
RenderQueue, | ||
RenderAdapterInfo, | ||
RenderAdapter, | ||
Mutex<Instance>, |
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 mutex here is to allow interior mutability, which breaks the assumption that setting up a plugin doesn't mutate it
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.
(Not a bevy maintainer): from what I could tell, all methods on wgpu::Instance
are on a shared ref, and the type is Send
and Sync
. Is there a reason that cloning a Arc<wgpu::Instance>
cannot be used instead of taking from a Mutex<Instance>
?
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.
@mockersf my most recent commit should have fixed this. i implemented what @TheButlah recommended
i had to rebuild my pr since i was having some merge conflicts and forgot to make a new branch when i started making this pr, however, github won't let me reopen this PR without the original branch, so i had to create a duplicate of this pr here: #9925 |
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 - 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 <[email protected]> Co-authored-by: Robert Swain <[email protected]>
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 <[email protected]> Co-authored-by: Robert Swain <[email protected]>
Objective
Solution
Migration Guide
The
RenderPlugin
now takes aRenderSettings
enum instead ofWgpuSettings
.RenderSettings::default()
returnsRenderSettings::Automatic(WgpuSettings::default())
.