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

Allowing the wgpu renderer to be created externally #2743

Conversation

Neo-Zhixing
Copy link
Contributor

@Neo-Zhixing Neo-Zhixing commented Aug 29, 2021

Objective

This PR makes it so that bevy_render2 will create the WGPU Renderer if and only if there isn't already one created. The motivation in my case is that this would allow me to create the WGPU instance from raw handles (gfx-rs/wgpu#1609)

Solution

To create the WGPU Renderer externally, the user needs to create bevy_render2::renderer::Renderer before initializing the bevy_render2 plugin and insert it into the world. bevy_render2 will try to remove the renderer from the world and use it upon initialization.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Aug 29, 2021
.insert_resource(queue.clone())
let renderer = app
.world
.remove_resource::<renderer::Renderer>()
Copy link
Member

Choose a reason for hiding this comment

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

This is to remove the Renderer resource if it exists right?

I would prefer an explicit check / branch over a removal here.

Copy link
Contributor Author

@Neo-Zhixing Neo-Zhixing Aug 29, 2021

Choose a reason for hiding this comment

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

It'll create ownership problems if we leave renderer::Renderer in App. Specifically, RenderInstance is not Clone. So, you can have RenderInstance in the app or the render subapp, but not both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants