Framework

Metal

Render advanced 3D graphics and perform data-parallel computations. Get fine-grained access to the GPU while minimizing CPU overhead.

Overview

The Metal Framework provides extremely low-overhead access to the GPU, enabling incredibly high performance for your sophisticated graphics rendering and computational tasks. Metal eliminates many performance bottlenecks—such as costly state validation—that are found in traditional graphics APIs. Metal moves all expensive state translation and compilation operations out of the critical path of your most performance sensitive rendering code. It provides precompiled shaders, state objects, and explicit command scheduling to ensure that your application achieves the highest possible performance and efficiency.

Graphics, compute, and blit commands can be used together seamlessly and efficiently. Metal is specifically designed to exploit modern architectural considerations, such as multiprocessing and shared memory, to make it easy to parallelize the creation of GPU commands.

Symbols

Classes

MTLArgument

A MTLArgument object describes a single argument to a Metal function. Your app uses the MTLArgument properties to read details about a function argument as it was defined in the Metal Shading Language. You can determine the argument’s data type, access restrictions, and its associated resource type. For buffer, texture, and threadgroup memory arguments, additional properties can be read to determine more details about the argument.

MTLArrayType

A MTLArrayType object provides details about a MTLStructMember object that is an array. Your app does not create a MTLArrayType or MTLStructMember object directly. A reflection object, MTLRenderPipelineReflection or MTLComputePipelineReflection, can contain a MTLStructMember object, if one of its arguments is a struct (that is, if the bufferDataType property of MTLArgument is struct). If the dataType property of MTLStructMember is array, then the MTLStructMember object is an array, and the arrayType() method of MTLStructMember returns a MTLArrayType object that contains array details such as length, stride, and element type.

MTLAttribute

An object which represents the attributes of a function.

MTLAttributeDescriptor

An object that determines how attribute data is stored in memory and how it is mapped to arguments for a function.

MTLAttributeDescriptorArray

An array of objects that define how attribute data is formatted and assigned to an index in the attribute argument table.

MTLBufferLayoutDescriptor

An object that is used to configure how function input and attribute data are fetched by a function.

MTLBufferLayoutDescriptorArray

An array of buffer layout states.

MTLCompileOptions

A MTLCompileOptions object is used to specify how a new Metal shader library should be compiled. If you want to set the following options, use standard allocation and initialization techniques to create a MTLCompileOptions object and then set any or all of these properties:

MTLComputePipelineDescriptor

The MTLComputePipelineDescriptor object specifies the compute configuration state used during a compute operation pass. Use standard allocation and initialization techniques to create a MTLComputePipelineDescriptor object. A MTLComputePipelineDescriptor object is later used to create a MTLComputePipelineState object.

MTLComputePipelineReflection

A MTLComputePipelineReflection object provides access to the arguments of the compute function used in a MTLComputePipelineState object. A MTLComputePipelineReflection object can be created along with a MTLComputePipelineState object. Do not use standard allocation and initialization techniques to create a MTLComputePipelineReflection object.

MTLDepthStencilDescriptor

A MTLDepthStencilDescriptor object is used to define a specific configuration of the depth and stencil stages of a rendering pipeline. To create a MTLDepthStencilDescriptor object, use standard allocation and initialization techniques.

MTLFunctionConstant

A MTLFunctionConstant object describes a function constant referenced in a graphics or compute function.

MTLFunctionConstantValues

A MTLFunctionConstantValues object contains a set of constant values that specialize a graphics or compute function.

MTLHeapDescriptor

A MTLHeapDescriptor object is used to configure new MTLHeap objects.

MTLRenderPassAttachmentDescriptor

A MTLRenderPassAttachmentDescriptor object is used to configure an individual render target of a framebuffer. Each MTLRenderPassAttachmentDescriptor object specifies one texture that a graphics rendering pass can write into.

MTLRenderPassColorAttachmentDescriptor

A MTLRenderPassColorAttachmentDescriptor object is used to configure an individual render target whose texture has a color-renderable pixel format.

MTLRenderPassDepthAttachmentDescriptor

A MTLRenderPassDepthAttachmentDescriptor object is used to configure an individual render target whose texture has a depth-renderable pixel format.

MTLRenderPassDescriptor

A MTLRenderPassDescriptor object contains a collection of attachments that are the rendering destination for pixels generated by a rendering pass. The MTLRenderPassDescriptor class is also used to set the destination buffer for visibility information generated by a rendering pass.

MTLRenderPassStencilAttachmentDescriptor

A MTLRenderPassStencilAttachmentDescriptor object is used to configure an individual render target that has a texture with a stencil-renderable pixel format.

MTLRenderPipelineColorAttachmentDescriptor

A MTLRenderPipelineColorAttachmentDescriptor object defines the configuration of a color attachment associated with a rendering pipeline.

MTLRenderPipelineColorAttachmentDescriptorArray

A MTLRenderPipelineColorAttachmentDescriptorArray object contains an array of render pipeline states for an array of color attachments. The methods of MTLRenderPipelineColorAttachmentDescriptorArray set the render pipeline state or retrieve a copy of the render pipeline state for one of the color attachments in the array.

MTLRenderPipelineDescriptor

The MTLRenderPipelineDescriptor object specifies the rendering configuration state used during a rendering pass, including rasterization (such as multisampling), visibility, blending, tessellation, and graphics function state. Use standard allocation and initialization techniques to create a MTLRenderPipelineDescriptor object. A MTLRenderPipelineDescriptor object is later used to create a MTLRenderPipelineState object.

MTLRenderPipelineReflection

A MTLRenderPipelineReflection object provides access to the arguments of a vertex or fragment function of a MTLRenderPipelineState object. A MTLRenderPipelineReflection object can be created along with a MTLRenderPipelineState object. Do not use standard allocation and initialization techniques to create a MTLRenderPipelineReflection object.

MTLSamplerDescriptor

MTLSamplerDescriptor objects are used to define a specific configuration of a MTLSamplerState object.

MTLStageInputOutputDescriptor

An object that describes the inputs, outputs, and attribute data to Metal vertex, fragment or compute functions.

MTLStencilDescriptor

A MTLStencilDescriptor object is used to configure a stencil test operation.

MTLStructMember

MTLStructMember is part of the reflection API that allows Metal framework code to query details about an argument of a Metal shading language function. A MTLStructMember object describes the data type of one field in a struct that is passed as a MTLFunction argument, which is represented by MTLArgument.

MTLStructType

MTLStructType is part of the reflection API that allows Metal framework code to query details of a struct that is passed as an argument of a Metal shading language function. You do not allocate or initialize MTLStructType objects. To obtain a MTLStructType object, you can query the bufferStructType property of a MTLArgument object, or call the structType() method for a MTLStructMember object. To examine the details of the struct, you can recursively drill down the members property of the MTLStructType object, which contains details about struct members, each of which is represented by a MTLStructMember object.

MTLTextureDescriptor

A MTLTextureDescriptor object is used to configure new texture objects.

MTLVertexAttribute

A MTLVertexAttribute object represents an attribute for per-vertex input in a vertex function. You use vertex attribute objects to inspect the inputs of a vertex function by examining the vertexAttributes property of the corresponding MTLFunction object.

MTLVertexAttributeDescriptor

MTLVertexAttributeDescriptor determines how vertex attribute data is stored in memory and how it is mapped to arguments for a vertex shader function.

MTLVertexAttributeDescriptorArray

A MTLVertexAttributeDescriptorArray object is an array of objects that defines how vertex attribute data is formatted and assigned to an index in the attribute argument table. The methods of MTLVertexAttributeDescriptorArray set or retrieve the attribute formatting information from the array.

MTLVertexBufferLayoutDescriptor

A MTLVertexBufferLayoutDescriptor object is used to configure how vertex and attribute data are fetched by a vertex function.

MTLVertexBufferLayoutDescriptorArray

A MTLVertexBufferLayoutDescriptorArray holds an array of vertex buffer layout states. The methods of MTLVertexBufferLayoutDescriptorArray set the vertex buffer layout state in the array or retrieve the state from the array.

MTLVertexDescriptor

A MTLVertexDescriptor object is used to configure how vertex data stored in memory is mapped to attributes in a vertex shader.

Protocols

MTLBlitCommandEncoder

The MTLBlitCommandEncoder protocol is used to define the interface for objects that can encode resource-copying commands into a command buffer. Use these commands to manage the contents of textures and buffers.

MTLBuffer

The MTLBuffer protocol defines the interface for objects that represent an allocation of unformatted, device-accessible memory that can contain any type of data. Your app does not define classes that implement this protocol.

MTLCommandBuffer

A transient, single-use buffer that stores encoded commands which are committed to and executed by the GPU.

MTLCommandEncoder

The MTLCommandEncoder protocol defines the common interface for objects that can write commands into a command buffer.

MTLCommandQueue

The MTLCommandQueue protocol defines the interface for an object that can queue an ordered list of command buffers for a Metal device to execute. In general, command queues are thread-safe and allow multiple outstanding command buffers to be encoded simultaneously.

MTLComputeCommandEncoder

Methods that allow the encoding of commands that specify the data-parallel compute processing state and execute the compute function.

MTLComputePipelineState

The MTLComputePipelineState protocol defines the interface for a lightweight object used to encode a reference to a compiled compute program. A MTLComputePipelineState object is fully thread-safe and can be used by many MTLComputeCommandEncoder objects, even if they are associated with different command buffers.

MTLDepthStencilState

The MTLDepthStencilState protocol defines the interface for a lightweight object used to encode how a graphics rendering pass should perform depth and stencil operations. The MTLRenderCommandEncoder uses a MTLDepthStencilState object to set the depth and stencil state for a rendering pass.

MTLDevice

The MTLDevice protocol defines the interface to a single graphics processor (GPU). You use an object that conforms to this protocol to query the capabilities of the processor and to allocate objects used to access those capabilities.

MTLDrawable

A displayable resource that can be rendered or written to.

MTLFence

The MTLFence protocol defines the interface for an object that can track and manage resource dependencies across command encoders.

MTLFunction

The MTLFunction protocol defines the interface for an object that represents a single graphics or compute function.

MTLHeap

The MTLHeap protocol defines the interface for an object that represents an abstract memory pool.

MTLLibrary

The MTLLibrary protocol defines the interface for an object that represents a library of graphics or compute functions.

MTLParallelRenderCommandEncoder

The MTLParallelRenderCommandEncoder protocol is used to define the interface for objects that can break up a single graphics rendering pass so that it can be encoded from multiple threads simultaneously.

MTLRenderCommandEncoder

The MTLRenderCommandEncoder protocol is used to define the interface for objects that encode graphics rendering state and commands into a command buffer. Your app does not define classes that implement this protocol.

MTLRenderPipelineState

The MTLRenderPipelineState protocol defines the interface for a lightweight object used to encode the state for a configured graphics rendering pipeline.

MTLResource

The MTLResource protocol defines the interface for any resource object that represents an allocation of memory.

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:

MTLTexture

The MTLTexture protocol defines the interface for an object that represents an allocation of formatted image data. Textures are used as source data for a vertex shader, a fragment shader, or a compute kernel. They are also used as an attachment that acts as a rendering destination.

Structures

MTLBlitOption

Options for controlling a blit operation.

MTLColorWriteMask

Values used to specify a mask to permit or restrict writing to color channels of a color value. The values red, green, blue, and alpha select one color channel each, and they can be bitwise combined.

MTLCommandBufferErrorMTLLibraryError
MTLPipelineOption

Controls which argument information is made available for reflection by the creation of the pipeline.

MTLRenderPipelineErrorMTLRenderStages
MTLResourceOptions

Optional arguments used to create and influence behavior of buffer and texture objects.

MTLTextureUsage

The options that describe how a texture will be used in your app.