<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputeCommandEncoder/setComputePipelineState(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLComputeCommandEncoder(im)setComputePipelineState:"
  },
  "title" : "setComputePipelineState(_:)"
}
-->

# setComputePipelineState(_:)

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

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

## Parameters

`state`

An [`MTLComputePipelineState`](/documentation/Metal/MTLComputePipelineState) instance.

## 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`](/documentation/Metal/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)