Precaching global shaders with r.PSOPrecache.GlobalShaders = 2 crashes on startup

Hey folks!

We are currently trying to eliminate the need for manually recording PSOs and for this purpose we would like to enable automatic precaching for all global shaders. We have found this console variable, which supposedly should do just that:

But unfortunately it seems this is not properly implemented. I believe the problem is in PrecacheComputePipelineStatesForGlobalShaders:

I think this code should check whether the given shader is a compute shader or something else and call FPrecacheGraphicsPipelineCache::PrecacheGraphicsPipelineState instead for non-compute shaders, but I am not sure how or even if it is possible to get the necessary information to fill the FGraphicsPipelineStateInitializer required for calling this function.

Do you think there is an easy fix for this or will we just have to live with having to record PSOs to avoid stutters from these global shaders?

Cheers,

Dave

Steps to Reproduce

  • Start a cooked build with the console variable r.PSOPrecache.GlobalShaders set to 2
  • Observe that the game crashes on startup

Hi David, I was able to reproduce this issue as well, and I have not seen that we added a fix for this issue in our latest development stream. I assume we added the option solely for compute shaders, since they have historically taken way longer to compile; however, that does not explain why we have a choice also to precompile non-compute shaders. I have created a Jira so we can properly resolve this: https://issues.unrealengine.com/issue/UE\-366678\. In the meantime, you might need to run without that option to avoid the crash. How soon do you need a fix for this issue?

Ok, thanks for letting me know. If collecting a PSO bundle covers is acceptable to you right now, then we at least have a workaround in place for the time being. I will close out the case then, but do let me know if you find any other similar issues.

Hey Tim, thanks for looking into it!

It’s not urgent for us, since we can simply record PSOs the old fashioned way to work around this. Would just have been nice to have as this is one of the last remaining places where we haven’t found a way to asynchronously precache PSOs on demand.