mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 13:13:49 +00:00
74c97332a6
# Objective Currently, if a large amount of inactive cameras are spawned, they will immensely slow down performance. This can be reproduced by adding ```rust let default_image = images.add(default()); for _ in 0..10000 { commands.spawn(Camera3dBundle { camera: Camera { is_active: false, target: RenderTarget::Image(default_image.clone()), ..default() }, ..default() }); } ``` to for example `3d_shapes`. Using `tracy`, it's clear that preparing view bind groups for all cameras is still happening. Also, visibility checks on the extracted views from inactive cameras also take place. ## Performance gains The following `tracy` comparisons show the effect of skipping this unneeded work. Yellow is Bevy main, red is with the fix. ### Visibility checks ![bevy-visibility-check-savings](https://github.com/bevyengine/bevy/assets/52322338/154a20ce-bd70-487e-a85c-8b993950ea2b) ### Bind group preparation ![bevy-mesh2d-savings](https://github.com/bevyengine/bevy/assets/52322338/a48d8d9a-8c37-4c34-9698-b1b1bf01f070) ## Solution - Check if the cameras are inactive in the appropriate places, and if so skip them ## Changelog ### Changed - Do not extract views from inactive cameras or check visiblity from their extracted views Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com> Co-authored-by: Torstein Grindvik <torstein.grindvik@muybridge.com> |
||
---|---|---|
.. | ||
visibility | ||
window | ||
mod.rs | ||
view.wgsl |