-
Build GPU binaries with Metal
Power up your shader pipeline with enhancements to the Metal shader compilation model — all leading to a dramatic reduction in Pipeline State Object (PSO) loading time, especially upon first launch. Learn about explicit PSO caching and sharing of GPU binaries using Metal binary archives and dynamic libraries. And we'll detail the toolchain to create libraries and improve your shader compilation workflow.
Recursos
Videos relacionados
WWDC23
WWDC22
WWDC21
WWDC20
-
Buscar este video…
-
-
6:19 - Creating an empty archive
let descriptor = MTLBinaryArchiveDescriptor() descriptor.url = nil let binaryArchive = try device.makeBinaryArchive(descriptor:descriptor) -
6:47 - Populating an archive
// Render pipelines try binaryArchive.addRenderPipelineFunctions(with: renderPipelineDescriptor) // Compute pipelines try binaryArchive.addComputePipelineFunctions(with: computePipelineDescriptor) // Tile render pipelines try binaryArchive.addTileRenderPipelineFunctions(with: tileRenderPipelineDescriptor) -
6:56 - Reusing compiled functions
// Reusing compiled functions to build a pipeline state object from a file let renderPipelineDescriptor = MTLRenderPipelineDescriptor() // ... renderPipelineDescriptor.binaryArchives = [ binaryArchive ] let renderPipeline = try device.makeRenderPipelineState(descriptor: renderPipelineDescriptor) -
7:15 - Serialization
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let archiveURL = documentsURL.appendingPathComponent("binaryArchive.metallib") try binaryArchive.serialize(to: NSURL.fileURL(withPath: archiveURL)) -
7:26 - Deserialization
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let serializeURL = documentsURL.appendingPathComponent("binaryArchive.metallib") let descriptor = MTLBinaryArchiveDescriptor() descriptor.url = NSURL.fileURL(withPath: serializeURL) let binaryArchive = try device.makeBinaryArchive(descriptor: descriptor) -
17:18 - Runtime compiled dynamic library
let options = MTLCompileOptions(); options.libraryType = .dynamic; options.installName = "@executable_path/myDynamicLibrary.metallib" let utilityLib = try device.makeLibrary(source: dylibSrc, options: options) let utilityDylib = try device.makeDynamicLibrary(library: utilityLib) -
17:59 - Compiling with a dynamic library
let options = MTLCompileOptions() options.libraries = [ utilityDylib ] let library = try device.makeLibrary(source: kernelStr, options: options)
-