I’m using FSkeletalMeshMerge class to merge skeletal meshes in runtime for my modular characters.
Everything works great so far for my need except that it has big performance hit. I call FSkeletalMeshMerge::DoMerge when I initialize characters and it ends up freezing the game for a frame or two.
Profiler says it took about 15ms(in editor but still relatively noticeable in build) and FSkeletalMeshMerge::FinalizeMesh takes the majority of the time.
I tried to put the whole DoMerge in a pool thread then it crashed from Check is In game thread. From the crashing code, I had an impression that this only works on game thread because it involves interaction with rendering thread? Is there still possibility to multi thread this function?
I think potentially I can always split the task into pieces and do them in ticks in game thread but does this work for FSkeletalMeshMerge::DoMerge? The code that release resource and init resources worries me that they might have to be done in one frame. But I had limited knowledge on rendering, please correct me if I am wrong.
Or is there any other way of optimizing this? Thanks.