---
title: "setComputePipelineState(_:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlcomputecommandencoder/setcomputepipelinestate(_:)"
---

# setComputePipelineState(_:)

Configures the compute encoder with a pipeline state for subsequent kernel calls.

## Declaration

```swift
func setComputePipelineState(_ state: any MTLComputePipelineState)
```

## Parameters

- `state`: An doc://com.apple.metal/documentation/Metal/MTLComputePipelineState instance.

## Discussion

Discussion important: Set a compute encoder’s pipeline state before encoding any commands. Encoding commands without an available pipeline state causes an error. Create your pipeline state through one of the MTLDevice methods in Creating Compute Pipeline States. A compute pipeline state provides information Metal uses to compile and run encoded commands. You can change the pipeline state at any time, allowing you to encode multiple kernel calls in a single command buffer. Changing the pipeline state doesn’t affect any previously encoded commands.

## See Also

### Configuring the pipeline state

- [dispatchType](metal/mtlcomputecommandencoder/dispatchtype.md)
