2 Data Types
This chapter details the Metal data types, including types that represent vectors and matrices.
Atomic data types, buffers, textures, samplers, arrays, and user-defined structs are also
discussed. Type alignment and type conversion are also described.
2.1 Scalar Data Types
Metal supports the scalar types listed in Table 1. Metal does
not support the
double
,
long
,
unsigned long
,
long long
,
unsigned long long
, and
long double
data types.
Table 1 Metal Scalar Data Types
Type
Description
bool
A conditional data type that has the value of either
true
or
false
.
The value
true
expands to the integer constant 1, and the value
false
expands to the integer constant 0.
char
int8_t
A signed two’s complement 8-bit integer.
unsigned char
uchar
uint8_t
An unsigned 8-bit integer.
short
int16_t
A signed two’s complement 16-bit integer.
unsigned short
ushort
unit16_t
An unsigned 16-bit integer.
int
int32_t
A signed two’s complement 32-bit integer.
unsigned int
uint
uint32_t
An unsigned 32-bit integer.
half
A 16-bit floating-point. The half data type must conform to the
IEEE 754 binary16 storage format.
float
A 32-bit floating-point. The float data type must conform to the
IEEE 754 single precision storage format.
size_t
An unsigned integer type of the result of the
sizeof
operator. This
is a 64-bit unsigned integer.
2017-9-12 | Copyright © 2017 Apple Inc. All Rights Reserved.
Page of
11
174