Class

MTLCompileOptions

Compilation settings for a Metal shader library.

Declaration

@interface MTLCompileOptions : NSObject

Overview

Use a MTLCompileOptions object 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:

  • To allow the compiler to perform optimizations for floating-point arithmetic that may violate the IEEE 754 standard, set fastMathEnabled to YES.

  • To target previous OS releases, set languageVersion to a supported Metal shading language version.

  • Set preprocessorMacros to a list of preprocessor macros to be considered when compiling this code.

The MTLCompileOptions object is used with either the newLibraryWithSource:options:error: or newLibraryWithSource:options:completionHandler: method of MTLDevice to compile shading language functions into a new library.

Topics

Specifying Compiler Options

fastMathEnabled

A Boolean value that indicates whether the compiler can perform optimizations for floating-point arithmetic that may violate the IEEE 754 standard.

languageVersion

The language version used to interpret the library source code.

MTLLanguageVersion

Metal shading language versions.

preprocessorMacros

A list of preprocessor macros to apply when compiling the library source.

Relationships

Inherits From

Conforms To

See Also

Essentials

Understanding the Metal Shading Language Filename Extension

Use the .metal filename extension to gain access to Metal's build, profile, and debug tools.

Building a Library with Metal's Command-Line Tools

Use command-line tools to run the Metal compiler toolchain.

MTLLibrary

A collection of Metal shader functions.