Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created November 2, 2017 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/3ce3e119a5a48f93e1ab3445a9cf2548 to your computer and use it in GitHub Desktop.
Save laevandus/3ce3e119a5a48f93e1ab3445a9cf2548 to your computer and use it in GitHub Desktop.
Setting up compute pipeline state in Metal.
init()
{
guard let device = MTLCreateSystemDefaultDevice() else { fatalError("Metal device is not available.") }
self.device = device
guard let commandQueue = device.makeCommandQueue() else { fatalError("Failed creating Metal command queue.") }
self.commandQueue = commandQueue
guard let library = device.makeDefaultLibrary() else { fatalError("Failed creating Metal library.") }
guard let function = library.makeFunction(name: "processData") else { fatalError("Failed creating Metal function.") }
do
{
computePipelineState = try device.makeComputePipelineState(function: function)
}
catch
{
fatalError("Failed preparing compute pipeline.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment