Fix a runtime error
This commit is contained in:
parent
7120d1793a
commit
bca9d09f43
|
|
@ -5,7 +5,7 @@ public typealias float4 = SIMD4<Float>
|
||||||
|
|
||||||
public var device: MTLDevice!
|
public var device: MTLDevice!
|
||||||
public let commandQueue = device.makeCommandQueue()!
|
public let commandQueue = device.makeCommandQueue()!
|
||||||
public let library = createLibrary()
|
public let library = device.makeDefaultLibrary()!
|
||||||
public let pipelineState = createPipelineState(library: library)
|
public let pipelineState = createPipelineState(library: library)
|
||||||
|
|
||||||
public var lightGrayColor: float4 = [0.9, 0.9, 0.9, 1]
|
public var lightGrayColor: float4 = [0.9, 0.9, 0.9, 1]
|
||||||
|
|
@ -14,17 +14,6 @@ public var redColor: float4 = [1, 0, 0, 1]
|
||||||
public func setupMetal() {
|
public func setupMetal() {
|
||||||
|
|
||||||
}
|
}
|
||||||
public func createLibrary() -> MTLLibrary {
|
|
||||||
var library: MTLLibrary?
|
|
||||||
do {
|
|
||||||
let path = Bundle.main.path(forResource: "Shaders", ofType: "metal")
|
|
||||||
let source = try String(contentsOfFile: path!, encoding: .utf8)
|
|
||||||
library = try device.makeLibrary(source: source, options: nil)
|
|
||||||
} catch let error as NSError {
|
|
||||||
fatalError("library error: " + error.description)
|
|
||||||
}
|
|
||||||
return library!
|
|
||||||
}
|
|
||||||
|
|
||||||
public func createPipelineState(library: MTLLibrary) -> MTLRenderPipelineState {
|
public func createPipelineState(library: MTLLibrary) -> MTLRenderPipelineState {
|
||||||
let descriptor = MTLRenderPipelineDescriptor()
|
let descriptor = MTLRenderPipelineDescriptor()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue