Instance Method

newLibraryWithSource:options:completionHandler:

Creates a library object asynchronously by compiling the functions stored in the specified source string.

Required.

Declaration

- (void)newLibraryWithSource:(NSString *)source options:(MTLCompileOptions *)options completionHandler:(MTLNewLibraryCompletionHandler)completionHandler;

Parameters

source

A string containing source code for one or more Metal functions. See Metal Shading Language Guide.

options

A set of options to influence the compilation of this source code. See MTLCompileOptions.

completionHandler

A block of code that is invoked when the library has completed loading.

Discussion

The source may only import the Metal standard library. There is no search path to find other functions.

Topics

Compilation Options

MTLCompileOptions

Compilation settings for a Metal shader library.

Completion Handler

MTLNewLibraryCompletionHandler

A block of code that is invoked when a MTLLibrary object has completed loading.

See Also

Creating Shader Libraries

- newDefaultLibrary

Creates a library object containing the functions in the app’s default Metal library.

Required.

- newDefaultLibraryWithBundle:error:

Creates a library object containing the functions stored in the default Metal library in the specified bundle.

Required.

- newLibraryWithFile:error:

Creates a library object containing the functions in a Metal library file at a specified path.

Required.

- newLibraryWithURL:error:

Creates a library object containing the functions in a Metal library file at a specified URL.

Required.

- newLibraryWithData:error:

Creates a library object containing the functions stored in a binary data object created from a precompiled Metal library.

Required.

- newLibraryWithSource:options:error:

Creates a library object synchronously by compiling the functions stored in the specified source string.

Required.

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