bevy/crates
Patrick Walton 0ede857103
Build batches across phases in parallel. (#17764)
Currently, invocations of `batch_and_prepare_binned_render_phase` and
`batch_and_prepare_sorted_render_phase` can't run in parallel because
they write to scene-global GPU buffers. After PR #17698,
`batch_and_prepare_binned_render_phase` started accounting for the
lion's share of the CPU time, causing us to be strongly CPU bound on
scenes like Caldera when occlusion culling was on (because of the
overhead of batching for the Z-prepass). Although I eventually plan to
optimize `batch_and_prepare_binned_render_phase`, we can obtain
significant wins now by parallelizing that system across phases.

This commit splits all GPU buffers that
`batch_and_prepare_binned_render_phase` and
`batch_and_prepare_sorted_render_phase` touches into separate buffers
for each phase so that the scheduler will run those phases in parallel.
At the end of batch preparation, we gather the render phases up into a
single resource with a new *collection* phase. Because we already run
mesh preprocessing separately for each phase in order to make occlusion
culling work, this is actually a cleaner separation. For example, mesh
output indices (the unique ID that identifies each mesh instance on GPU)
are now guaranteed to be sequential starting from 0, which will simplify
the forthcoming work to remove them in favor of the compute dispatch ID.

On Caldera, this brings the frame time down to approximately 9.1 ms with
occlusion culling on.

![Screenshot 2025-02-08
210720](https://github.com/user-attachments/assets/44bed500-e323-4786-b40c-828b75bc7d3f)
2025-02-13 00:02:20 +00:00
..
bevy_a11y Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_animation Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_app feat(ecs): configurable error handling for fallible systems (#17753) 2025-02-11 18:36:08 +00:00
bevy_asset Remove labeled_assets from LoadedAsset and ErasedLoadedAsset (#15481) 2025-02-10 21:06:37 +00:00
bevy_audio Support decibels in bevy_audio::Volume (#17605) 2025-02-10 21:26:43 +00:00
bevy_color Upgrade to wgpu v24 (#17542) 2025-02-09 19:40:53 +00:00
bevy_core_pipeline Switch bins from parallel key/value arrays to IndexMaps. (#17819) 2025-02-12 22:39:04 +00:00
bevy_derive Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_dev_tools Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_diagnostic Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_dylib Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_ecs Shorten the 'world lifetime returned from QueryLens::query(). (#17694) 2025-02-12 22:41:02 +00:00
bevy_encase_derive Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_gilrs Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_gizmos Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_gltf Add links to the types on the documentation of GltfAssetLabel (#17791) 2025-02-11 01:30:41 +00:00
bevy_image Allowed creating uninitialized images (for use as storage textures) (#17760) 2025-02-10 22:22:07 +00:00
bevy_input Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_input_focus Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_internal Use target_abi = "sim" instead of ios_simulator feature (#17702) 2025-02-11 23:01:26 +00:00
bevy_log Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_macro_utils Fix failing proc macros when depending on bevy through dev and normal dependencies. (#17795) 2025-02-11 18:28:15 +00:00
bevy_math Add ways to configure EasingFunction::Steps via new StepConfig (#17752) 2025-02-11 22:19:01 +00:00
bevy_mesh Upgrade to wgpu v24 (#17542) 2025-02-09 19:40:53 +00:00
bevy_mikktspace Move #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] to the workspace Cargo.toml (#17374) 2025-01-15 01:14:58 +00:00
bevy_pbr Build batches across phases in parallel. (#17764) 2025-02-13 00:02:20 +00:00
bevy_picking Add scroll functionality to bevy_picking (#17704) 2025-02-10 22:03:38 +00:00
bevy_platform_support Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_ptr Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_reflect Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_remote Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_render Build batches across phases in parallel. (#17764) 2025-02-13 00:02:20 +00:00
bevy_scene Allow users to register their own disabling components / default query filters (#17768) 2025-02-11 18:25:32 +00:00
bevy_sprite Build batches across phases in parallel. (#17764) 2025-02-13 00:02:20 +00:00
bevy_state Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_tasks Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_text Allowed creating uninitialized images (for use as storage textures) (#17760) 2025-02-10 22:22:07 +00:00
bevy_time Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_transform Improved Spawn APIs and Bundle Effects (#17521) 2025-02-09 23:32:56 +00:00
bevy_ui UI text extraction refactor (#17805) 2025-02-11 22:18:47 +00:00
bevy_utils Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_window Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_winit Allowed creating uninitialized images (for use as storage textures) (#17760) 2025-02-10 22:22:07 +00:00