Repository navigation
Improve image/glyph atlas packing algorithm - #7171
Conversation
|
Awesome @mourner ! A good place to test is around here - rotate and pan to load as many tiles as possible! |
|
@bhousel I ran some modified benchmarks from ShelfPack that stress the "low height variation" case (with |
46fa816 to
46836aa
Compare
|
@mourner the As part of #7207, however, we may need to be able to modify/add sprites to these |
|
@mollymerp great! I'll push the Quick question — one render test ( |
|
This is now ready for review. |
| "pngjs": "^3.0.0", | ||
| "postcss-cli": "^5.0.0", | ||
| "postcss-inline-svg": "^3.1.1", | ||
| "potpack": "^1.0.1", |
There was a problem hiding this comment.
Shouldn't this be a regular dependency rather than a dev dependency?
There was a problem hiding this comment.
Yeah, my misstep, although it actually doesn't affect anything because GL JS is only usable with the built bundle. We might want to move most other regular deps to devdeps then.
Since our current binpacking uses are mostly static, I found a simple packing algorithm that produces smaller glyph and image atlases than
shelf-pack— for a typical streets z11 view, about 20% less pixels in average. This may not be reflected noticeably on the benchmarks, but it means textures will use less memory and be faster to upload to GPU on tile loads.In this PR, I've only switched worker-side atlases to the new packing since they're fully static. The next step would be to replace
shelf-packinimage_manager.jsfor currently used patterns, but that would mean replacing dynamic insertion/removal of individual images with repacking all patterns every time one is added/removed. This may be fine because there are only a couple patterns on the screen at a time on typical styles, not thousands where it could be perf a problem.If the approach sounds OK, I can work on this further and also likely publish the algorithm as a separate ES module.
shelf-packwould still remain our module of choice for dynamic use cases.cc @jfirebaugh @bhousel
Benchmarks
Launch Checklist
write tests for all new functionalitydocument any changes to public APIs