Global Shaders on bootup engine loop

Hello,

I was wondering if I could get some insight into the global shader map on engine launch loop.

In some games, engine launch involves compiling shaders and this seems to be timely for some hardware specs where the engine launch time is noticeably longer.

I know in some games, users would see a “Compiling shaders…” screen. Is there a hook into an engine event or shader compiler manager event where we can present users a loading screen for this with progress %?

What are your recommendations?

Thanks!

Steps to Reproduce
Simple application bootup

The global shader map partially uses the PSO precaching mechanism. Games that display a loading screen usually fly through their level ahead of time to find all possible shader permutations to compile for a PC platform (consoles do not need to do this due to their fixed hardware constraints). The PSO precaching guide has a section on how to display a loading screen for this scenario: https://dev.epicgames.com/documentation/en\-us/unreal\-engine/pso\-precaching\-for\-unreal\-engine\#loading\-screen. You need to query FShaderPipelineCache::NumPrecompilesRemaining() each frame to find out how many PSO compilation tasks are still in-flight and exit the loading screen once your count hits 0. I hope that clears things up for you, but if you have any remaining questions, please let me know.

Hi William,

Sorry for the long delay in responding. I was out of the office for Unreal Fest this past week and am just trying to catch up now.

When you say games fly through their level ahead of time to find all permutations, what do you mean exactly? How do you invoke these precompiles ahead of time?

From what I have seen from other licensees, they would create a camera actor or similar actor right when you make the EngineLoadingScreen (see my answer below), turn off collisions, and literally move the camera through the level. This should trigger shader PSO compilations as the camera performs a flythrough with no other intervention having to be done by you. You would of course hide this with the loading screen until you are finished.

For the initial loading screen, is this past the engine launch loop where we can invoke UMG? Or is this an initial loading screen found in “PreloadScreenManager”?

I suggest you look at the PreLoadScreenBase.h header file, which is our base implementation for handling all loading screen flows. Ideally, you would create a standalone loading screen plugin that calls FPreloadScreenManager::RegisterPreLoadScreen, which should let you display a loading screen at the right time, such as when loading into a level.

You are welcome. I am going to close out the ticket, but if you have any further questions, please feel free to open another one.

Thanks Tim,

Just a few follow-up questions:

  • When you say games fly through their level ahead of time to find all permutations, what do you mean exactly? How do you invoke these precompiles ahead of time?
  • For the initial loading screen, is this past the engine launch loop where we can invoke UMG? Or is this an initial loading screen found in “PreloadScreenManager”?

No worries and thank you!