Instance Method

makeLibrary(source:options:)

Synchronously creates a new library that contains the functions stored in the specified source string.

Required.

Declaration

func makeLibrary(source: String, options: MTLCompileOptions?) throws -> MTLLibrary

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. See MTLCompileOptions.

error

A pointer to an error object that describes source code compilation problems, if any. This object contains compiler errors if the returned library object is nil, and compiler warnings if the library was generated with warnings. If the library was generated successfully, without errors or warnings, this error object is nil.

Return Value

A new library object that contains the compiled source code or nil if an error occurred.

Discussion

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

Topics

Compilation Options

class MTLCompileOptions

Compilation settings for a Metal shader library.

See Also

Acquiring Shader Functions

func makeDefaultLibrary() -> MTLLibrary?

Creates a new library that contains the functions stored in the app’s default Metal library.

Required.

func makeDefaultLibrary(bundle: Bundle) -> MTLLibrary

Creates a new library that contains the functions stored in the specified bundle.

Required.

func makeLibrary(filepath: String) -> MTLLibrary

Creates a new library that contains the functions stored in the specified Metal library.

Required.

func makeLibrary(URL: URL) -> MTLLibrary

Creates a new library that contains the functions from a Metal library file at a specified URL.

Required.

func makeLibrary(data: __DispatchData) -> MTLLibrary

Creates a new library that contains the functions stored in the specified binary data object.

Required.

func makeLibrary(source: String, options: MTLCompileOptions?, completionHandler: MTLNewLibraryCompletionHandler)

Asynchronously creates a new library by compiling the functions stored in the specified source string.

Required.