<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: -",
    "macOS: 10.11.0 -",
    "tvOS: 8.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputeCommandEncoder/setSamplerStates(_:range:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So24MTLComputeCommandEncoderP5MetalE16setSamplerStates_5rangeySaySo15MTLSamplerState_pSgG_SnySiGtF"
  },
  "title" : "setSamplerStates(_:range:)"
}
-->

# setSamplerStates(_:range:)

Encodes multiple texture samplers to the sampler argument table, allowing compute kernels to use them for sampling textures on the GPU.

```
func setSamplerStates(_ samplers: [(any MTLSamplerState)?], range: Range<Int>)
```

## Parameters

`samplers`

An array of [`MTLSamplerState`](/documentation/Metal/MTLSamplerState) instance to bind to the sampler argument table.

`range`

The sampler table indicies to bind each of the `samplers` to, in the order they appear.

## Discussion> Warning:
> This method requires that the number of instances in `samplers` be the same as the length of `range`.

---

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)