/** Restores systems that need references to classes in the renderer module. */
void RestoreReferencesToRendererModuleClasses(
    const TMap<UWorld*, bool>& WorldsToUpdate,
    const TMap<FMaterialShaderMap*, TScopedPointer<TArray<uint8> > >& ShaderMapToSerializedShaderData,
    const TScopedPointer<TArray<uint8> >& GlobalShaderData,
    const TMap<FShaderType*, FString>& ShaderTypeNames,
    const TMap<FVertexFactoryType*, FString>& VertexFactoryTypeNames)
{
    FlushShaderFileCache();

    // Initialize cached shader type data
    InitializeShaderTypes();

    IRendererModule& RendererModule = GetRendererModule();

    FSceneViewStateReference::AllocateAll();

    // Recreate all renderer scenes
    for (TMap<UWorld*, bool>::TConstIterator It(WorldsToUpdate); It; ++It)
    {
        UWorld* World = It.Key();

        RendererModule.AllocateScene(World, World->RequiresHitProxies(), It.Value(), World->FeatureLevel);

        for (int32 LevelIndex = 0; LevelIndex < World->GetNumLevels(); LevelIndex++)
        {
            ULevel* Level = World->GetLevel(LevelIndex);
            Level->InitializeRenderingResources();
        }
    }

    // Restore FShaders from the serialized memory blobs
    // Shader maps may still not be complete after this due to code changes picked up in the recompile
    RestoreGlobalShaderMap(GRHIShaderPlatform_DEPRECATED, *GlobalShaderData);
    UMaterial::RestoreMaterialShadersFromMemory(GRHIShaderPlatform_DEPRECATED, ShaderMapToSerializedShaderData);
    FMaterialShaderMap::FixupShaderTypes(GRHIShaderPlatform_DEPRECATED, ShaderTypeNames, VertexFactoryTypeNames);

    TArray<FShaderType*> OutdatedShaderTypes;
    TArray<const FVertexFactoryType*> OutdatedFactoryTypes;
    FShaderType::GetOutdatedTypes(OutdatedShaderTypes, OutdatedFactoryTypes);

    // Recompile any missing shaders
    UMaterialInterface::IterateOverActiveFeatureLevels([&](ERHIFeatureLevel::Type FeatureLevel)
    {
        auto ShaderPlatform = GShaderPlatformForFeatureLevel[FeatureLevel];
        BeginRecompileGlobalShaders(OutdatedShaderTypes, ShaderPlatform);
        UMaterial::UpdateMaterialShaders(OutdatedShaderTypes, OutdatedFactoryTypes, ShaderPlatform);
    });

    // Block on global shader jobs
    FinishRecompileGlobalShaders();
}