Created
November 2, 2017 09:05
-
-
Save laevandus/3ce3e119a5a48f93e1ab3445a9cf2548 to your computer and use it in GitHub Desktop.
Setting up compute pipeline state in Metal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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