The Metal shading language is a unified programming language for writing both graphics and compute kernel functions that are used by apps written with the Metal framework.
The Metal shading language is designed to work together with the Metal framework, which manages the execution, and optionally the compilation, of the Metal shading language code. The Metal shading language uses clang and LLVM so developers get a compiler that delivers close to the metal performance for code executing on the GPU.
At a Glance
This document describes the Metal unified graphics and compute shading language. The Metal shading language is a C++ based programming language that developers can use to write code that is executed on the GPU for graphics and general-purpose data-parallel computations. Since the Metal shading language is based on C++, developers will find it familiar and easy to use. With the Metal shading language, both graphics and compute programs can be written with a single, unified language, which allows tighter integration between the.
How to Use This Document
Developers who are writing code with the Metal framework will want to read this document, because they will need to use the Metal shading language to write graphics and compute programs to be executed on the GPU. This document is organized into the following chapters:
Metal and C++11 covers the similarities and differences between the Metal shading language and C++11.
Metal Data Types lists the Metal shading language data types, including types that represent vectors, matrices, buffers, textures, and samplers. It also discusses type alignment and type conversion.
Operators lists the Metal shading language operators.
Functions, Variables, and Qualifiers details how functions and variables are declared, sometimes with qualifiers that restrict how they are used.
Metal Standard Library defines a collection of built-in Metal shading language functions.
Compiler Options details the options for the Metal shading language compiler, including preprocessor directives, options for math intrinsics, and options that control optimization.
Numerical Compliance describes requirements for representing floating-point numbers, including accuracy in mathematical operations.
Stroustrup, Bjarne. The C++ Programming Language, 4th ed., Addison-Wesley Professional, 2013.