CesiumGS / cesium-native

Apache License 2.0
414 stars 210 forks source link

Cache images across glTFs to avoid duplication #926

Open azrogers opened 1 month ago

azrogers commented 1 month ago

As described in #497, sometimes tilesets contain multiple tiles that point to the same image resources. At the moment, these images are loaded once for every tile that uses them, meaning a tileset with 1,000 tiles that use the same image will load that image 1,000 times (and the runtimes will allocate video memory for each of them). This change adds a SharedAssetDepot class that stores images across tiles, and a SharedAsset smart pointer type for tracking and cleaning up the images.

SharedAssetDepot is set up so that in the future, if we need, we can extend this feature to handle glTF buffers as well.

There's a few TODO items currently (besides the runtime implementations):

lilleyse commented 3 weeks ago

@azrogers do you think it will be straightforward to extend this approach to also support external schemas (#727) in a follow-up PR?

azrogers commented 3 weeks ago

@lilleyse I've designed the SharedAssetDepot to support multiple kinds of assets, though only images are implemented in this PR. It should support extending it to also handle loading external schemas.