Contents

MTLSamplerState

An instance that defines how a texture should be sampled.

Declaration

protocol MTLSamplerState : NSObjectProtocol, Sendable

Mentioned in

Overview

The MTLSamplerState protocol defines the interface for a lightweight instance used to encode how a shader or compute kernel should sample a texture. To create a sampler state instance:

  1. Create an MTLSamplerDescriptor instance.

  2. Set the desired properties of the sampler descriptor, including filtering options, addressing modes, maximum anisotropy, and level-of-detail parameters.

  3. Call the makeSamplerState(descriptor:) method of the MTLDevice instance.

(Your app does not define a class that implements the MTLSamplerState protocol.)

You can either release the MTLSamplerDescriptor instance or modify its property values and reuse it to create more MTLSamplerState instances. The descriptor’s properties are only used during instance creation; once created the behavior of a sampler state instance is fixed and cannot be changed.

Topics

Identifying the sampler

Instance Properties

See Also

Texture samplers