Search Issue Tracker
In Progress
Fixed in 2023.2.0a12
Fix In Review for 2021.3.27f1, 2022.2.X, 2022.3.1f1, 2023.1.0b20
Votes
3
Found in
2021.3.22f1
2022.2.12f1
2022.3.0f1
2023.1.0b9
2023.2.0a9
Issue ID
UUM-32183
Regression
No
GC Alloc when using Graphics.RenderMeshInstanced
Reproduction steps:
1. Open the attached project "RenderMeshInstanced_ArgumentException"
2. Open "SampleScene"
3. Enable Deep Profile in the Profiler window
4. Enter Play mode, wait for the grass to load in the Game view
5. Select a frame in the CPU Usage module of the Profiler window
6. Sort by GC Alloc
Expected result: there is no GC Alloc
Actual result: there is 89.4 KB of GC Alloc under PlayerLoop>Update.ScriptRunBehaviourUpdate>BehaviourUpdate>GrassGPUInstancing.Update>Graphics.RenclerMeshInslanced>RenderInstancedDataLayout..ctor>Marshal.OffsetOf
Reproducible with: 2021.3.22f1, 2022.2.12f1, 2023.1.0b9, 2023.2.0a9
Could not test with: 2020.3.46f1 (compilation errors)
Reproducible on: macOS 13.2.1 (Intel), Windows 11 (user's)
Workaround: also using "if (!(t == typeof (Matrix4x4)))" for "prevObjectToWorld" and "renderingLayerMask" as it is already done for "objectToWorld"
Note: forum further discussing the issue https://forum.unity.com/threads/graphics-rendermeshinstanced-generates-gc-and-is-slower-than-graphics-drawmeshinstanced.1367628/#post-8632140
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- VFX Blackboard: Duplicated items numbers misses brackets
- [Android] TouchScreenKeyboard.active triggers an error when set to false in the Player
- [Android] Auto-correct suggestions show up over the "hidden zone" when typing text with TouchScreenKeyboard
- [Android] Clicks on the "hidden zone" remain blocked when TouchScreenKeyboard is active
- [URP][DX12] Black Game View window when URP Dynamic Resolution is enabled
Resolution Note (fix version 2023.1.0b20):
Fixed: Provide a way to avoid GC.Alloc with RenderMeshInstanced
Resolution Note (fix version 2022.3.1f1):
Fixed: Provide a way to avoid GC.Alloc with RenderMeshInstanced
Resolution Note (fix version 2022.2):
Fixed: Provide a way to avoid GC.Alloc with RenderMeshInstanced
Resolution Note (fix version 2021.3.27f1):
Fixed: Provide a way to avoid GC.Alloc with RenderMeshInstanced