Version: Unity 6 Beta (6000.0)
Language : English
Introduction to Metal
Debug Metal graphics

Metal requirements and compatibility

This page lists the requirements for using Metal as well as the features that Metal is compatible with.

Platform compatibility

Unity supports Metal for the Unity Player on iOS, tvOS, and macOS. Unity also supports Metal for the Unity Editor on macOS.

Hardware compatibility

Unity supports Metal for all Apple devices that Unity supports.

Render pipeline compatibility

Feature Built-in Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
Universal Render Pipeline (URP) High Definition Render Pipeline (HDRP) Custom Scriptable Render Pipeline (SRP)
Metal Yes Yes Yes (macOS only) Yes

Shader compatibility

Shader data types support

When writing shaders in Unity, it’s important to note that Unity defines half as either float or min16float. If Shader Precision Model is set to Platform Default, then half is float on macOS and min16float on iOS/tvOS. If Shader Precision Model is set to Unified, then half is min16float on macOS/tvOS/iOS.

Use half wherever you can to speed up operations, and save memory and battery power. However, as min16float has lower precision than float, you might quickly reach the precision limit and experience visual issues. For example, if you notice infinity or NaN pixelThe smallest unit in a computer image. Pixel size depends on your screen resolution. Pixel lighting is calculated at every screen pixel. More info
See in Glossary
values in frame captures and if you are using half in a shader, it might be a precision issue. To overcome the precision issue, replace a half variable with a float.

To prevent low precision issues that only affect certain platforms (e.g., iOS), it’s a recommended practice to set Shader Precision Model to Unified, so that half is consistent across platforms. As development and testing on macOS are performed before testing on iOS, set the Shader Precision Model to Unified to detect precision errors as early as possible.

From Unity 6 onwards, the size and alignment of min16float on Metal are 4 bytes on any CPU visible buffer, such as vertex shaderA program that runs on each vertex of a 3D model when the model is being rendered. More info
See in Glossary
input, constant buffers, and structured buffers. Therefore, the size and alignment of half is always the same regardless of the platform or project settingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary
. On previous versions of Unity, as the size and alignment of min16float was 2 bytes, the layout of buffers containing half varied depending on the platform and selected Shader Precision Model setting. Because of this issue, iOS and tvOS users had to add C# code as a workaround when uploading data to GPU buffers on iOS/tvOS, which no longer applies to Unity 6. To enable the old behavior when compiling with FXC in Unity 6, you can include #pragma metal_fxc_allow_float16_in_cpu_visible_buffers in your shader.

For more information about shader data types and the precision they support, see Shader data types and precision.

Support implications

16-bit floating point numbers have low precision compared to 32-bit floating point numbers. If you use half and test your application on a device that supports it, you can often see any issues caused by low precision and then fix them. However, if you test your application on a device that doesn’t support half (and substitutes float for half), this can hide precision issues which will appear later when the application runs on a device that supports half.

Introduction to Metal
Debug Metal graphics
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961