WarmUp(JobHandle)
Prewarms all shader variants in this collection using associated graphics states.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Experimental.Rendering
- Assembly: UnityEngine.CoreModule
public JobHandle WarmUp(JobHandle dependency = default)
Parameters
Job to wait for.
Returns
Type | Description |
|---|---|
| JobHandle | Handle to prewarming job. |
Remarks
This will result in the GPU representation of the stored shader variants being created.
The JobHandle returned by this method can be used to control if the creation of GPU representations occurs synchronously or asynchronously.
The example below will perform the warm up asynchronously.
using UnityEngine;using UnityEngine.Experimental.Rendering;using Unity.Jobs;public class WarmUpExample : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; void Start() { JobHandle handle = graphicsStateCollection.WarmUp(); }}
Below is an example of how to wait on the completion of the job handle in order to perform operations synchronously.
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); }}