Skip to content

Instantly share code, notes, and snippets.

@kunofellasleep
Last active October 6, 2018 04:06
Show Gist options
  • Save kunofellasleep/6c680caac85c6be1fd17dc08f9cda2d1 to your computer and use it in GitHub Desktop.
Save kunofellasleep/6c680caac85c6be1fd17dc08f9cda2d1 to your computer and use it in GitHub Desktop.
//ハードウェアとしてのGPUを抽象化したプロトコル
lazy var device: MTLDevice! = MTLCreateSystemDefaultDevice()
//コマンドバッファの実行順を管理するキュー
var commandQueue: MTLCommandQueue!
public func Setup() {
let defaultLibrary = device.makeDefaultLibrary()!
if let target = defaultLibrary.makeFunction(name: funcName) {
commandQueue = device.makeCommandQueue()
do {
pipelineState = try device.makeComputePipelineState(function: target)
} catch {
fatalError("Impossible to setup MTL")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment