Fix Vulkan crash with many Omni/SpotLights, Decals or ReflectionProbes #80845
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.
When ClusterBuilderRD attempted to allocate memory for a buffer, it accidentally reserved memory for RenderElementData pointers instead of actual structures. This caused it to allocate much less memory than it thought, so when enough cluster elements were in a scene it overflowed the buffer. Easy to see with ASAN enabled in the issue MRP, if it doesn't crash after some camera movement resizing the window seems to trigger this bug immediately every time.
By default
Max Clustered Elements
in ProjectSettings is 512 items. This times 4 (clustered item types) is 2048 elements. sizeof(RenderElementData) is 80 bytes and pointer size is 8, so only 10% of needed memory is actually allocated. 10% of 2048 elements is roughly 204, and as Calinou and qarmin noted 103 (or 102) OmniLights and SpotLights (total of 206 elements) will start crashing as this is roughly where the buffer overflows the actual allocated size (204 elements) and causes an access violation or memory corruption.