GraphicsStateCollection
Collection of shader variants and associated graphics states.
Read time 6 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
- Inherits from: Object
public sealed class GraphicsStateCollection : Object
Remarks
Use graphics state collections to record shader variants and graphics states encountered at runtime and prewarm shader variants.
Each shader variant in the collection may have one or more associated graphics states. Each permutation of a shader variant and a graphics state will result in a single GPU representation of the shader being created by Unity.
GraphicsStateCollectionExamples
using UnityEngine;using UnityEngine.Rendering;public class GraphicsStateCollectionTracing : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; void Start() { graphicsStateCollection = new GraphicsStateCollection(); graphicsStateCollection.BeginTrace(); } void OnDestroy() { graphicsStateCollection.EndTrace(); }}
Constructors
Constructor | Description |
|---|---|
| GraphicsStateCollection() | Create a GraphicsStateCollection populated with contents of a file, or empty. |
| GraphicsStateCollection(System.String) | Create a GraphicsStateCollection populated with contents of a file, or empty. |
Properties
Property | Description |
|---|---|
| cacheMissCollection | A separate |
| completedWarmupCount | The number of shader variant state permutations that have been warmed up. |
| graphicsDeviceType | The graphics device API type the collection is intended to be used with. |
| isTracing | Flag indicating if the collection is actively tracing shader variants and graphics states. |
| isTracingCacheMisses | Flag indicating if the collection is actively tracing cache misses into GraphicsStateCollection.cacheMissCollection. |
| isWarmedUp | Flag indicating if the collection is completely warmed up. |
| qualityLevelName | The quality level the collection is intended to be used with. |
| runtimePlatform | The platform that the collection is intended to be used with. |
| totalGraphicsStateCount | The total number of graphics states across all shader variants in the collection. |
| variantCount | The number of shader variants contained in this collection. |
| version | The current version of the collection. |
Methods
Method | Description |
|---|---|
| AddGraphicsStateForVariant | Adds a new graphics state associated with a shader variant. |
| AddGraphicsStates | Generates and adds new graphics states to the collection from arrays of assets. |
| AddGraphicsStatesFromReference | Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values. |
| AddVariant | Adds a new shader variant to the collection. |
| AddVariants | Adds one or more new shader variants to the collection. |
| Append | Adds all new graphics states and shader variants from the given |
| BeginTrace | Start tracing shader variants and graphics states encountered at runtime. |
| ClearVariants | Clears all shader variants and associated graphics states from the collection. |
| ContainsVariant | Check if the specified ShaderVariantCollection.ShaderVariant exists in the collection. |
| CopyGraphicsStatesForVariant | Copy all the graphics states from the source variant to the destination variant. |
| EndTrace | Stop tracing shader variants and graphics states encountered at runtime. |
| EraseCacheMissCollection | Erase the GraphicsStateCollection.cacheMissCollection and all its entries, setting it to null. |
| GetGraphicsStateCountForVariant | Get the number of graphics states associated with an input shader variant. |
| GetGraphicsStatesForVariant | Populate given list with graphics states associated with an input shader variant. |
| GetVariants | Populate given list with shader variants contained in the collection. |
| LoadFromFile | Load the GraphicsStateCollection at the given path. |
| LoadFromJson | Load a GraphicsStateCollection from the provided JSON-formatted string. |
| RemoveGraphicsStatesForVariant | Remove all associated graphics states from an input shader variant. |
| RemoveVariant | Remove ShaderVariantCollection.ShaderVariant and associated graphics states from collection. |
| SaveToFile | Save GraphicsStateCollection to disk. |
| SendToEditor | Send GraphicsStateCollection to the Editor using PlayerConnection. |
| WarmUp | Prewarms all shader variants in this collection using associated graphics states. |
| WarmUpProgressively | Prewarms the given number of shader variant state permutations using associated graphics states. |
Structs
Struct | Description |
|---|---|
| GraphicsStateCollection.GraphicsState | A graphics state identifies a specific rendering configuration. |
| GraphicsStateCollection.ShaderVariant | Identifies a specific variant of a shader stored in a GraphicsStateCollection. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |