mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +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> |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_ecs_compile_fail_tests | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_macros_compile_fail_tests | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_reflect_compile_fail_tests | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |