-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
wgpu re-exports are inconsistent and confusing #3823
Comments
I am definitely in favor of a more coherent re-export strategy. I'll defer to @superdump on the details though. |
Indeed, I fully sympathize and spent much time myself hunting for the place where a particular |
Agreed, current one is confusing. Actually, I did not know of the wgpu re-exports and for some reason rust-analyzer auto-import did suggest them from the render_resource path. Ended up adding wgpu dependency to my crate. The re-export would be better solution. |
The problem is that we want to not reexport wgpu types that we wrap for reference counting purposes. But maybe exporting wgpu as a module indeed solves this as an IDE or rust-analyzer should suggest multiple imports. People can still make mistakes but they should be able to figure it out. What do you think @cart ? |
Heres my rationale for not blanket exporting wgpu:
Note that (1) might ultimately be resolved if wgpu exposes their internal "resource id" api to public consumers. We've asked for that in the past and the wgpu devs seemed open to it. I'm of the opinion that if we are missing types we think users need, we should re-export them. The biggest pain point so far is "missing re-exports". And thats because nobody has done a "full pass" over wgpu types to export whats needed. Instead we've taken an "add exports as they are needed" approach, which obviously will create friction in the early days. |
I wasn't suggesting that the |
This is especially annoying when bevy includes functions that depend on these unexported wgpu types, like how https://docs.rs/bevy/latest/bevy/render/renderer/struct.RenderDevice.html#method.poll depends on https://docs.rs/wgpu/latest/wgpu/type.Maintain.html . At the very least bevy should re-export these types that it requires as arguments, or provide and document a constructor or wrapper type for these cases. |
Some re-exports have conflicting names with bevy types. Sometimes these are renamed with a
Wgpu
prefix and other times they are renamed with aRaw
prefix. The current mechanism re-exports each item individually and can easily fall out of date and miss things.What solution would you like?
It would be a lot nicer to simply re-export wgpu as a module instead of the individual items. In other words, use this:
instead of this:
bevy/crates/bevy_render/src/render_resource/mod.rs
Lines 23 to 42 in 4134577
The
wgpu
crate name (and when re-exported wholesale as a module) is short enough that it is not tedious to simply always use the fully qualified name (e.g.wgpu::Buffer
). This usage is pretty common in the wgpu ecosystem including other areas of bevy.What problem does this solve or what need does it fill?
Re-exporting the crate as a module makes things much more consistent and reduces the maintenance burden of having to add every wgpu type manually.
What alternative(s) have you considered?
Leave things as they are.
Additional context
I can draft a PR if there's interest in making this change.
The text was updated successfully, but these errors were encountered: