[5.8.4][PCG] Runtime-generated GPU instances are lost on any global render state recreation and never regenerated

Summary

With PCG runtime generation and GPU spawning, the spawned instances live only in the GPU scene (UPCGProceduralISMComponent). When the render state of all components is recreated globally (FGlobalComponentRecreateRenderStateContext, e.g. from FMaterialUpdateContext with default options), these instances are erased, and PCG is not notified, so they are never regenerated. All runtime-generated content around the camera disappears until pcg.RuntimeGeneration.Refresh (Tools > PCG Framework > Refresh All Runtime Gen Components).

What Type of Bug are you experiencing?

World Creation Tools

Steps to Reproduce

  1. A level with a landscape and a PCG Volume with Generation Trigger = Generate At Runtime, hierarchical generation (grid 32 / 64 / 128 m), graph: Generate Landscape Textures → Custom HLSL point generator → Static Mesh Spawner, executed on the GPU.
  2. Wait until the vegetation appears around the editor camera.
  3. Open any Material asset (it does not need to be used in the level) and press Apply — or from Python: unreal.MaterialEditingLibrary.recompile_material(material).
  4. All runtime-generated instances disappear and do not come back. With pcg.RuntimeGeneration.EnableDebugging 1 there is no [RUNTIMEGEN] line after the recompile — the scheduler does not know the instances are gone.

Expected Result

The instances survive the render state recreation, or PCG regenerates the affected components.

Observed Result

All runtime-generated instances around the camera disappear immediately after the material is applied/recompiled and are never regenerated. With pcg.RuntimeGeneration.EnableDebugging 1 there is no [RUNTIMEGEN] line after the recompile — the runtime generation scheduler does not know the instances are gone. They come back only after pcg.RuntimeGeneration.Refresh (Tools > PCG Framework > Refresh All Runtime Gen Components). Reproducible 100 %.

Affects Versions

5.8

Platform(s)

Linux

Upload an image

For crash reports, include your callstack

Not a crash. Callstack at the moment the instances are lost (breakpoint in UPCGProceduralISMComponent::CreateSceneProxy):

Callstack when the instances are lost (breakpoint in UPCGProceduralISMComponent::CreateSceneProxy):

UPCGProceduralISMComponent::CreateSceneProxy
FActorPrimitiveComponentInterface::CreateSceneProxy
FScene::BatchAddPrimitivesInternal / FScene::AddPrimitive
UPrimitiveComponent::CreateRenderState_Concurrent
UStaticMeshComponent::CreateRenderState_Concurrent
FComponentRecreateRenderStateContext::~FComponentRecreateRenderStateContext
FGlobalComponentRecreateRenderStateContext::~FGlobalComponentRecreateRenderStateContext
FMaterialUpdateContext::~FMaterialUpdateContext

UPCGProceduralISMComponent::OnRenderStateDirty already handles the same loss for MarkRenderStateDirty (comment: “there is no explicit persistence of instance data in the GPU scene. When this component is dirtied, the instance data is cleared”) and refreshes the owning components. The global recreate path does not broadcast MarkRenderStateDirtyEvent, so that handler is never called.

Additional Notes

Related observations (same root cause, may be expected behaviour)

  1. Cold start: on the first session after opening a level, every material shader map that finishes loading (FShaderCompilingManager::ProcessCompiledShaderMaps → PropagateMaterialChangesToPrimitives → MarkRenderStateDirty → UPCGProceduralISMComponent::OnRenderStateDirty → UPCGSubsystem::RefreshAllComponentsFiltered) restarts the whole runtime generation, including the unbounded root. In my scene the root executes 10–16 times and the 128 m cells up to 6–8 times each during the first 15–40 s (editor and -game), versus once each in a warm session. Visible as flickering vegetation at startup.
  2. APCGPartitionActor::AddGraphInstance → UPCGComponent::SetPropertiesFromOriginal → UPCGGraphInstance::SetGraph → OnGraphParametersChanged → RefreshAfterGraphChanged issues an extra refresh for every partition actor taken from the pool.

Workaround: pcg.RuntimeGeneration.Refresh after anything that recreates render state globally.