RemoveComputeVariant(ComputeShader, int, LocalKeyword[])
Removes the specified compute shader variant from the collection.
Read time 1 minuteLast updated 5 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
public bool RemoveComputeVariant(ComputeShader shader, int kernelIndex, LocalKeyword[] keywords)
Parameters
The ComputeShader of the variant.
The index of the kernel in .
shaderThe 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 |
|---|---|
| bool | Returns |
Remarks
Returns if is or the variant isn't in the collection. If you remove a variant that Unity already warmed up, GraphicsStateCollection.completedWarmupCount decreases.
falseshadernullAdditional Resources: GraphicsStateCollection.AddComputeVariant, GraphicsStateCollection.ContainsComputeVariant.
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."); }}