---
title: GraphicsStateCollection.ComputeShaderVariant
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant.md
last_updated: 2026-11-13
generated_at: 2026-11-18T09:02:56.508Z
locale: en-us
---

# GraphicsStateCollection.ComputeShaderVariant

> Identifies a specific variant of a compute shader kernel stored in a graphics state collection.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.Rendering](/engine/7000.0/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public struct GraphicsStateCollection.ComputeShaderVariant
```

## Remarks

A compute shader, a kernel index, and a set of local keywords identify a compute shader variant. [GraphicsStateCollection.GetComputeVariants](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/getcomputevariants.md) returns the variants in a collection as this struct. To add, check, or remove a variant, pass its fields to [GraphicsStateCollection.AddComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/addcomputevariant.md), [GraphicsStateCollection.ContainsComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/containscomputevariant.md), or [GraphicsStateCollection.RemoveComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/removecomputevariant.md).

Additional Resources: [GraphicsStateCollection.GetComputeVariants](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/getcomputevariants.md), [GraphicsStateCollection.AddComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/addcomputevariant.md).

## Examples

```csharp
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                                   |
| -------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| [kernelIndex](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant/kernelindex.md) | Index of the kernel used in this variant.     |
| [keywords](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant/keywords.md)       | Array of local keywords used in this variant. |
| [shader](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant/shader.md)           | ComputeShader used in this variant.           |

## Constructors

| Constructor                                                                                                                                                                                                                                                              | Description                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [ComputeShaderVariant(UnityEngine.ComputeShader,System.Int32)](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant/ctor.md#computeshadervariant\(computeshader-int\))                                                     | 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\[\])](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant/ctor.md#computeshadervariant\(computeshader-int-localkeyword\)) | Creates a compute shader variant identifier with the provided compute shader, kernel index, and keywords.                                   |
