An object that defines how a texture should be sampled.


protocol MTLSamplerState


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

  1. Create a MTLSamplerDescriptor object.

  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 object.

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

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


Identifying the Sampler

var device: MTLDevice

The device object that created the sampler.


var label: String?

A string that identifies the sampler.



Inherits From

See Also

Sampling Texture Data

class MTLSamplerDescriptor

An object that you use to configure a texture sampler.