ドキュメント

Unity Engine


User Manual

Script Reference

Unity Engine


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.
注
The recommended best practice is to prewarm your collection during application or scene loading sequences.
To warm up a PSO data collection, you can use two API methods:
The
GraphicsStateCollection.WarmUp
and
GraphicsStateCollection.WarmUpProgressively
prewarm methods return a job handle, which you can use to set whether Unity performs the warming synchronously or asynchronously.
Unity 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).
ヒント
To trace any PSOs used by your application that weren't created during the collection warmup, enable the traceCacheMisses option when you call
GraphicsStateCollection.WarmUp
or
GraphicsStateCollection.WarmUpProgressively
. This creates a separate cacheMissCollection to store the new PSOs, which you can manage as its own collection, or Append to an existing collection.
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:
  • Shader.CreateGPUProgram
    for Unity creating a GPU-specific version of a shader variant.
  • CreateGraphicsGraphicsPipelineImpl
    for Unity creating a PSO.

Additional resources