bevy/crates
Torstein Grindvik 74c97332a6
Ignore inactive cameras (#10543)
# 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>
2023-11-14 02:13:21 +00:00
..
bevy_a11y Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_animation Fix animations resetting after repeat count (#10540) 2023-11-14 01:59:36 +00:00
bevy_app Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_asset Prepend root_path to meta path in HttpWasmAssetReader (#10527) 2023-11-14 01:29:22 +00:00
bevy_audio Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_core Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_core_pipeline Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_derive Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_diagnostic Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_dylib Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_dynamic_plugin Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_ecs Optimize Entity::eq (#10519) 2023-11-14 02:06:21 +00:00
bevy_ecs_compile_fail_tests Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
bevy_encase_derive Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_gilrs Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_gizmos #[derive(Reflect)] on GizmoConfig (#10483) 2023-11-11 21:26:41 +00:00
bevy_gltf Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_hierarchy Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_input Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_internal Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_log Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_macro_utils Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_macros_compile_fail_tests bevy_derive: Fix #[deref] breaking other attributes (#9551) 2023-08-28 17:36:18 +00:00
bevy_math Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_mikktspace Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_pbr Register WireframeColor (#10486) 2023-11-12 17:07:15 +00:00
bevy_ptr Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_reflect Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_reflect_compile_fail_tests Improve TypeUuid's derive macro error messages (#9315) 2023-10-02 12:42:01 +00:00
bevy_render Ignore inactive cameras (#10543) 2023-11-14 02:13:21 +00:00
bevy_scene Use EntityHashMap for EntityMapper (#10415) 2023-11-07 08:23:04 +00:00
bevy_sprite Add PartialEq to Anchor (#10424) 2023-11-07 08:36:10 +00:00
bevy_tasks Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_text Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_time Rename Timer::{percent,percent_left} to Timer::{fraction,fraction_remaining} (#10442) 2023-11-13 14:59:42 +00:00
bevy_transform Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_ui Ignore inactive cameras (#10543) 2023-11-14 02:13:21 +00:00
bevy_utils Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_window Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_winit Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00