-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Tracking Issue: GPU type refactor and bevy_gpu split #7157
Description
There have been discussions about splitting up the bevy_render module.
As a first and pretty straightforward step, we can refactor our wgpu GPU abstraction into its own crate.
The idea is to pull the entire render_resources module with all the wgpu and encase reexports, as well as most of the code of the render module into the new bevy_gpu crate.
This raises two major design questions:
Naming
The refactor opens up the possibility for more precise and consistent type and variable names.
Currently, we use no prefix for some types (e.g. Buffer, ComputePipeline) or the Render prefix for the remaining ones (e.g. RenderDevice, RenderQueue).
I propose three alternatives:
1. Gpu Prefix
- rexport all wgpu types with the
Gpuprefix (e.g.GpuDevice,GpuBuffer, etc.) - use a similar
gpu_prefix for variable names (e.g.gpu_device,gpu_buffer, etc.) - see Rename Render* to Gpu* #6968
2. Prefixless
- stick with the wgpu prefixless names (e.g. Device, Buffer, etc.)
- do not prefix variable names as well (e.g.
device,buffer) - see Drop Render* prefix #7109
3. Hybrid
- only use the Gpu prefix for some of the types and variables, similar to our current implementation
- how do we decide when to use which?
- this makes the API pretty inconsistent IMO
A quick poll on discord showed that many people are in favor of this change.
Exporting
Additionally, since this refactor is a major breaking change we can reconsider our GPU type reexporting strategy (which was marked with a todo comment: TODO: decide where re-exports should go).
We have got two options:
A. Root Export
- export all types at root level (e.g.
bevy::gpu::TypeName)
B. Module Export
- keep the current
render_resourcemodule and simply rename it togpu_resource(e.g.bevy::gpu::gpu_resource::TypeName) - we could elevate some types like
Device,Queue, etc. to the root level - again: how do we decide where which type belongs?
Solution
Both decisions are unrelated, so we can mix and match.
I think this refactor will take place in two phases.
First, the rename to either one of these three options described above.
Second, the split of all GPU-related types into the bevy_gpu crate and the reconsidered exporting strategy.
We could further subdivide these changes into smaller PRs, but this would break bevy main multiple times, and would probably confuse a lot of our users.
I prototyped phase one for both the Gpu Prefix in #6968 and the Prefixless alternative in #7109.
Based on that, phase two is implemented in PRs #7000 (Gpu Prefix & Module Export ) and #7111 (Prefixless & Root Export).
Let me know which propositions you like the most, or which alternatives I have not considered yet.
Please vote for your preferred strategy in this GitHub poll: #7169.