Speed Metal: New features of Apple’s Metal 3 in practice
At WWDC 2022, Apple introduced Metal 3, a major update where almost everything revolves around performance: be it faster code, faster programming or faster debugging. In addition, Apple has added a number of additional features to the new Metal 3 that are worth taking a closer look at: Optimized Ray Tracing gets the GPU up to speed, Metal FX Upscaling converts small images into large ones, Offline Shader Loading compiles shaders during the build of Apps, Fast Resource Loading speeds up the loading of large textures, and mesh shaders process entire hierarchies of geometric objects on the GPU instead of vertex shaders.
- Many new features in Metal 3 are dedicated to performance and require current hardware and operating systems.
- Metal 3 accelerates ray tracing, can convert small images into large ones, and compiles shaders during the build.
- Most of the features considered are easy to use in existing code.
- Xcode 14 makes debugging Metal 3 apps easier with some improved and new GUIs.
- On macOS, Metal 3 offers backends for the machine learning frameworks TensorFlow and PyTorch.
Metal 3 is part of the iOS 16, iPadOS 16, tvOS 16 and macOS Ventura operating systems. The new features require at least one A13 Bionic or M1 SoC (system-on-a-chip) in the iPhone and iPad. Macs with Apple Silicon, AMD or Intel chips are also suitable. with the new value .metal3
in the enumeration MTLGPUFamily
and the MTLDevice protocol, the availability of Metal 3 for the chip used can be checked at runtime. Apple summarizes the functional limitations of older devices in the table Metal Feature Set Tables (link in web code).
if device.supportsFamily(.metal3) {
…
}
The showcase is the SpeedMetal app. She implements a simple ray tracer with controls for some of the new features in Metal 3. Within the app there are three scenes with one, four and nine Cornell boxes, a kind of Hello World for graphics programs. A runtime indicator for the render pipeline shows how the features look when they are on or off.