---
title: 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/ctor
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/computeshadervariant/ctor.md
last_updated: 2026-11-13
generated_at: 2026-11-18T09:26:22.020Z
locale: en-us
---

# ComputeShaderVariant

> Creates a compute shader variant identifier with the provided compute shader, kernel index, and keywords.

## Definition

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

## ComputeShaderVariant(ComputeShader, int, LocalKeyword\[])

Creates a compute shader variant identifier with the provided compute shader, kernel index, and keywords.

```csharp
public ComputeShaderVariant(ComputeShader shader, int kernelIndex, LocalKeyword[] keywords)
```

### Parameters

**** (\[ComputeShader]\(/engine/7000.0/script-reference/unityengine/computeshader)): The [ComputeShader](/engine/7000.0/script-reference/unityengine/computeshader.md) of the variant.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the kernel in `shader`.**** (\[LocalKeyword\[]]\(/engine/7000.0/script-reference/unityengine/rendering/localkeyword)): The [LocalKeyword](/engine/7000.0/script-reference/unityengine/rendering/localkeyword.md) array of the variant.

### Remarks

Use this constructor to describe a variant to pass 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), or to compare with the variants that [GraphicsStateCollection.GetComputeVariants](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/getcomputevariants.md) returns. The constructor stores the arguments as they are and doesn't validate them.

## ComputeShaderVariant(ComputeShader, int)

Creates a compute shader variant identifier with the provided compute shader, kernel index, and the keywords enabled on the compute shader.

```csharp
public ComputeShaderVariant(ComputeShader shader, int kernelIndex)
```

### Parameters

**** (\[ComputeShader]\(/engine/7000.0/script-reference/unityengine/computeshader)): The [ComputeShader](/engine/7000.0/script-reference/unityengine/computeshader.md) of the variant.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the kernel in `shader`.

### Remarks

The variant uses the keywords that are enabled on `shader` when you call the constructor, from [ComputeShader.enabledKeywords](/engine/7000.0/script-reference/unityengine/computeshader/enabledkeywords.md). Later changes to the keywords of `shader` don't affect the variant. If `shader` is `null`, this constructor throws a `NullReferenceException`.
