Target and optimize GPU binaries with Metal 3

RSS for tag

Discuss the WWDC22 Session Target and optimize GPU binaries with Metal 3

Posts under wwdc2022-10102 tag

2 Posts

Post

Replies

Boosts

Views

Activity

Offline compilation: are the new metal tools already available in Xcode 14 beta?
Hi All, I tried using the new metal tools for compiling Metal shaders at build time (as explained in this session https://developer.apple.com/videos/play/wwdc2022/10102/), but I got some errors. In particular: the command "metal shadersfilename.metal -N descriptors.mtlp-json -o archive.metallib" complains about the -N argument. the command "metal-tt shaders.metallib descriptors.mtlp-json -o archive.metallib" doesn't seem to recognise the JSON format. Also the command to extract the JSON pipeline from a binary archive (metal-source) fails. I'm using Xcode 14.0 beta (14A5228q) on macOS Ventura beta. Are the new Metal tools for offline compilation already available (and I'm simply doing something wrong) or do I need to wait for next betas? Thanks!
6
1
2.8k
Nov ’22
Offline Compilation: Still unable to extract pipeline script with Xcode 14 RC
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.
1
1
1.1k
Nov ’22
Offline compilation: are the new metal tools already available in Xcode 14 beta?
Hi All, I tried using the new metal tools for compiling Metal shaders at build time (as explained in this session https://developer.apple.com/videos/play/wwdc2022/10102/), but I got some errors. In particular: the command "metal shadersfilename.metal -N descriptors.mtlp-json -o archive.metallib" complains about the -N argument. the command "metal-tt shaders.metallib descriptors.mtlp-json -o archive.metallib" doesn't seem to recognise the JSON format. Also the command to extract the JSON pipeline from a binary archive (metal-source) fails. I'm using Xcode 14.0 beta (14A5228q) on macOS Ventura beta. Are the new Metal tools for offline compilation already available (and I'm simply doing something wrong) or do I need to wait for next betas? Thanks!
Replies
6
Boosts
1
Views
2.8k
Activity
Nov ’22
Offline Compilation: Still unable to extract pipeline script with Xcode 14 RC
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.
Replies
1
Boosts
1
Views
1.1k
Activity
Nov ’22