Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Closedependency | Job to wait for. |
JobHandle Handle to prewarming job.
Prewarms all shader variants in this collection using associated graphics states.
This will result in the GPU representation of the stored shader variants being created.
using UnityEngine; using UnityEngine.Experimental.Rendering; using Unity.Jobs;
public class WarmUpExample : MonoBehaviour { public GraphicsStateCollection graphicsStateCollection;
void Start() { JobHandle handle = graphicsStateCollection.WarmUp(); } }
The JobHandle returned by this method can be used to control if the creation of GPU representations occurs synchronously or asynchronously.
The example above will perform the warm up asynchronously.
using UnityEngine; using UnityEngine.Experimental.Rendering; using Unity.Jobs;
public class WarmUpSynchronousExample : MonoBehaviour { public GraphicsStateCollection graphicsStateCollection;
void Start() { JobHandle handle = graphicsStateCollection.WarmUp(); handle.Complete(); } }
Prewarming can also be linked to other jobs using the input dependency and returned JobHandle.
using UnityEngine; using UnityEngine.Experimental.Rendering; using Unity.Jobs;
public class WarmUpSynchronousExample : MonoBehaviour { struct PostWarmUpJob : IJob { public void Execute() { Debug.Log("WarmUp is complete"); } }
public GraphicsStateCollection graphicsStateCollection; public JobHandle inputJobHandle;
void Start() { JobHandle handle = graphicsStateCollection.WarmUp(inputJobHandle);
var job = new PostWarmUpJob(); job.Schedule(handle); } }