Documentation

Unity Engine

Download Unity

Unity Engine

RemoveComputeVariant(ComputeShader, int, LocalKeyword[])

Removes the specified compute shader variant from the collection.
Read time 1 minuteLast updated 5 days ago

Definition

public bool RemoveComputeVariant(ComputeShader shader, int kernelIndex, LocalKeyword[] keywords)

Parameters

The ComputeShader of the variant.

kernelIndex

The index of the kernel in
shader
.

The LocalKeyword array of the variant. The order of the keywords doesn't matter. Unity ignores keywords that the kernel doesn't declare and keywords that only select a dynamic branch.

Returns

Type

Description

boolReturns
true
if Unity removes the variant. Otherwise, returns
false
.

Remarks

Returns
false
if
shader
is
null
or the variant isn't in the collection. If you remove a variant that Unity already warmed up, GraphicsStateCollection.completedWarmupCount decreases.

Examples

using UnityEngine;using UnityEngine.Rendering;// Attach this script to a GameObject, then assign a graphics state collection and a compute shader in the Inspector.public class RemoveComputeVariantExample : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; public ComputeShader computeShader; void Start() { // Uses the CSMain kernel with the keywords currently enabled on the compute shader. int kernelIndex = computeShader.FindKernel("CSMain"); bool removed = graphicsStateCollection.RemoveComputeVariant(computeShader, kernelIndex, computeShader.enabledKeywords); Debug.Log(removed ? "Removed the compute shader variant." : "The compute shader variant isn't in the collection."); }}