bevy/crates/bevy_pbr/src/meshlet
JMS55 3fb6cefb2f
Meshlet fill cluster buffers rewritten (#15955)
# Objective
- Make the meshlet fill cluster buffers pass slightly faster
- Address https://github.com/bevyengine/bevy/issues/15920 for meshlets
- Added PreviousGlobalTransform as a required meshlet component to avoid
extra archetype moves, slightly alleviating
https://github.com/bevyengine/bevy/issues/14681 for meshlets
- Enforce that MeshletPlugin::cluster_buffer_slots is not greater than
2^25 (glitches will occur otherwise). Technically this field controls
post-lod/culling cluster count, and the issue is on pre-lod/culling
cluster count, but it's still valid now, and in the future this will be
more true.

Needs to be merged after https://github.com/bevyengine/bevy/pull/15846
and https://github.com/bevyengine/bevy/pull/15886

## Solution

- Old pass dispatched a thread per cluster, and did a binary search over
the instances to find which instance the cluster belongs to, and what
meshlet index within the instance it is.
- New pass dispatches a workgroup per instance, and has the workgroup
loop over all meshlets in the instance in order to write out the cluster
data.
- Use a push constant instead of arrayLength to fix the linked bug
- Remap 1d->2d dispatch for software raster only if actually needed to
save on spawning excess workgroups

## Testing

- Did you test these changes? If so, how?
- Ran the meshlet example, and an example with 1041 instances of 32217
meshlets per instance. Profiled the second scene with nsight, went from
0.55ms -> 0.40ms. Small savings. We're pretty much VRAM bandwidth bound
at this point.
- How can other people (reviewers) test your changes? Is there anything
specific they need to know?
  - Run the meshlet example

## Changelog (non-meshlets)
- PreviousGlobalTransform now implements the Default trait
2024-10-23 19:18:49 +00:00
..
asset.rs Meshlet new error projection (#15846) 2024-10-22 20:14:30 +00:00
cull_clusters.wgsl Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
downsample_depth.wgsl Meshlet software raster + start of cleanup (#14623) 2024-08-26 17:54:34 +00:00
dummy_visibility_buffer_resolve.wgsl Meshlet rendering (initial feature) (#10164) 2024-03-25 19:08:27 +00:00
fill_cluster_buffers.wgsl Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
from_mesh.rs Meshlet builder improvements redux (#15886) 2024-10-23 16:56:50 +00:00
instance_manager.rs Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
material_pipeline_prepare.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
material_shade_nodes.rs Meshlet software raster + start of cleanup (#14623) 2024-08-26 17:54:34 +00:00
meshlet_bindings.wgsl Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
meshlet_mesh_manager.rs Meshlet new error projection (#15846) 2024-10-22 20:14:30 +00:00
meshlet_mesh_material.wgsl Meshlet misc (#13761) 2024-06-10 13:06:08 +00:00
meshlet_preview.png Meshlet rendering (initial feature) (#10164) 2024-03-25 19:08:27 +00:00
mod.rs Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
persistent_buffer.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
persistent_buffer_impls.rs Meshlet new error projection (#15846) 2024-10-22 20:14:30 +00:00
pipelines.rs Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
remap_1d_to_2d_dispatch.wgsl Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
resolve_render_targets.wgsl More triangles/vertices per meshlet (#15023) 2024-09-08 17:55:57 +00:00
resource_manager.rs Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
visibility_buffer_hardware_raster.wgsl Per-meshlet compressed vertex data (#15643) 2024-10-08 18:42:55 +00:00
visibility_buffer_raster_node.rs Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
visibility_buffer_resolve.wgsl Meshlet fill cluster buffers rewritten (#15955) 2024-10-23 19:18:49 +00:00
visibility_buffer_software_raster.wgsl Meshlet fix software rasterization (#16049) 2024-10-22 23:05:40 +00:00