The process of getting graphics pipeline(GpuProgramMetal.GetCachedPipeline on iOS) takes a lot of time when displaying for the first time

When displaying an effect that uses an Universal Render Pipeline/Unlit shader for the first time, the process of GpuProgramMetal.GetCachedPipeline on iOS and CreateGraphicsPipelineImpl on Android takes a lot of time.

In what cases does this occur and is there any way to avoid it?

Version of Unity: 2022.3.8f1
Version of URP: 14.0.8

Profiler result when the phenomenon occurred (iOS)

Profiler result when the phenomenon occurred (Android)

I’ve encountered this phenomenon as well and would like to know how to resolve it.

Yup, I’ve the same problem with unity version 2022.3.16f1 and URP version 14.0.9

@norimatsu_yusuke

Could you edit the name of the title to include : GpuProgramMetal.GetCachedPipeline , that will capture the attention of Unity internal engineer

We’re having this issue too, 2022.3.29f1, URP 14.0.11. Did any of you find a good solution? Haven’t been able to get rid of it by shader warmup APIs (it doesn’t seem to be triggered by a gpu shader upload, at least it doesn’t log anything or have a profiler entry for gpu program creation).

any solutions for this issue?
Still an issue in Unity 6000.0.23f1 on an ios platform

this is happening when the app load the shaders for first time.

to make sure this only happen once, make sure you setup shader variant correctly which include all the shaders in the game, and set it to load when the game launch… this way, the spike for loading the shader first time only happen once during the game lunch

The solution was provided to my by unity internal team on different thread

I’ve already tried using Shader Variant Collections to load the scene, but unfortunately, it hasn’t resolved the issue I’m facing. The first-time shader loading spike still occurs, especially with Skinned Mesh Objects on iOS.

Yes, thats the point , the shader loading spike only happen at first time… and not again during the game

That’s exactly the problem. Even when I load the Shader Variant Collection at the start of the game using shaderVariantCollection.WarmUp(), it seems like Unity ignores this step. I’ve enabled shader compilation logging, and unfortunately, I still see shaders being uploaded to the GPU despite preloading them.

For example, I get logs like this:

Uploaded shader variant to the GPU driver: Universal Render Pipeline/Lit, pass: ForwardLit, stage: vertex, keywords EVALUATE_SH_VERTEX LIGHTMAP_ON _FORWARD_PLUS _LIGHT_LAYERS _MAIN_LIGHT_SHADOWS _NORMALMAP.

So even though the shaders should be warmed up, they still get uploaded when first encountered in-game.

At the following thread, the cause of the problem and the solution seem to be described.

For Unity 6, however that is an experimental API, GraphicsStateCollection warmup will help us.