Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GraphicsStateCollection

Collection of shader variants and associated graphics states.
Read time 6 minutesLast updated 2 days ago

Definition

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.
GraphicsStateCollection
generally replaces the ShaderVariantCollection class for prewarming shader variants. On legacy graphics APIs that do not support prewarming graphics states, GraphicsStateCollection.WarmUp will fallback to using ShaderVariantCollection.WarmUp.

Examples

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

cacheMissCollectionA separate
GraphicsStateCollection
that stores shader variants and graphics states that were not in this collection during GraphicsStateCollection.WarmUp.
completedWarmupCountThe number of shader variant state permutations that have been warmed up.
graphicsDeviceTypeThe graphics device API type the collection is intended to be used with.
isTracingFlag indicating if the collection is actively tracing shader variants and graphics states.
isTracingCacheMissesFlag indicating if the collection is actively tracing cache misses into GraphicsStateCollection.cacheMissCollection.
isWarmedUpFlag indicating if the collection is completely warmed up.
qualityLevelNameThe quality level the collection is intended to be used with.
runtimePlatformThe platform that the collection is intended to be used with.
totalGraphicsStateCountThe total number of graphics states across all shader variants in the collection.
variantCountThe number of shader variants contained in this collection.
versionThe current version of the collection.

Methods

Method

Description

AddGraphicsStateForVariantAdds a new graphics state associated with a shader variant.
AddGraphicsStatesGenerates and adds new graphics states to the collection from arrays of assets.
AddGraphicsStatesFromReferenceGenerates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.
AddVariantAdds a new shader variant to the collection.
AddVariantsAdds one or more new shader variants to the collection.
AppendAdds all new graphics states and shader variants from the given
collection
to this collection.
BeginTraceStart tracing shader variants and graphics states encountered at runtime.
ClearVariantsClears all shader variants and associated graphics states from the collection.
ContainsVariantCheck if the specified ShaderVariantCollection.ShaderVariant exists in the collection.
CopyGraphicsStatesForVariantCopy all the graphics states from the source variant to the destination variant.
EndTraceStop tracing shader variants and graphics states encountered at runtime.
EraseCacheMissCollectionErase the GraphicsStateCollection.cacheMissCollection and all its entries, setting it to null.
GetGraphicsStateCountForVariantGet the number of graphics states associated with an input shader variant.
GetGraphicsStatesForVariantPopulate given list with graphics states associated with an input shader variant.
GetVariantsPopulate given list with shader variants contained in the collection.
LoadFromFileLoad the GraphicsStateCollection at the given path.
LoadFromJsonLoad a GraphicsStateCollection from the provided JSON-formatted string.
RemoveGraphicsStatesForVariantRemove all associated graphics states from an input shader variant.
RemoveVariantRemove ShaderVariantCollection.ShaderVariant and associated graphics states from collection.
SaveToFileSave GraphicsStateCollection to disk.
SendToEditorSend GraphicsStateCollection to the Editor using PlayerConnection.
WarmUpPrewarms all shader variants in this collection using associated graphics states.
WarmUpProgressivelyPrewarms the given number of shader variant state permutations using associated graphics states.

Structs

Struct

Description

GraphicsStateCollection.GraphicsStateA graphics state identifies a specific rendering configuration.
GraphicsStateCollection.ShaderVariantIdentifies a specific variant of a shader stored in a GraphicsStateCollection.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.