WorldClusters allocation is now dynamic, removed from composition update #5569
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactoring to limit the amount of LayerComposition updates.
Before: When a light was added / removed from the layer, the expensive composition update would execute. Part of the update was to assign world clusters (textures storing clustered lights) to individual layers based on their lights.
Now: The world clusters assignment takes place at the start of the frame. The layers lazily update their light hash values and world clusters are shared between layers based on this hash.
The is still a cost of computing a hash for a layer on frames lights are added / removed on it - but this is reasonably cheap.
Note that this is needed specifically for WebGL1 path, on other platforms we could use bitflag to encode layers and reject lights from a single clusters structure at runtime. One day.
Note that the composition still updates when lights are added / removed, and further refactoring is needed, this PR only addresses the clustered part of it.