4. Why this topic?
• I am curious about Metal
• What can I do with Metal?
• Is is difficult to use?
• Can i integrated it in my Project?
• I want to use Swift!!
• Not many resources
• Hope to meet other people with same interest ?
Motivation
5. Let's have a look at Apple's Metal Framework
• History
• Metal concepts
• Render pipeline
• Compute pipeline
• Shader
• Demo
• Other possibilities
Agenda
13. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
History
14. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL -> OpenGL
History
15. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
History
19. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
• 3D Graphic cards became popular
History
20. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
• 3D Graphic cards became popular
• 2003 OpenGL ES was released, subset of OpenGL
History
21. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
• 3D Graphic cards became popular
• 2003 OpenGL ES was released, subset of OpenGL
• 2007 iPhone released, supported OpenGL ES
History
22. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
• 3D Graphic cards became popular
• 2003 OpenGL ES was released, subset of OpenGL
• 2007 iPhone released, supported OpenGL ES
• 2010 iPhone supports OpenGL ES 2.0 + Shader
History
23. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
• 3D Graphic cards became popular
• 2003 OpenGL ES was released, subset of OpenGL
• 2007 iPhone released, supported OpenGL ES
• 2010 iPhone supports OpenGL ES 2.0 + Shader
• 2014 Metal was released
History
24. OpenGL
Where does it come from?
• 1981 Silicon Graphics (SGI) was founded
• 1992 opened and renamed IRIS GL API -> OpenGL
• 1996 Quake used OpenGL
• 3D Graphic cards became popular
• 2003 OpenGL ES was released, subset of OpenGL
• 2007 iPhone released, supported OpenGL ES
• 2010 iPhone supports OpenGL ES 2.0 + Shader
• 2014 Metal was released
• 2017 Metal 2 was released
History
25. What is Metal?
• Provides access to the GPU
• Low-level access
• Low-overhead access
• Accelerated 3D graphics rendering
• Data-parallel computation
• Full control of GPU computation power
Metal
🤘
26. Why not OpenGL ES?
• For graphics programming
• Not for general-purpose programming
• Need to copy memory between CPU and GPU
• Very old, has its beginning in the 80’s
• Does not fit for Apple’s plan
OpenGL ES
27. Why Metal?
• For graphics programming
• For general-purpose programming
• CPU and GPU are on the same chip
• No Need to copy memory between CPU and GPU
• Optimized for the chip
• Developer has full control of buffer
• Queue work in preferred order
• Can delay buffer execution
• More control over the performance
Metal
?
32. Assemble vertices to primitive
• Groups vertices into primitive types
• Primitive Types: point, line, lineStrip, triangle, triangleStrip
• Needed for rasterization
37. What belongs to Metal?
• Metal framework
• MetalKit framework
• Metal Performance Shaders framework (MPS)
• Metal shading language (MSL)
• Metal standard library
Metal World
40. MTLDevice
• Represent the actual GPU
• Create command Queue
• Creates pipeline
• Creates Data Buffer
• Access to custom function library
What is it for?
42. MTLCommandQueue
• Created by the MetalDevice
• Creates CommandBuffers
• Queues and schedules CommandBuffers
What is it for?
43. MTLCommandBuffer
• Created every frame
• Creates CommandEncoders
• RenderCommandEncoder
• ParallelRenderCommandEncoder
• ComputeCommandEncoder
• BlitCommandEncoder
• Encodes to the specific GPU hardware
What is it for?
49. MetalKit
MetalKit framework?
• Reduces the boilerplate code
• No need to setup RenderPassDescriptor
• No need to setup MetalLayer
• No need to setup Displaylink
• Provides MTKView
• Provides MTKTextureLoader
• Model Handling
Metal
UIKit + Metal = MetalKit
51. Compute Pipeline
Compute Pipeline
• Only one stage
• shader is marked with kernel keyword
• kernel reads and write directly from/to resource
• Must specify “thread” size
• Fine control performance with threadGroups
Metal
53. Resume
Resume
• A lot of information
• But not too difficult
• An own world
• Compute Pipeline very powerful
• Particles
• Apple says its good for AR, VR, Cryptography, Machine
learning, Physics and Finance
!