Optimization Patch for Reducing Allocations in Entities Graphics System [1.2.0]

Hello Unity Developers,

I’ve been working on optimizing the Entities Graphics System, particularly focusing on reducing unnecessary memory allocations that occur due to property getters in RenderMeshArray. I’ve noticed that accessing Meshes and Materials properties frequently during rendering can lead to significant performance drops due to repeated array copying.

To address this, I’ve created a patch that modifies the EntitiesGraphicsSystem and RenderMeshArray classes to use internal arrays directly instead of going through the property getters. This change has shown a noticeable reduction in memory allocations and an improvement in the execution time of the RegisterMaterialsAndMeshesSystem.RegisterMaterialsAndMeshes method.

I’ve attached the patch file here for anyone facing similar issues or interested in improving the performance of their game’s rendering system. Please feel free to try it out and share your results or any feedback you might have!

9772398–1400589–0001-Prevented-unnecessary-allocations-of-Meshes-Material.zip (1.61 KB)

3 Likes

Thank you for taking the time to write this! These issues have already been addressed and will be in the next release of entities.graphics. Note that MeshesInternal and MaterialsInternal have been renamed to MeshReferences and MaterialReferences and will now be public while the allocating ones have been deprecated.

4 Likes