-
-
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
extensible view bindgroups / reusable binding definitions #6738
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backlog cleanup: @robtfm hard keeping 76 files up to date with |
Backlog cleanup: closing due to inactivity, would be considerable bitrot to combat at this point. |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
@group(0)
/view bind groupsSolution
builds on #5703.
beefed up
OwnedBindingResource
from bind_group.rs, currently used forAsBindGroup
implsDynamicBuffer
variant, including the dynamic offsetOwnedBindingResource
s forUniformBuffer
/DynamicUniformBuffer
(todo: add helpers to more resource types, storage buffer etc)created
AutoBindGroupPlugin
to manage automatic bindgroupsrender_app.add_plugin(AutoBindGroupPlugin::<MeshViewBindGroup, With<RenderPhase<Opaque3d>>>::default())
(for pbr)G
is a bind group marker struct, andF
is a filter that defines which entities the bind group is generated forcreated
AutoBinding
trait which encapsulates info about a binding; the shader variable name, binding layout, and data sourceAutoBinding
on first use (so that any combo ofAutoBinding
s can be added to anyAutoBindGroup
- webgpu allows binding slots up to 65536 so there is lots of room)AutoBinding
for all the current main pipeline@group(0)
bind group entries (excl post-processing)view
andglobals
bindings into bevy_renderused automatically managed binding slots for auto bindings in .wgsl shaders by specifying
@binding(auto)
@binding(auto)
syntax@binding(auto)
isn't strictly necessary and code using@binding(0)
,@binding(1)
etc will still generally work (though the binding slots will not necessarily be 0, 1 any more). and if multiple plugins add to the same bind group and both use the same binding slot, they will be mapped to separate binding slots anyway. but if the naga_oil validation is switched on (as it is in debug builds by default) then duplicate binding slot definitions cause validation errors. anyway, i think it is clearer to say@binding(auto)
to indicate that you can't actually tell what the slot value will be.allowed users/plugins to add new AutoBinding items to the builtin auto bindgroups via
render_app.add_auto_binding<G: AutoBindGroup, B: AutoBinding>()
pbr_global_override.rs
(which also uses a function override to modify pbr's point light function using the user binding)allowed users/plugins to use core bindings in their own bindgroups via e.g.
render_app.add_auto_binding<MyBindGroup, bevy_pbr::mesh_view_bindings::PointLightsBinding>()
removed
view_layout
member for severalPipeline
s, these are now accessed statically viaauto_layout::<G>()
since they can be changed by user pluginsperf notes
this requires a lot of systems (one per binding per containing bindgroup), and bumps/drops
Arc
s on each resource every frame.for view bindgroups i think the capabilities are very much worth this small cost, and i notice no impact on benchmarks.
this auto strategy should maybe not be used for more high-frequency bindgroups like material / mesh (although allowing plugin extensions to
StandardMaterial
would be interesting ...)issues
can make it even harder to tell whats going wrong when wgpu throws binding mismatch errors, since you don't even know what slot refers to what data any more. there is logging for the binding slot allocation ("bevy_render::auto_binding=debug"), but we could consider adding a custom wgpu error handler as well.
migration guide
change the import location for the view and global bindings in user shaders:
change source for pipeline view_layouts to use
auto_layout::<G>()