I tried with the latest Xcode 14 RC, but still am unable to extract a pipeline script from a harvested binary archive, as per WWDC 2022 session video.
Here's what I've tried (Runnable XCode project on Github):
// Create a simple render pipeline
let device = MTLCreateSystemDefaultDevice()!
let lib = device.makeDefaultLibrary()!
let pipelineDesc = MTLRenderPipelineDescriptor()
pipelineDesc.vertexFunction = lib.makeFunction(name: "main_vertex")
pipelineDesc.fragmentFunction = lib.makeFunction(name: "main_fragment")
pipelineDesc.colorAttachments[0]?.pixelFormat = .bgra8Unorm
// Harvest GPU Archive
let archivePath = NSTemporaryDirectory().appending("harvested-archive.metallib")
let archiveDesc = MTLBinaryArchiveDescriptor()
let archive = try device.makeBinaryArchive(descriptor: archiveDesc)
try archive.addRenderPipelineFunctions(descriptor: pipelineDesc)
try archive.serialize(to: NSURL.fileURL(withPath: archivePath))
// In a terminal...
> xcrun metal-source -flatbuffers=json harvested-archive.metallib -o descriptors.mtlp-json
Unfortunately, metal-source
produces a directory of metallibs and no pipeline JSON script in sight.
Did I miss something? Has the process changed since the WWDC 2022?
Thanks.