Documentation

Unity Engine

Download Unity

Unity Engine

GraphicsStateCollection.ComputeShaderVariant

Identifies a specific variant of a compute shader kernel stored in a graphics state collection.
Read time 1 minuteLast updated 5 days ago

Definition

public struct GraphicsStateCollection.ComputeShaderVariant

Remarks

A compute shader, a kernel index, and a set of local keywords identify a compute shader variant. GraphicsStateCollection.GetComputeVariants returns the variants in a collection as this struct. To add, check, or remove a variant, pass its fields to GraphicsStateCollection.AddComputeVariant, GraphicsStateCollection.ContainsComputeVariant, or GraphicsStateCollection.RemoveComputeVariant.

Examples

using System.Collections.Generic;using UnityEngine;using UnityEngine.Rendering;// Attach this script to a GameObject, then assign a graphics state collection in the Inspector.public class ComputeShaderVariantExample : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; void Start() { List<GraphicsStateCollection.ComputeShaderVariant> variants = new List<GraphicsStateCollection.ComputeShaderVariant>(); graphicsStateCollection.GetComputeVariants(variants); foreach (GraphicsStateCollection.ComputeShaderVariant variant in variants) { if (variant.shader == null) continue; Debug.Log(variant.shader.name + ", kernel " + variant.kernelIndex + ", " + variant.keywords.Length + " keywords"); } }}

Fields

Value

Description

kernelIndexIndex of the kernel used in this variant.
keywordsArray of local keywords used in this variant.
shaderComputeShader used in this variant.

Constructors

Constructor

Description

ComputeShaderVariant(UnityEngine.ComputeShader,System.Int32)Creates a compute shader variant identifier with the provided compute shader, kernel index, and the keywords enabled on the compute shader.
ComputeShaderVariant(UnityEngine.ComputeShader,System.Int32,UnityEngine.Rendering.LocalKeyword[])Creates a compute shader variant identifier with the provided compute shader, kernel index, and keywords.