Framework

Metal Performance Shaders

Optimize graphics and compute performance with kernels that are fine-tuned for the unique characteristics of each Metal GPU family.

Overview

The Metal Performance Shaders framework contains a collection of highly optimized compute and graphics shaders that are designed to integrate easily and efficiently into your Metal app. These data-parallel primitives are specially tuned to take advantage of the unique hardware characteristics of each GPU family to ensure optimal performance.

Apps adopting the Metal Performance Shaders framework achieve great performance without needing to create and maintain hand-written shaders for each GPU family. Metal Performance Shaders can be used along with your app’s existing Metal resources (such as the MTLCommandBuffer, MTLTexture, and MTLBuffer objects) and shaders.

The Metal Performance Shaders framework supports the following functionality:

  • Apply high-performance filters to, and extract statistical and histogram data from images.

  • Implement and run neural networks for machine learning training and inference.

  • Solve systems of equations, factorize matrices and multiply matrices and vectors.

  • Accelerate ray tracing with high-performance ray-geometry intersection testing.

Topics

Device Support

MPSSupportsMTLDevice

Determines whether the Metal Performance Shaders framework supports a Metal device.

Image Filters

Image Filters

Apply high-performance filters to, and extract statistical and histogram data from images.

Neural Networks

Implement and run deep learning using previously obtained training data.

Training a Neural Network with Metal Performance Shaders

Use an MPS neural network graph to train a simple neural network digit classifier.

MPSImage

A texture that may have more than four channels for use in convolutional neural networks.

MPSTemporaryImage

A texture for use in convolutional neural networks that stores transient data to be used and discarded promptly.

Objects that Simplify the Creation of Neural Networks

Simplify the creation of neural networks using networks of filter, image, and state nodes.

Convolutional Neural Network Kernels

Build neural networks with layers.

Recurrent Neural Networks

Create recurrent neural networks.

Matrices and Vectors

Matrices and Vectors

Solve systems of equations, factorize matrices and multiply matrices and vectors.

Ray Tracing

Metal for Accelerating Ray Tracing

Use the Metal Performance Shaders ray intersector to perform ray-traced rendering.

Animating and Denoising a Raytraced Scene

Support dynamic scenes and denoising by extending your ray tracer with Metal Performance Shaders.

MPSRayIntersector

A kernel that performs intersection tests between rays and geometry.

MPSAccelerationStructureGroup

A group of acceleration structures.

MPSInstanceAccelerationStructure

An acceleration structure built over instances of other acceleration structures.

MPSTriangleAccelerationStructure

An acceleration structure built over triangles.

MPSAccelerationStructure

The base class for data structures that are built over geometry and used to accelerate ray tracing.

Kernel Base Classes

MPSKernel

A standard interface for Metal Performance Shaders kernels.

Keyed Archivers

NSKeyedArchiver

An encoder that stores an object’s data to an archive referenced by keys.

MPSKeyedUnarchiver

A keyed archiver that supports Metal Performance Shaders kernel decoding.

MPSDeviceProvider

An interface that enables the setting of a Metal device for unarchived objects.

Classes

MPSImageNormalizedHistogram

A filter that computes the normalized histogram of an image.

MPSNNCropAndResizeBilinear

A cropping and bilinear resizing filter.

MPSNNResizeBilinear

A bilinear resizing filter.

MPSStateResourceList

An interface for objects that define resources for Metal Performance Shaders state containers.

See Also

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