rafx

Metal Backend Design Notes

Minimum Requirements

rafx-api requires metal 2.0. iOS GPU family 3 or higher is recommended. (A9 or higher on mobile)

For more info, see the Metal Feature Set Tables provided by Apple.

Status

Metal support is fairly complete but could probably be optimized. See Future Work.

Platform Support

Metal is supported on macOS and iOS only. A9 or higher is recommended on mobile.

Implementation Notes

Coordinate System

rafx-api uses the default metal coordinate system with no modifications.

Validation

Set the environment variable METAL_DEVICE_WRAPPER_TYPE=1

Debugging

Xcode can be used to debug/trace a frame. It can be used by rust by making an empty xcode project and changing the debug settings to launch an external program.

Shader Translation

rafx-api accepts metal source code or compiled shader libraries. You can compile this yourself, or use rafx-shader-processor. The shader processor currently uses vulkan GLSL as input. spirv-cross is used to translate the shader to metal shader language. There are a few things about this process to be aware of:

Subpasses/Tile Shading

Tile shading is not supported in rafx-api. It’s unclear how metal’s abstraction can be mapped to other backends. rafx-api makes the internally created metal objects available to you, so you can always natively implement a performance-critical part of your pipeline if needed.

Future Work