From ae0cf5ed91c3b22e9dc4c1827b48585fd7e5674f Mon Sep 17 00:00:00 2001 From: daemyung jang Date: Sun, 3 Apr 2022 21:56:43 +0900 Subject: [PATCH] Fix runtime errors --- .../Pages/1. SDF.xcplaygroundpage/Sources/Renderer.swift | 4 +--- .../2. Raymarching.xcplaygroundpage/Sources/Renderer.swift | 4 +--- .../3. Random Noise.xcplaygroundpage/Sources/Renderer.swift | 4 +--- .../Pages/4. Clouds.xcplaygroundpage/Sources/Renderer.swift | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/18-rendering-with-rays/starter/Clouds.playground/Pages/1. SDF.xcplaygroundpage/Sources/Renderer.swift b/18-rendering-with-rays/starter/Clouds.playground/Pages/1. SDF.xcplaygroundpage/Sources/Renderer.swift index 1e6733b..763c10a 100644 --- a/18-rendering-with-rays/starter/Clouds.playground/Pages/1. SDF.xcplaygroundpage/Sources/Renderer.swift +++ b/18-rendering-with-rays/starter/Clouds.playground/Pages/1. SDF.xcplaygroundpage/Sources/Renderer.swift @@ -16,9 +16,7 @@ public class Renderer: NSObject, MTKViewDelegate { device = MTLCreateSystemDefaultDevice() queue = device!.makeCommandQueue() do { - guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() } - let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8) - let library = try device.makeLibrary(source: input, options: nil) + let library = device.makeDefaultLibrary()! guard let kernel = library.makeFunction(name: "compute") else { fatalError() } pipelineState = try device.makeComputePipelineState(function: kernel) } catch { diff --git a/18-rendering-with-rays/starter/Clouds.playground/Pages/2. Raymarching.xcplaygroundpage/Sources/Renderer.swift b/18-rendering-with-rays/starter/Clouds.playground/Pages/2. Raymarching.xcplaygroundpage/Sources/Renderer.swift index c32b2a9..eaf3c19 100644 --- a/18-rendering-with-rays/starter/Clouds.playground/Pages/2. Raymarching.xcplaygroundpage/Sources/Renderer.swift +++ b/18-rendering-with-rays/starter/Clouds.playground/Pages/2. Raymarching.xcplaygroundpage/Sources/Renderer.swift @@ -17,9 +17,7 @@ public class Renderer: NSObject, MTKViewDelegate { device = MTLCreateSystemDefaultDevice() queue = device!.makeCommandQueue() do { - guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() } - let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8) - let library = try device.makeLibrary(source: input, options: nil) + let library = device.makeDefaultLibrary()! guard let kernel = library.makeFunction(name: "compute") else { fatalError() } pipelineState = try device.makeComputePipelineState(function: kernel) } catch { diff --git a/18-rendering-with-rays/starter/Clouds.playground/Pages/3. Random Noise.xcplaygroundpage/Sources/Renderer.swift b/18-rendering-with-rays/starter/Clouds.playground/Pages/3. Random Noise.xcplaygroundpage/Sources/Renderer.swift index ed7b97c..e6539a8 100755 --- a/18-rendering-with-rays/starter/Clouds.playground/Pages/3. Random Noise.xcplaygroundpage/Sources/Renderer.swift +++ b/18-rendering-with-rays/starter/Clouds.playground/Pages/3. Random Noise.xcplaygroundpage/Sources/Renderer.swift @@ -17,10 +17,8 @@ public class Renderer: NSObject, MTKViewDelegate { func initializeMetal() { device = MTLCreateSystemDefaultDevice() queue = device!.makeCommandQueue() - let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") do { - let input = try String(contentsOfFile: path!, encoding: String.Encoding.utf8) - let library = try device!.makeLibrary(source: input, options: nil) + let library = device.makeDefaultLibrary()! let kernel = library.makeFunction(name: "compute")! pipelineState = try device!.makeComputePipelineState(function: kernel) } catch { diff --git a/18-rendering-with-rays/starter/Clouds.playground/Pages/4. Clouds.xcplaygroundpage/Sources/Renderer.swift b/18-rendering-with-rays/starter/Clouds.playground/Pages/4. Clouds.xcplaygroundpage/Sources/Renderer.swift index c32b2a9..eaf3c19 100644 --- a/18-rendering-with-rays/starter/Clouds.playground/Pages/4. Clouds.xcplaygroundpage/Sources/Renderer.swift +++ b/18-rendering-with-rays/starter/Clouds.playground/Pages/4. Clouds.xcplaygroundpage/Sources/Renderer.swift @@ -17,9 +17,7 @@ public class Renderer: NSObject, MTKViewDelegate { device = MTLCreateSystemDefaultDevice() queue = device!.makeCommandQueue() do { - guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() } - let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8) - let library = try device.makeLibrary(source: input, options: nil) + let library = device.makeDefaultLibrary()! guard let kernel = library.makeFunction(name: "compute") else { fatalError() } pipelineState = try device.makeComputePipelineState(function: kernel) } catch {