飛び道具ではないmetal #iosdc
TRANSCRIPT
![Page 1: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/1.jpg)
iOSDC 2017
Shuichi Tsutsumi shu223
WWDC 2014
Swift Metal
WWDC2014 Metal
WWDC2014 Swift
Metal
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 2: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/2.jpg)
WWDC 2014
Swift Metal
WWDC2014 Metal
WWDC2014 Swift
Metal
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 3: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/3.jpg)
Swift Metal
WWDC2014 Metal
WWDC2014 Swift
Metal
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 4: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/4.jpg)
WWDC2014 Metal
WWDC2014 Swift
Metal
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 5: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/5.jpg)
WWDC2014 Swift
Metal
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 6: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/6.jpg)
Metal
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 7: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/7.jpg)
Metal
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 8: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/8.jpg)
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 9: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/9.jpg)
Metal
GPU
bull Core MLbull Visionbull Core Imagebull SceneKitbull SpriteKitbull MapKit
bull Core Animationbull UIKit
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 10: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/10.jpg)
143000Metal API
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 11: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/11.jpg)
143000
17000000Metal API
Metal API
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 12: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/12.jpg)
Metal
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 13: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/13.jpg)
Metal
Metal
Metal
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 14: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/14.jpg)
imageViewimage = image
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 15: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/15.jpg)
CPU GPU
CPUbull
bull
GPUbull
bull CPU
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 16: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/16.jpg)
bull CPU
- 100
bull GPU GPU
-
-
-
-
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 17: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/17.jpg)
1 60
bull CPUbull
OK
1
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 18: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/18.jpg)
1 60
bull CPUbull
OK
GPU
1
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 19: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/19.jpg)
GPU GPU
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 20: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/20.jpg)
GPU
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 21: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/21.jpg)
GPU
GPU
Your app
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 22: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/22.jpg)
OpenGL
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 23: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/23.jpg)
OpenGLbull API
bull
bull Apple
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 24: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/24.jpg)
Metalbull Apple
bull Apple
bull OpenGL 10
bull OpenGL Metal
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 25: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/25.jpg)
imageViewimage = image
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 26: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/26.jpg)
Metal API
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 27: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/27.jpg)
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 28: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/28.jpg)
bull MTLDevice bull MTLCommandQueue bull MTLCommandBuffer bull MTLCommandEncoder bull MTLTexture bull MTKView bull MTKTextureLoader bull etchellip
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 29: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/29.jpg)
$
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 30: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/30.jpg)
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 31: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/31.jpg)
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 32: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/32.jpg)
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTLCommandEncoder
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 33: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/33.jpg)
MTLCommandBuffer
MTLTexture
MTLDevice
MTLCommandQueue
MTKTextureLoader
MTLCommandEncoder
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 34: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/34.jpg)
MTLDevice
let device = MTLCreateSystemDefaultDevice()
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 35: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/35.jpg)
MTLTexture MTKTextureLoader
loader = MTKTextureLoader(device device) texture = try loadernewTexture( name ldquohoge scaleFactor viewcontentScaleFactor bundle nil)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 36: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/36.jpg)
MTLCommandQueue MTLCommandBuffer
let commandBuffer = commandQueuemakeCommandBuffer()
hellip
commandBuffercommit()
commandQueue = devicemakeCommandQueue()
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 37: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/37.jpg)
MTLCommandEncoderbull
MTLRenderCommandEncoder
MTLComputeCommandEncoder
MTLBlitCommandEncode
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 38: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/38.jpg)
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 39: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/39.jpg)
MTLCommandEncoder (MTLBlitCommandEncoder)
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 40: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/40.jpg)
let commandBuffer = commandQueuemakeCommandBuffer()
let blitEncoder = commandBuffermakeBlitCommandEncoder() blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin srcOrigin sourceSize srcSize to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigindstOrigin) blitEncoderendEncoding()
commandBuffercommit()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 41: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/41.jpg)
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 42: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/42.jpg)
private let device = MTLCreateSystemDefaultDevice() private func setup() commandQueue = devicemakeCommandQueue() let textureLoader = MTKTextureLoader(device device) texture = try textureLoadernewTexture(name highsierra scaleFactor viewcontentScaleFactor bundle nil) mtkViewdevice = device mtkViewdelegate = self mtkViewcolorPixelFormat = texturepixelFormat
rarr rarr GPU
rarr GPU
rarr
func draw(in view MTKView) guard let drawable = viewcurrentDrawable else return guard let commandBuffer = commandQueuemakeCommandBuffer() else fatalError() guard let blitEncoder = commandBuffermakeBlitCommandEncoder() else fatalError() let targetW = min(texturewidth drawabletexturewidth) let targetH = min(textureheight drawabletextureheight) blitEncodercopy(from texture sourceSlice 0 sourceLevel 0 sourceOrigin MTLOrigin(x 0 y 0 z 0) sourceSize MTLSizeMake(targetW targetH texturedepth) to drawabletexture destinationSlice 0 destinationLevel 0 destinationOrigin MTLOrigin(x 0 y 0 z 0)) blitEncoderendEncoding() commandBufferpresent(drawable) commandBuffercommit() commandBufferwaitUntilCompleted()
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 43: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/43.jpg)
Powered by
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 44: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/44.jpg)
GPU
GPU
Your app
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 45: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/45.jpg)
Metalbull ARKit
bull MPS CNN RNN
bull Core Image
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 46: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/46.jpg)
GPU Metal
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 47: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/47.jpg)
bull Metal - UIKit
bull GPU GPU
bull Metal - Metal OpenGL
bull Metal -
httpsgithubcomshu223
![Page 48: 飛び道具ではないMetal #iOSDC](https://reader034.vdocuments.pub/reader034/viewer/2022052116/5a65aae07f8b9ab3488b4b2d/html5/thumbnails/48.jpg)
httpsgithubcomshu223