Contents

makeLibrary(source:options:completionHandler:)

Asynchronously creates a Metal library instance by compiling the functions in a source string.

Declaration

func makeLibrary(source: String, options: MTLCompileOptions?, completionHandler: @escaping  @Sendable ((any MTLLibrary)?, (any Error)?) -> Void)
func makeLibrary(source: String, options: MTLCompileOptions?) async throws -> any MTLLibrary

Parameters

  • source:

    A string that contains source code for one or more Metal functions. For information about writing source in Metal Shading Language (MSL), see the Metal Shading Language Specification.

  • options:

    An Mtlcompileoptions instance that affects the compilation of the source code in the string.

  • completionHandler:

    A Swift closure or an Objective-C block the method calls when the library finishes loading.

Mentioned in

Discussion

Because there’s no search path to find other functions, the source may only import the Metal default library.

See Also

Creating shader libraries