-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Replace rather than update Metal buffers #1842
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a nice, small change.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1842 +/- ##
==========================================
+ Coverage 85.83% 85.85% +0.02%
==========================================
Files 568 568
Lines 27975 27986 +11
==========================================
+ Hits 24012 24028 +16
+ Misses 3963 3958 -5 ☔ View full report in Codecov by Sentry. |
Bloaty Results 🐋Compared to main
Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-1842-compared-to-main.txtCompared to d387090 (legacy)
Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-1842-compared-to-legacy.txt |
After some panning & zooming the street name labels are drawn in the wrong place. Maybe some UBO buffer is not getting updated and the matrix is wrong? RPReplay_1842.MP4 |
Replace Metal-specific `Context::clear` with common `performCleanup`. Add stats logging to the end of benchmarking. Simplify stats checking in stencil test.
About 1/3 of buffers above the 4k threshold in the benchmark, but only 11K of 1.8M = 0.6% of updates are to large buffers.
|
With #1831, small non-index buffers (<= 4KiB) are encoded directly into the render command encoder rather than referenced as buffers. This should eliminate sequencing problems where the buffer is updated while the previous frame rendering is still using them.
In order to avoid the same problem with larger buffers (e.g., vertex attributes), this change makes buffer updates allocate a new Metal buffer instead of modifying an existing one. Index buffers were already being replaced rather than updating.
The effect on performance in the benchmarks seems minimal, but cases where the vertex buffers are large and changing regularly (e.g., symbols with layout in dense areas) there may be a more significant effect.
The previous buffers will remain allocated until they are no longer referenced, so memory utilization will increase somewhat.