-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore inactive cameras #10543
Merged
alice-i-cecile
merged 1 commit into
bevyengine:main
from
torsteingrindvik:inactive-cameras
Nov 14, 2023
Merged
Ignore inactive cameras #10543
alice-i-cecile
merged 1 commit into
bevyengine:main
from
torsteingrindvik:inactive-cameras
Nov 14, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
alice-i-cecile
added
A-Rendering
Drawing game state to the screen
C-Performance
A change motivated by improving speed, memory usage or compile times
labels
Nov 13, 2023
alice-i-cecile
approved these changes
Nov 13, 2023
JMS55
approved these changes
Nov 13, 2023
alice-i-cecile
added
the
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
label
Nov 13, 2023
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 14, 2023
# Objective - Reduce work from inactive cameras Tracing was done on the `3d_shapes` example on PR #10543 . Doing tracing on a "real" application showed more instances of unnecessary work. ## Solution - Skip work on inactive cameras Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com> Co-authored-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
rdrpenguin04
pushed a commit
to rdrpenguin04/bevy
that referenced
this pull request
Jan 9, 2024
# 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>
rdrpenguin04
pushed a commit
to rdrpenguin04/bevy
that referenced
this pull request
Jan 9, 2024
# Objective - Reduce work from inactive cameras Tracing was done on the `3d_shapes` example on PR bevyengine#10543 . Doing tracing on a "real" application showed more instances of unnecessary work. ## Solution - Skip work on inactive cameras Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com> Co-authored-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Rendering
Drawing game state to the screen
C-Performance
A change motivated by improving speed, memory usage or compile times
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Currently, if a large amount of inactive cameras are spawned, they will immensely slow down performance.
This can be reproduced by adding
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
Bind group preparation
Solution
Changelog
Changed