bevy/crates/bevy_ui/src/render
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
..
mod.rs Ignore inactive cameras (#10543) 2023-11-14 02:13:21 +00:00
pipeline.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
render_pass.rs Fix UI borders (#10078) 2023-10-13 17:17:16 +00:00
ui.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
ui_material.wgsl Add UI Materials (#9506) 2023-11-03 22:33:01 +00:00
ui_material_pipeline.rs UI Materials: ignore entities with a BackgroundColor component (#10434) 2023-11-07 20:04:10 +00:00
ui_vertex_output.wgsl Add UI Materials (#9506) 2023-11-03 22:33:01 +00:00