Contents

Inspecting sampler states

Verify your sampler state configurations by examining their properties.

Overview

The Metal debugger allows you to inspect a sampler state with the Sampler State viewer. After opening a sampler state, you can view its associated properties and preview the sampling behavior. For more information, see Inspecting the bound resources for a command or Analyzing memory usage.

The Sampler State viewer shows the properties of your sampler state on the left (as configured by MTLSamplerDescriptor) and a preview on the right. The preview illustrates how pixels in a texture appear when using your sampler state.

[Image]

The square region in the center of the preview corresponds to UV coordinates within the range of 0.0 to 1.0.

[Image]

You can use the preview to quickly verify the configuration for your sampler state. For example, if you want a texture to mirror, but it’s drawing a constant value instead, you can check the sampler state. In the screenshot below, the sampler state is configured to clamp to a border color that’s opaque black, rather than using mirror repeat as the address mode:

[Image]

Try various combinations

The properties you configure when creating a sampler state determine how a texture looks when sampling it. The properties related to filtering control how pixels combine when the sample footprint is either larger or smaller than a pixel, or when it’s between mipmap levels. The address mode determines the texture coordinate at each pixel when a read falls outside the bounds of a texture. You can try using different combinations of filtering and addressing modes until you achieve your desired look.

Properties

Preview

Nearest, Clamptoedge

[Image]

Nearest, Mirrorclamptoedge

[Image]

Nearest, Repeat

[Image]

Nearest, Mirrorrepeat

[Image]

Nearest, Clamptozero

[Image]

Nearest, doc://com.apple.documentation/documentation/metal/mtlsampleraddressmode/clamptobordercolor, Opaqueblack

[Image]

Nearest, doc://com.apple.documentation/documentation/metal/mtlsampleraddressmode/clamptobordercolor, Opaquewhite

[Image]

Nearest, doc://com.apple.documentation/documentation/metal/mtlsampleraddressmode/clamptobordercolor, Transparentblack

[Image]

Linear, Clamptoedge

[Image]

Linear, Clamptoedge

[Image]

Linear, Repeat

[Image]

Linear, Mirrorrepeat

[Image]

Linear, Clamptozero

[Image]

Linear, doc://com.apple.documentation/documentation/metal/mtlsampleraddressmode/clamptobordercolor, Opaqueblack

[Image]

Linear, doc://com.apple.documentation/documentation/metal/mtlsampleraddressmode/clamptobordercolor, Opaquewhite

[Image]

Linear, doc://com.apple.documentation/documentation/metal/mtlsampleraddressmode/clamptobordercolor, Transparentblack

[Image]

See Also

Metal resource inspection