docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ShaderWarmup

    Provides helpers to ensure every shader variant needed by a scene is compiled and uploaded to the GPU before an image-comparison capture. In the Editor the helpers temporarily enable asynchronous shader compilation, yield frames so the driver can finish in the background, then restore the original settings. In a Player build every method is a no-op because all variants are pre-compiled at build time.

    Inheritance
    object
    ShaderWarmup
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools.Graphics
    Assembly: UnityEngine.TestTools.Graphics.dll
    Syntax
    public static class ShaderWarmup

    Methods

    WaitForCompilation(int, int)

    Yields frames until every in-flight shader compilation task has finished. In the Editor the method temporarily enables ShaderUtil.allowAsyncCompilation and EditorSettings.asyncShaderCompilation so variants that are triggered during the warm-up frames compile on background threads rather than blocking the render thread one by one. Call this from any test coroutine before AreEqual(Texture2D, Camera, ImageComparisonSettings, string, bool) to eliminate image differences caused by shader compilation timing.

    Declaration
    public static IEnumerator WaitForCompilation(int warmupFrames = 1, int timeoutFrames = 300)
    Parameters
    Type Name Description
    int warmupFrames

    Number of frames to render before polling the compiler. These frames give the render pipeline a chance to touch every pass and trigger compilation for all the shader variants the scene needs.

    int timeoutFrames

    Maximum number of additional frames to wait while the compiler is still busy. A warning is logged if the timeout is reached.

    Returns
    Type Description
    IEnumerator

    An enumerator suitable for yield return.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)