CesiumGS / CesiumGS/cesium-native

Remove hardcoded tile size logic

Open
#748 0 comments 0 reactions 0 assignees View on GitHub
performance
Dominant language
C++
Stars
623
Forks
277
PR merge metrics
No merged PRs in 30d

Description

Right now the size of each tile is hardcoded to the size of the gltf model. Specifically in Unity but probably Unreal too there is no real reason to keep the gltf model in memory after the IPrepareRendererResources runs and you have created your game engine-specific resources. Our devices have very little working memory so it is imperative we free the gltf model immediately after using it to create the Unity meshes and textures.
I wanted to present the proposed changes as a pr but this is actually a bigger change than I thought and would love to discuss different solutions.
Right now I'm working with the idea that TileRenderContent now has a byteSize that can be set by the end user inside the IPrepareRenderResources. This can still be set to the gltf model like before or something else, this allows more flexibility as I can set it to a calculated value I get from my Unity resources as well as the size of RenderResources, in my case a collision mesh for each tile.
This works well except the notifyTileDoneLoading() which increments the TilesetContentManager _tilesDataUsed after the prepareInLoadThread but before the prepareInMainThread which is a problem as the final true size of the tile may not be known until after prepareInMainThread.

I attached an example of how I'm using setByteSize at the end of my prepareInMainThread
![image](https://github.com/CesiumGS/cesium-native/assets/13579475/40883f9d-a67f-4897-aa3e-c40917ff0d21)

Contributor guide

Open the contributing guide

Research direction

Start by tracing IPrepareRendererResources, IPrepareRenderResources, and notifyTileDoneLoading(), then inspect how TileRenderContent and TilesetContentManager track tile memory. Compare the proposed byteSize flow through prepareInLoadThread and prepareInMainThread. Done means the final engine-specific resource size can be supplied before memory accounting and the source glTF data can be released promptly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, unity, unreal-engine
Domain
computer-graphics, game-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.