Skip to content
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

Optimize tile calculations for globe #12050

Merged
merged 4 commits into from
Jun 29, 2022
Merged

Optimize tile calculations for globe #12050

merged 4 commits into from
Jun 29, 2022

Conversation

mourner
Copy link
Member

@mourner mourner commented Jun 29, 2022

When profiling globe view, I noticed that aabbForTileOnGlobe takes ~5% of CPU time, and makes quite a lot of allocations for a hot path function that's called many times per frame. This PR eliminates most redundant allocations, bringing it below 1% in the profiler. See the two self-contained commits:

  1. Instead of allocating a new scaled globe matrix every time, use transform's cached globeMatrix and scale things inline when calculating bounding volume corners.
  2. Eliminate most temporary arrays that are immediately discarded. As a part of this, also clean up some function signatures so that LngLat corners of a bounding box are encapsulated in LngLatBounds which we designated for such cases.

Launch Checklist

  • briefly describe the changes in this PR
  • manually test the debug page
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Improve rendering performance on globe view</changelog>

@mourner mourner added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Jun 29, 2022
@mourner
Copy link
Member Author

mourner commented Jun 29, 2022

@akoylasar the first commit could be ported to native since it appears to have the same redundancy.

Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@karimnaaji karimnaaji merged commit 147c385 into main Jun 29, 2022
@karimnaaji karimnaaji deleted the optimize-globe-aabb branch June 29, 2022 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants