Version: Unity 6.3 LTS (6000.3)
Language : English
PSO tracing and warming example
Create a shader variant collection

Other methods to warm up shaders

Warm up shadersA program that runs on the GPU. More info
See in Glossary
if your build targets the DirectX 11, OpenGL, OpenGLES, or WebGLA JavaScript API that renders 2D and 3D graphics in a web browser. The Unity Web build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info
See in Glossary
graphics APIs.

If your project uses the DirectX 11, OpenGL, OpenGLES, or WebGL graphics APIs, Unity provides multiple methods to warm up shaders in your project.

Use the GraphicsStateCollection API (recommended)

The GraphicsStateCollection API is compatible with DirectX 11, OpenGL, OpenGLES, or WebGL. On these APIs, GraphicsStateCollection automatically fallbacks to shader warm up. The GraphcsStateCollection API is the recommended method of warming up shaders. To learn more about warming up shaders with this API, refer to Warm up PSOs.

Note: GraphicsStateCollection automatic fallback is available in Unity 6.1 and later. If your project uses an older version of Unity, use an alternative method of shader warmup outlined in the following section.

Other methods to warm up shaders

On DirectX 11, OpenGL, OpenGLES, or WebGL graphics APIs, you can also use the following methods to warm up shaders:

  • To warm up a Shader objectAn instance of the Shader class, a Shader object is container for shader programs and GPU instructions, and information that tells Unity how to use them. Use them with materials to determine the appearance of your scene. More info
    See in Glossary
    , use the Experimental.Rendering.ShaderWarmup API.
  • To warm up all variants of all Shader objects currently in memory, use the Shader.WarmupAllShaders API.

To warm up a shader variant collection, do any of the following:

Note: These methods aren’t recommended on Vulkan, DirectX 12, and Metal because they can create the wrong PSOs due to missing graphics states.

Additional resources

PSO tracing and warming example
Create a shader variant collection