Loading NiagaraSystems in PIE causes many calls to UpdateAllPrimitiveSceneInfos()

This question was created in reference to: [Very slow PIE starts with UE [Content removed]

As requested by Stu here is the CallStack. Sorry for the long delay to provide it:

UNiagaraSystem::UpdateSystemAfterLoad()
UNiagaraSystem::CacheFromCompiledData()
FVersionedNiagaraEmitterData::CacheFromCompiledData()
UNiagaraSpriteRendererProperties::CacheFromCompiledData()
UNiagaraSpriteRendererProperties::UpdateMICs()
UNiagaraRendererProperties::UpdateMaterialParametersMIC()
    BuildMaterialStaticParameterSet() returns true as we change static paramters in the emitter.
    We are freshly loaded, InOutMIC is nullptr and we make a new UMaterialInstanceConstant
UMaterialInstance::UpdateStaticPermutation()
    Because we just made a new InOutMIC its bHasStaticPermutationResource
    is still false so we need to set it and do update work.
    Because we didn't pass in a MaterialUpdateContext
    we make a fresh local one that goes out of scope immediately.
    As it is made with FMaterialUpdateContext::EOptions::RecreateRenderStates,
    it has a FGlobalComponentRecreateRenderStateContext that goes out of scope
    right away, too, and calls UpdateAllPrimitiveSceneInfos().

Without the workarounds in the referenced ticket this makes PIE almost unusable. As our map grows and evolves the workarounds start to no longer be sufficient.

Steps to Reproduce
Start PIE in a WorldPartition map with

* Many Actors

* Many instances of Niagara Systems that have emitters that change static material parameters

Observe: Many costly calls to UpdateAllPrimitiveSceneInfos()

Hey,

Thanks for providing the callstack.

I had a quick look and loading into a level with MICs will cause the update to the be called, beyond that going in / out of PIE I don’t get any further calls as the permutation set is the same.

I do know that we have refactored this code quite a bit since 5.5, it might be worthwhile trying to integrate over the changes to UNiagaraRendererProperties::UpdateMaterialParametersMIC to see if that helps at all?

Thanks,

Stu

Bump to keep the ticket open. Still in the middle of upgrading…

Initial testing suggests that PIE startups in 5.6 (with the workarounds in the referenced ticket removed) is comparable to PIE startups in 5.5 (with the workarounds in the referenced ticket) :slight_smile:

Did you compare the MIC generation in 5.6 to 5.7? You may still need to pull some changes over, I would need to go check.

Thanks,

Stu

Thanks!

Looking at the newer versions of UpdateMaterialParametersMIC(), the logic to get pre-existing MICs looks promising. We are in the process of upgrading to UE 5.6, and will report back after we are done.