Open azrogers opened 1 month ago
@azrogers do you think it will be straightforward to extend this approach to also support external schemas (#727) in a follow-up PR?
@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.
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 aSharedAsset
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):
SharedAsset
contains either a pointer to a stored asset and counter, or it contains the asset itself if noSharedAssetDepot
was provided. This means that the "smart pointer" is at least 96 bytes (the size of ImageCesium), even if it does contain a pointer, which is unacceptable. I'm not sure what to do about this, short of just requiring the use of aSharedAssetDepot
- but this would increase the number of necessary code changes to other projects that use CesiumGltf besides the native runtimes.SharedAssetDepot.h
is almost certainly not compatible with the style guide (I started it before the meeting) so I need to fix that.