ChunkEvictionStrategy
Specifies the strategy Unity uses to evict shader variant chunks from memory.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Enum
- Namespace: UnityEngine.Shaders
- Assembly: UnityEngine.CoreModule
public enum ChunkEvictionStrategy
Remarks
Shaders store their variant data in chunks to reduce memory usage when Unity loads shaders that have a large number of variants. Use this enum to control how quickly Unity evicts chunks from memory after it stops using them. This setting works with the Shader.maximumChunksOverride setting as follows:
- If you set Shader.maximumChunksOverride to , Unity never evicts chunks.
0 - If you set Shader.maximumChunksOverride to a value other than , Unity keeps at most Shader.maximumChunksOverride chunks in memory per shader. If Unity needs a new chunk, it evicts the least recently used chunk from memory to free space.
0 - If Shader.maximumChunksOverride isn't and you set Shader.chunkEvictionStrategy to a value other than
0, Unity also evicts any chunk that it hasn't used for a certain number of rendered frames. Each enum value sets a different number of frames.Never
This setting affects only the Unity Player.
Additional Resources: Shader.chunkEvictionStrategy.
Examples
using UnityEngine;using UnityEngine.Shaders;// Attach this script to a GameObject and enter Play mode. Unity prints "Default chunk eviction strategy: Aggressive" in the Console window.public class ShaderChunkEvictionStrategy : MonoBehaviour{ void Start() { ChunkEvictionStrategy strategy = Shader.chunkEvictionStrategy; Debug.Log("Default chunk eviction strategy: " + strategy); }}
Fields
Value | Description |
|---|---|
| Aggressive | Evicts a chunk from memory after Unity doesn't use it for a small number of rendered frames. |
| Medium | Evicts a chunk from memory after Unity doesn't use it for a moderate number of rendered frames. |
| Never | Doesn't evict chunks based on how many frames have passed since Unity last used them. |
| Slow | Evicts a chunk from memory after Unity doesn't use it for a large number of rendered frames. |