---
title: "setSamplerStates(_:range:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlcomputecommandencoder/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.

## Declaration

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

## Parameters

- `samplers`: An array of doc://com.apple.metal/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

Discussion warning: This method requires that the number of instances in samplers be the same as the length of range.

## See Also

### Binding texture samplers

- [setSamplerState(_:index:)](metal/mtlcomputecommandencoder/setsamplerstate(_:index:).md)
- [setSamplerState(_:lodMinClamp:lodMaxClamp:index:)](metal/mtlcomputecommandencoder/setsamplerstate(_:lodminclamp:lodmaxclamp:index:).md)
- [setSamplerStates(_:lodMinClamps:lodMaxClamps:range:)](metal/mtlcomputecommandencoder/setsamplerstates(_:lodminclamps:lodmaxclamps:range:).md)
