Protocol

MTLSamplerState

An object that defines how a texture should be sampled.

Declaration

protocol MTLSamplerState

Overview

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.

Topics

Identifying the Sampler

var device: MTLDevice

The device object that created the sampler.

Required.

var label: String?

A string that identifies the sampler.

Required.

Relationships

Inherits From

See Also

Sampling Texture Data

class MTLSamplerDescriptor

An object that you use to configure a texture sampler.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software