# Dispatch(int, int, int, int)

> Execute a compute shader.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public void Dispatch(int kernelIndex, int threadGroupsX, int threadGroupsY, int threadGroupsZ)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Which kernel to execute. A single compute shader asset can have multiple kernel entry points.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of work groups in the X dimension.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of work groups in the Y dimension.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of work groups in the Z dimension.

### Remarks

This functions "runs" the compute shader, launching the indicated number of compute shader thread groups in the X, Y and Z dimensions. Within each work group, a number of shader invocations ("threads") are made. The work group size is specified in the compute shader itself (using "numthreads" HLSL attribute), and the total amount of compute shader invocations is thus group count multiplied by the thread group size. Work group size can be queried using [ComputeShader.GetKernelThreadGroupSizes](/engine/6000.0/script-reference/unityengine/computeshader/getkernelthreadgroupsizes.md) function.

Additional Resources: [ComputeShader.FindKernel](/engine/6000.0/script-reference/unityengine/computeshader/findkernel.md), [ComputeShader.GetKernelThreadGroupSizes](/engine/6000.0/script-reference/unityengine/computeshader/getkernelthreadgroupsizes.md), [ComputeShader.DispatchIndirect](/engine/6000.0/script-reference/unityengine/computeshader/dispatchindirect.md), [Compute Shaders](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/class-compute-shader.md).
