dependency | 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); } }