GraphicsStateCollection
Collection of shader variants, compute shader variants, and associated graphics states.
Read time 7 minutesLast updated 10 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.
A compute shader, a kernel index, and a set of local keywords identify a compute shader variant. Compute shader variants have no associated graphics states. For more information, refer to GraphicsStateCollection.AddComputeVariant and GraphicsStateCollection.GetComputeVariants.
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 graphics states and compute shader variants that Unity has warmed up. |
| computeVariantCount | The number of compute shader variants contained in this collection. |
| 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 |
|---|---|
| AddComputeVariant | Adds a new compute shader variant to the collection. |
| 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, shader variants, and compute shader variants from the given |
| BeginTrace | Starts tracing shader variants, compute shader variants, and graphics states encountered at runtime. |
| ClearVariants | Clears all shader variants, compute shader variants, and associated graphics states from the collection. |
| ContainsComputeVariant | Checks whether the specified compute shader variant exists in 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 | Stops tracing shader variants, compute shader variants, and graphics states encountered at runtime. |
| EraseCacheMissCollection | Erase the GraphicsStateCollection.cacheMissCollection and all its entries, setting it to null. |
| GetComputeVariants | Populates the given list with the compute shader variants in the collection. |
| 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. |
| RemoveComputeVariant | Removes the specified compute shader variant from the collection. |
| 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 with their associated graphics states, and then prewarms all compute shader variants. |
| WarmUpProgressively | Prewarms the given number of shader variant state permutations and compute shader variants. |
Structs
Struct | Description |
|---|---|
| GraphicsStateCollection.ComputeShaderVariant | Identifies a specific variant of a compute shader kernel stored in a graphics state collection. |
| 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. |