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
Improve performance by binning together opaque items instead of sorting them. #12453
Merged
Commits on Mar 13, 2024
-
Improve performance by binning together opaque items instead of sorting
them. Today, we sort all entities added to all phases, even the phases that don't strictly need sorting, such as the opaque and shadow phases. This results in a performance loss because our `PhaseItem`s are rather large in memory, so sorting is slow. Additionally, determining the boundaries of batches is an O(n) process. This commit makes Bevy instead applicable place phase items into *bins* keyed by *bin keys*, which have the invariant that everything in the same bin is potentially batchable. This makes determining batch boundaries O(1), because everything in the same bin can be batched. Instead of sorting each entity, we now sort only the bin keys. This drops the sorting time to near-zero on workloads with few bins like `many_cubes --no-frustum-culling`. Memory usage is improved too, with batch boundaries and dynamic indices now implicit instead of explicit. The improved memory usage results in a significant win even on unbatchable workloads like `many_cubes --no-frustum-culling --vary-material-data-per-instance`, presumably due to cache effects. Not all phases can be binned; some, such as transparent and transmissive phases, must still be sorted. To handle this, this commit splits `PhaseItem` into `BinnedPhaseItem` and `SortedPhaseItem`. Most of the logic that today deals with `PhaseItem`s has been moved to `SortedPhaseItem`. `BinnedPhaseItem` has the new logic. FPS results are as follows: | Benchmark | `binning` | `main` | Speedup | | ------------------------ | --------- | ------- | ------- | | `many_cubes -nfc -vmdpi` | 4.608 | 3.373 | 36.61% | | `many_cubes -nfc` | 42.161 | 35.437 | 18.97% | | `many_foxes` | 308.943 | 303.321 | 1.85% | (`-nfc` is short for `--no-frustum-culling`; `-vmdpi` is short for `--vary-material-data-per-instance`.)
Configuration menu - View commit details
-
Copy full SHA for 8625fd3 - Browse repository at this point
Copy the full SHA 8625fd3View commit details -
Configuration menu - View commit details
-
Copy full SHA for bf394b0 - Browse repository at this point
Copy the full SHA bf394b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for f70baba - Browse repository at this point
Copy the full SHA f70babaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1903a47 - Browse repository at this point
Copy the full SHA 1903a47View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6604632 - Browse repository at this point
Copy the full SHA 6604632View commit details
Commits on Mar 19, 2024
-
Configuration menu - View commit details
-
Copy full SHA for f26961a - Browse repository at this point
Copy the full SHA f26961aView commit details
Commits on Mar 20, 2024
-
Configuration menu - View commit details
-
Copy full SHA for dd53692 - Browse repository at this point
Copy the full SHA dd53692View commit details -
Configuration menu - View commit details
-
Copy full SHA for c1e9035 - Browse repository at this point
Copy the full SHA c1e9035View commit details -
Configuration menu - View commit details
-
Copy full SHA for c017e6f - Browse repository at this point
Copy the full SHA c017e6fView commit details
Commits on Mar 25, 2024
-
Configuration menu - View commit details
-
Copy full SHA for d040787 - Browse repository at this point
Copy the full SHA d040787View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4178fe8 - Browse repository at this point
Copy the full SHA 4178fe8View commit details
Commits on Mar 26, 2024
-
Configuration menu - View commit details
-
Copy full SHA for ef78989 - Browse repository at this point
Copy the full SHA ef78989View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6692299 - Browse repository at this point
Copy the full SHA 6692299View commit details -
Configuration menu - View commit details
-
Copy full SHA for 67a5f10 - Browse repository at this point
Copy the full SHA 67a5f10View commit details
Commits on Mar 27, 2024
-
Fix shadows in
3d_shapes
and dynamic uniform indices.This commit fixes two bugs: 1. Shadow bin keys didn't contain the mesh IDs, causing us to incorrectly batch things together that shouldn't have been. 2. Splitting batches for dynamic uniform IDs caused `batchable_keys` and `batches` to get out of sync, messing up the rendering in `many_cubes` on WebGL 2. This fixes the issue by explicitly storing both instance ranges and dynamic uniforms for both batchable and unbatchable items.
Configuration menu - View commit details
-
Copy full SHA for ca56bac - Browse repository at this point
Copy the full SHA ca56bacView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3e4d2cd - Browse repository at this point
Copy the full SHA 3e4d2cdView commit details
Commits on Mar 28, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 34d7160 - Browse repository at this point
Copy the full SHA 34d7160View commit details -
Configuration menu - View commit details
-
Copy full SHA for b7570d3 - Browse repository at this point
Copy the full SHA b7570d3View commit details
Commits on Mar 29, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 642ad9b - Browse repository at this point
Copy the full SHA 642ad9bView commit details -
Configuration menu - View commit details
-
Copy full SHA for ac9c978 - Browse repository at this point
Copy the full SHA ac9c978View commit details -
Configuration menu - View commit details
-
Copy full SHA for 269b385 - Browse repository at this point
Copy the full SHA 269b385View commit details -
Configuration menu - View commit details
-
Copy full SHA for 23ab07d - Browse repository at this point
Copy the full SHA 23ab07dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 638c7c2 - Browse repository at this point
Copy the full SHA 638c7c2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 18392b7 - Browse repository at this point
Copy the full SHA 18392b7View commit details
Commits on Mar 30, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 8959f0f - Browse repository at this point
Copy the full SHA 8959f0fView commit details
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.