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

Add new render function for raw wgpu. #974

Merged
merged 5 commits into from
Sep 6, 2024

Conversation

tychedelia
Copy link
Collaborator

@tychedelia tychedelia commented Jul 31, 2024

Adds a new render function type to the app builder that allows access to raw wgpu resources and restores the Frame concept for this function.

fn main() {
    nannou::app(model).render(render).run();
}

fn render(app: &RenderApp, model: &Model, frame: Frame) {
    // do something with `wgpu`
}

We originally had to remove Frame as it no longer made sense in Bevy's pipelined render model. In Bevy, wgpu resources are held in the render world, which means that we couldn't provide access to them in our default update, view, etc., functions. Additionally, because we now render into Bevy's Mesh component, there was no need to access these lower level wgpu concepts in view.

However, some users may still want to manually wire everything up themselves, and for this, we now provide render.

One major change here is the addition of a RenderApp type that mirrors App. Not all methods from App have been migrated here and due to the complexities of accessing the same data in the render world, we'll want to check to see what makes sense.

One caveat that I'm still a little nervous about is that Bevy provides a lot of utilities for stuff like creating bind groups, etc., that our users could really benefit from. Adding this render fn is a good bridge to minimize breaking changes for our existing users, but part of me still feels like new users could benefit from the reduced boilerplate offered by Bevy. More to consider later.

Notable changes:

  • To use render your model must have a M: Clone bound in order for it to be cloned into the render world. For the most part, this means putting Arc around any wgpu resources.
  • Because we are using a Bevy render node to place our wgpu operations in the context of Bevy's broader pipeline, users who wish to use msaa need to target the resolve attachment rather than the intermediate texture view.

How to review this:

Mostly you should look at the changes in nannou/src that show how we are wiring this into Bevy. The other changes are mostly just adding back the nannou_wgpu crate and minor changes to the examples to get them to compile. Those examples can be manually diffed against master in a local checkout to see what changed.

image

@tychedelia
Copy link
Collaborator Author

@MacTuitui this probably is too chaotic to review, but you may be interested in this one as it should drastically ease your migration onto the bevy version if you choose to do so. Let me know if you have any questions or concerns.

@tychedelia tychedelia merged commit 384f42e into nannou-org:bevy-refactor Sep 6, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants