<!--
{
  "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/setSamplerStates:withRange:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLComputeCommandEncoder(im)setSamplerStates:withRange:"
  },
  "title" : "setSamplerStates:withRange:"
}
-->

# setSamplerStates:withRange:

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

```
- (void) setSamplerStates:(id<MTLSamplerState> const[]) samplers withRange:(NSRange) range;
```

## Parameters

`samplers`

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

`range`

The sampler table indexes 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)