Warm up PSOs
Warm up PSO collections on the GPU at runtime.
読み終わるまでの所要時間 2 分最終更新 1ヶ月前
Warm up PSO collections on the GPU at runtime.
To reduce stuttering, compile shaders and create PSOs before they're first needed, so that the graphics driver caches them to disk. This is called warming up, prewarming, or precooking graphics states. You usually warm up during a loading screen, either when your application starts or while loading a scene.
Warm up a collection
Once you've traced a PSO data collection, you can warm up the cached PSOs to disk.
To warm up a PSO data collection, you can use two API methods:
- GraphicsStateCollection.WarmUp schedules the creation of all PSOs in the collection.
- GraphicsStateCollection.WarmUpProgressively schedules the creation of a set number of PSOs in the collection. Progressive warm up can result in a smoother experience and prevent blocking the application.
The and prewarm methods return a job handle, which you can use to set whether Unity performs the warming synchronously or asynchronously.
GraphicsStateCollection.WarmUpGraphicsStateCollection.WarmUpProgressivelyUnity can also start warming PSOs from graphics state collections automatically before or after the first scene loads in your application. For more information, refer to Shader loading (Graphics Settings).
Unity creates PSOs and caches them to disk. The next time the GPU needs a PSO, it loads the PSO directly from the cache.
Check if shaders are warmed up
To check when Unity and the graphics driver compile shaders and create PSOs, search for the following profiler markers in the Profiler:
- for Unity creating a GPU-specific version of a shader variant.
Shader.CreateGPUProgram - for Unity creating a PSO.
CreateGraphicsGraphicsPipelineImpl