Add a bindless mode to AsBindGroup
.
#16368
Draft
+999
−170
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.
This adds the infrastructure necessary for Bevy to support bindless resources. Bindless resources significantly improve rendering performance by reducing
wgpu
and driver overhead considerably.TODO: Write more here.
Copied and pasted from the new
AsBindGroup
documentation:bindless(COUNT)
supplies resources (uniforms, textures, and samplers) to the shader.
When bindless resources are enabled, and the current platform supports
them, instead of presenting a single instance of a resource to your
shader Bevy will instead present a binding array of
COUNT
elements.In your shader, the index of the element of each binding array
corresponding to the mesh currently being drawn can be retrieved with
mesh[in.instance_index].material_bind_group_slot
.state changes. By grouping resources together into binding arrays, Bevy
doesn't have to modify GPU state as often, decreasing API and driver
overhead.
BINDLESS
definition will beavailable. Because not all platforms support bindless resources, you
should check for the presence of this definition via
#ifdef
and fallback to standard bindings if it isn't present.
shaders/shader_material_bindless
example for an example ofhow to use bindless mode.
This should be ready except for documentation. I'm submitting it now as a draft since this shouldn't land before 0.15 is released anyway.
Here's a Tracy profile of
submit_graph_commands
of this patch and an additional patch (not submitted yet) that makesStandardMaterial
use bindless. Red is those patches; yellow ismain
. The scene was Bistro Exterior with a hack that forces all textures to opaque. You can see a 1.47x mean speedup.Migration Guide
RenderAssets::prepare_asset
now takes anAssetId
parameter.wgpu
material bind group IDs, as part of the bindless change. Use the newMaterialBindGroupAllocator
to map from bind group index to bind group ID.