Documentation

Unity Engine

Download Unity

Unity Engine

WarmUpProgressively

Prewarms the given number of shader variant state permutations and compute shader variants.
Read time 3 minutesLast updated 20 hours ago

Definition

WarmUpProgressively(int, JobHandle)

Prewarms the given number of shader variant state permutations and compute shader variants.
public JobHandle WarmUpProgressively(int count, JobHandle dependency = default)

Parameters

count

The maximum number of variant permutations and compute shader variants to warm up.

dependency

Job to wait for.

Returns

Type

Description

JobHandleHandle to prewarming job.

Remarks

Except for the case of WebGPU, graphics state collection warmup is only supported when SystemInfo.supportsParallelPSOCreation is true. Otherwise, behavior falls back to the legacy ShaderVariantCollection.WarmUp and
count
restricts the maximum number of shader variants instead of shader variant permutations.
Unity warms up graphics states first. Each compute shader variant that Unity warms up counts as one unit of
count
. Compute shader variants whose compute shader is missing, whose kernel index is invalid, or whose kernel has no compiled variant for its keywords don't use
count
. Unity marks them as warmed up when warmup reaches them, without creating a GPU representation.
Unity creates compute shader variants asynchronously on platforms that support it. On other platforms, this method waits for
dependency
to complete and creates the compute shader variants on the calling thread, so a larger
count
blocks the calling thread for longer.
Note that when cache miss tracing begins, only the graphics state collection entries that have completed warm up when this job finishes will be considered in identifying cache misses. Additionally, :ref::isTracingCacheMisses must be false before initiating warm up in order to set
traceCacheMisses
to true. Use GraphicsStateCollection.EndTrace on the GraphicsStateCollection.cacheMissCollection to end any ongoing cache miss tracing.
using UnityEngine;using UnityEngine.Rendering;using Unity.Jobs;public class GraphicsStateCollectionWarmup : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; public int statesToWarmup; void Start() { JobHandle handle = graphicsStateCollection.WarmUpProgressively(statesToWarmup); }}

WarmUpProgressively(int, JobHandle, bool)

Prewarms the given number of shader variant state permutations and compute shader variants.
public JobHandle WarmUpProgressively(int count, JobHandle dependency, bool traceCacheMisses)

Parameters

count

The maximum number of variant permutations and compute shader variants to warm up.

dependency

Job to wait for.

traceCacheMisses

If
true
, stores any graphics states and compute shader variants used during runtime that Unity didn't prewarm.

Returns

Type

Description

JobHandleHandle to prewarming job.

Remarks

Except for the case of WebGPU, graphics state collection warmup is only supported when SystemInfo.supportsParallelPSOCreation is true. Otherwise, behavior falls back to the legacy ShaderVariantCollection.WarmUp and
count
restricts the maximum number of shader variants instead of shader variant permutations.
Unity warms up graphics states first. Each compute shader variant that Unity warms up counts as one unit of
count
. Compute shader variants whose compute shader is missing, whose kernel index is invalid, or whose kernel has no compiled variant for its keywords don't use
count
. Unity marks them as warmed up when warmup reaches them, without creating a GPU representation.
Unity creates compute shader variants asynchronously on platforms that support it. On other platforms, this method waits for
dependency
to complete and creates the compute shader variants on the calling thread, so a larger
count
blocks the calling thread for longer.
Note that when cache miss tracing begins, only the graphics state collection entries that have completed warm up when this job finishes will be considered in identifying cache misses. Additionally, :ref::isTracingCacheMisses must be false before initiating warm up in order to set
traceCacheMisses
to true. Use GraphicsStateCollection.EndTrace on the GraphicsStateCollection.cacheMissCollection to end any ongoing cache miss tracing.
using UnityEngine;using UnityEngine.Rendering;using Unity.Jobs;public class GraphicsStateCollectionWarmup : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; public int statesToWarmup; void Start() { JobHandle handle = graphicsStateCollection.WarmUpProgressively(statesToWarmup); }}