-
-
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
Refactor check_light_mesh_visibility for performance #13900
Closed
Closed
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
janhohenheim
added
A-Rendering
Drawing game state to the screen
C-Performance
A change motivated by improving speed, memory usage or compile times
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
labels
Jun 17, 2024
Could you maybe make a separate PR for the split? It's a bit hard to review the other changes because it makes the diff very noisy |
This was referenced Jun 18, 2024
This has now been split :) |
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jun 26, 2024
# Objective - Second part of #13900 - based on #13905 ## Solution - check_dir_light_mesh_visibility defers setting the entity's `ViewVisibility `so that Bevy can schedule it to run in parallel with `check_point_light_mesh_visibility`. - Reduce HashMap lookups for directional light checking as much as possible - Use `par_iter `to parallelize the checking process within each system. --------- Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.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
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
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
check_light_mesh_visibility
system has unsatisfactory performance, as it involves multiple hash lookups for every mesh entity and lacks parallelizationSolution
split
check_light_mesh_visibility
tocheck_dir_light_mesh_visibility
andcheck_point_light_mesh_visibility
check_dir_light_mesh_visibility
defers setting the entity's viewVisibility so that Bevy can schedule it to run in parallel withcheck_point_light_mesh_visibility
.Reduce HashMap lookups for directional light checking as much as possible
Use par_iter to parallelize the checking process within each system.
Testing
cargo run --release --example many_cubes --features bevy/trace_tracy -- --shadows
command apply:
reduce from 4.88ms to 972+ 303 =1.2ms ,~4x speed up.
cargo run --release --example many_foxes --features bevy/trace_tracy -- --count 10000
command apply:
reduce from 646us to 142+ 97 =239us ,~3x speed up.
In the most common scenarios, there is usually one directional light and multiple point lights, and this PR should provide more advantages as direction light checking can run in parallel with point light checking.