# DispatchCompute

> Add a command to execute a ComputeShader.

## Definition

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

## DispatchCompute(ComputeShader, int, int, int, int)

Add a command to execute a [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md).

```csharp
public void DispatchCompute(ComputeShader computeShader, int kernelIndex, int threadGroupsX, int threadGroupsY, int threadGroupsZ)
```

### Parameters

**** (\[ComputeShader]\(/engine/6000.7/script-reference/unityengine/computeshader)): [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md) to execute.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Kernel index to execute, see [ComputeShader.FindKernel](/engine/6000.7/script-reference/unityengine/computeshader/findkernel.md).**** (\[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

When the command buffer executes, a compute shader kernel is dispatched, with work group size either specified directly (see [ComputeShader.Dispatch](/engine/6000.7/script-reference/unityengine/computeshader/dispatch.md)) or read from the GPU buffer (see [ComputeShader.DispatchIndirect](/engine/6000.7/script-reference/unityengine/computeshader/dispatchindirect.md)).

## DispatchCompute(ComputeShader, int, ComputeBuffer, uint)

Add a command to execute a [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md).

```csharp
public void DispatchCompute(ComputeShader computeShader, int kernelIndex, ComputeBuffer indirectBuffer, uint argsOffset)
```

### Parameters

**** (\[ComputeShader]\(/engine/6000.7/script-reference/unityengine/computeshader)): [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md) to execute.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Kernel index to execute, see [ComputeShader.FindKernel](/engine/6000.7/script-reference/unityengine/computeshader/findkernel.md).**** (\[ComputeBuffer]\(/engine/6000.7/script-reference/unityengine/computebuffer)): [ComputeBuffer](/engine/6000.7/script-reference/unityengine/computebuffer.md) with dispatch arguments.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Byte offset indicating the location of the dispatch arguments in the buffer.

### Remarks

When the command buffer executes, a compute shader kernel is dispatched, with work group size either specified directly (see [ComputeShader.Dispatch](/engine/6000.7/script-reference/unityengine/computeshader/dispatch.md)) or read from the GPU buffer (see [ComputeShader.DispatchIndirect](/engine/6000.7/script-reference/unityengine/computeshader/dispatchindirect.md)).

## DispatchCompute(ComputeShader, int, GraphicsBuffer, uint)

Add a command to execute a [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md).

```csharp
public void DispatchCompute(ComputeShader computeShader, int kernelIndex, GraphicsBuffer indirectBuffer, uint argsOffset)
```

### Parameters

**** (\[ComputeShader]\(/engine/6000.7/script-reference/unityengine/computeshader)): [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md) to execute.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Kernel index to execute, see [ComputeShader.FindKernel](/engine/6000.7/script-reference/unityengine/computeshader/findkernel.md).**** (\[GraphicsBuffer]\(/engine/6000.7/script-reference/unityengine/graphicsbuffer)): [ComputeBuffer](/engine/6000.7/script-reference/unityengine/computebuffer.md) with dispatch arguments.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Byte offset indicating the location of the dispatch arguments in the buffer.

### Remarks

When the command buffer executes, a compute shader kernel is dispatched, with work group size either specified directly (see [ComputeShader.Dispatch](/engine/6000.7/script-reference/unityengine/computeshader/dispatch.md)) or read from the GPU buffer (see [ComputeShader.DispatchIndirect](/engine/6000.7/script-reference/unityengine/computeshader/dispatchindirect.md)).
