Fix runtime errors

This commit is contained in:
daemyung jang 2022-04-03 21:56:43 +09:00
parent 1bc5abb4b0
commit ae0cf5ed91
No known key found for this signature in database
GPG Key ID: 44160C9958A9C67B
4 changed files with 4 additions and 12 deletions

View File

@ -16,9 +16,7 @@ public class Renderer: NSObject, MTKViewDelegate {
device = MTLCreateSystemDefaultDevice() device = MTLCreateSystemDefaultDevice()
queue = device!.makeCommandQueue() queue = device!.makeCommandQueue()
do { do {
guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() } let library = device.makeDefaultLibrary()!
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)
guard let kernel = library.makeFunction(name: "compute") else { fatalError() } guard let kernel = library.makeFunction(name: "compute") else { fatalError() }
pipelineState = try device.makeComputePipelineState(function: kernel) pipelineState = try device.makeComputePipelineState(function: kernel)
} catch { } catch {

View File

@ -17,9 +17,7 @@ public class Renderer: NSObject, MTKViewDelegate {
device = MTLCreateSystemDefaultDevice() device = MTLCreateSystemDefaultDevice()
queue = device!.makeCommandQueue() queue = device!.makeCommandQueue()
do { do {
guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() } let library = device.makeDefaultLibrary()!
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)
guard let kernel = library.makeFunction(name: "compute") else { fatalError() } guard let kernel = library.makeFunction(name: "compute") else { fatalError() }
pipelineState = try device.makeComputePipelineState(function: kernel) pipelineState = try device.makeComputePipelineState(function: kernel)
} catch { } catch {

View File

@ -17,10 +17,8 @@ public class Renderer: NSObject, MTKViewDelegate {
func initializeMetal() { func initializeMetal() {
device = MTLCreateSystemDefaultDevice() device = MTLCreateSystemDefaultDevice()
queue = device!.makeCommandQueue() queue = device!.makeCommandQueue()
let path = Bundle.main.path(forResource: "Shaders", ofType: "metal")
do { do {
let input = try String(contentsOfFile: path!, encoding: String.Encoding.utf8) let library = device.makeDefaultLibrary()!
let library = try device!.makeLibrary(source: input, options: nil)
let kernel = library.makeFunction(name: "compute")! let kernel = library.makeFunction(name: "compute")!
pipelineState = try device!.makeComputePipelineState(function: kernel) pipelineState = try device!.makeComputePipelineState(function: kernel)
} catch { } catch {

View File

@ -17,9 +17,7 @@ public class Renderer: NSObject, MTKViewDelegate {
device = MTLCreateSystemDefaultDevice() device = MTLCreateSystemDefaultDevice()
queue = device!.makeCommandQueue() queue = device!.makeCommandQueue()
do { do {
guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() } let library = device.makeDefaultLibrary()!
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)
guard let kernel = library.makeFunction(name: "compute") else { fatalError() } guard let kernel = library.makeFunction(name: "compute") else { fatalError() }
pipelineState = try device.makeComputePipelineState(function: kernel) pipelineState = try device.makeComputePipelineState(function: kernel)
} catch { } catch {