Enumeration

MTLPixelFormat

The data formats that describe the organization and characteristics of individual pixels in a texture.

Declaration

typedef enum MTLPixelFormat : NSUInteger {
    ...
} MTLPixelFormat;

Overview

There are three varieties of pixel formats: ordinary, packed, and compressed. For ordinary and packed formats, the name of the pixel format specifies the order of components (such as R, RG, RGB, RGBA, BGRA), bits per component (such as 8, 16, 32), and data type for the component (such as Float, Sint, Snorm, Uint, Unorm). If the pixel format name has the _sRGB suffix, then sRGB gamma compression and decompression are applied during the reading and writing of color values in the pixel. For compressed formats, the name of the pixel format specifies a compression family (such as ASTC, BC, EAC, ETC2, PVRTC).

Storage Characteristics

The storage size of each pixel format is determined by the sum of its components. For example, the storage size of BGRA8Unorm is 32 bits (four 8-bit components) and the storage size of BGR5A1Unorm is 16 bits (three 5-bit components and one 1-bit component).

For normalized signed integer formats (Snorm), component values in the range [-1.0, 1.0] are stored as [MIN_INT, MAX_INT], where MIN_INT is the greatest negative integer and MAX_INT is the greatest positive integer that can be stored, given the bit size of the component. For normalized unsigned integer formats (Unorm), component values in the range [0.0, 1.0] are stored as [0, MAX_UINT], where MAX_UINT is the greatest unsigned integer that can be stored, given the bit size of the component.

Format data is stored in little-endian order (that is, the least-significant byte in the least-significant address). For formats with components that are themselves byte-aligned and more than one byte, the components are little-endian.

Topics

Ordinary 8-Bit Pixel Formats

MTLPixelFormatA8Unorm

Ordinary format with one 8-bit normalized unsigned integer component.

MTLPixelFormatR8Unorm

Ordinary format with one 8-bit normalized unsigned integer component.

MTLPixelFormatR8Unorm_sRGB

Ordinary format with one 8-bit normalized unsigned integer component with conversion between sRGB and linear space.

MTLPixelFormatR8Snorm

Ordinary format with one 8-bit normalized signed integer component.

MTLPixelFormatR8Uint

Ordinary format with one 8-bit unsigned integer component.

MTLPixelFormatR8Sint

Ordinary format with one 8-bit signed integer component.

Ordinary 16-Bit Pixel Formats

MTLPixelFormatR16Unorm

Ordinary format with one 16-bit normalized unsigned integer component.

MTLPixelFormatR16Snorm

Ordinary format with one 16-bit normalized signed integer component.

MTLPixelFormatR16Uint

Ordinary format with one 16-bit unsigned integer component.

MTLPixelFormatR16Sint

Ordinary format with one 16-bit signed integer component.

MTLPixelFormatR16Float

Ordinary format with one 16-bit floating-point component.

MTLPixelFormatRG8Unorm

Ordinary format with two 8-bit normalized unsigned integer components.

MTLPixelFormatRG8Unorm_sRGB

Ordinary format with two 8-bit normalized unsigned integer components with conversion between sRGB and linear space.

MTLPixelFormatRG8Snorm

Ordinary format with two 8-bit normalized signed integer components.

MTLPixelFormatRG8Uint

Ordinary format with two 8-bit unsigned integer components.

MTLPixelFormatRG8Sint

Ordinary format with two 8-bit signed integer components.

Packed 16-Bit Pixel Formats

MTLPixelFormatB5G6R5Unorm

Packed 16-bit format with normalized unsigned integer color components: 5 bits for blue, 6 bits for green, 5 bits for red, packed into 16 bits.

MTLPixelFormatA1BGR5Unorm

Packed 16-bit format with normalized unsigned integer color components: 5 bits each for BGR and 1 for alpha, packed into 16 bits.

MTLPixelFormatABGR4Unorm

Packed 16-bit format with normalized unsigned integer color components: 4 bits each for ABGR, packed into 16 bits.

MTLPixelFormatBGR5A1Unorm

Packed 16-bit format with normalized unsigned integer color components: 5 bits each for BGR and 1 for alpha, packed into 16 bits.

Ordinary 32-Bit Pixel Formats

MTLPixelFormatR32Uint

Ordinary format with one 32-bit unsigned integer component.

MTLPixelFormatR32Sint

Ordinary format with one 32-bit signed integer component.

MTLPixelFormatR32Float

Ordinary format with one 32-bit floating-point component.

MTLPixelFormatRG16Unorm

Ordinary format with two 16-bit normalized unsigned integer components.

MTLPixelFormatRG16Snorm

Ordinary format with two 16-bit normalized signed integer components.

MTLPixelFormatRG16Uint

Ordinary format with two 16-bit unsigned integer components.

MTLPixelFormatRG16Sint

Ordinary format with two 16-bit signed integer components.

MTLPixelFormatRG16Float

Ordinary format with two 16-bit floating-point components.

MTLPixelFormatRGBA8Unorm

Ordinary format with four 8-bit normalized unsigned integer components in RGBA order.

MTLPixelFormatRGBA8Unorm_sRGB

Ordinary format with four 8-bit normalized unsigned integer components in RGBA order with conversion between sRGB and linear space.

MTLPixelFormatRGBA8Snorm

Ordinary format with four 8-bit normalized signed integer components in RGBA order.

MTLPixelFormatRGBA8Uint

Ordinary format with four 8-bit unsigned integer components in RGBA order.

MTLPixelFormatRGBA8Sint

Ordinary format with four 8-bit signed integer components in RGBA order.

MTLPixelFormatBGRA8Unorm

Ordinary format with four 8-bit normalized unsigned integer components in BGRA order.

MTLPixelFormatBGRA8Unorm_sRGB

Ordinary format with four 8-bit normalized unsigned integer components in BGRA order with conversion between sRGB and linear space.

Packed 32-Bit Pixel Formats

MTLPixelFormatRGB10A2Unorm

A 32-bit packed pixel format with four normalized unsigned integer components: 10-bit red, 10-bit green, 10-bit blue, and 2-bit alpha.

MTLPixelFormatRGB10A2Uint

A 32-bit packed pixel format with four unsigned integer components: 10-bit red, 10-bit green, 10-bit blue, and 2-bit alpha.

MTLPixelFormatRG11B10Float

32-bit format with floating-point color components, 11 bits each for red and green and 10 bits for blue.

MTLPixelFormatRGB9E5Float

Packed 32-bit format with floating-point color components: 9 bits each for RGB and 5 bits for an exponent shared by RGB, packed into 32 bits.

Ordinary 64-Bit Pixel Formats

MTLPixelFormatRG32Uint

Ordinary format with two 32-bit unsigned integer components.

MTLPixelFormatRG32Sint

Ordinary format with two 32-bit signed integer components.

MTLPixelFormatRG32Float

Ordinary format with two 32-bit floating-point components.

MTLPixelFormatRGBA16Unorm

Ordinary format with four 16-bit normalized unsigned integer components in RGBA order.

MTLPixelFormatRGBA16Snorm

Ordinary format with four 16-bit normalized signed integer components in RGBA order.

MTLPixelFormatRGBA16Uint

Ordinary format with four 16-bit unsigned integer components in RGBA order.

MTLPixelFormatRGBA16Sint

Ordinary format with four 16-bit signed integer components in RGBA order.

MTLPixelFormatRGBA16Float

Ordinary format with four 16-bit floating-point components in RGBA order.

Ordinary 128-Bit Pixel Formats

MTLPixelFormatRGBA32Uint

Ordinary format with four 32-bit unsigned integer components in RGBA order.

MTLPixelFormatRGBA32Sint

Ordinary format with four 32-bit signed integer components in RGBA order.

MTLPixelFormatRGBA32Float

Ordinary format with four 32-bit floating-point components in RGBA order.

Compressed PVRTC Pixel Formats

MTLPixelFormatPVRTC_RGB_2BPP

Compressed format using PVRTC compression and 2bpp for RGB components.

MTLPixelFormatPVRTC_RGB_2BPP_sRGB

Compressed format using PVRTC compression and 2bpp for RGB components with conversion between sRGB and linear space.

MTLPixelFormatPVRTC_RGB_4BPP

Compressed format using PVRTC compression and 4bpp for RGB components.

MTLPixelFormatPVRTC_RGB_4BPP_sRGB

Compressed format using PVRTC compression and 4bpp for RGB components with conversion between sRGB and linear space.

MTLPixelFormatPVRTC_RGBA_2BPP

Compressed format using PVRTC compression and 2bpp for RGBA components.

MTLPixelFormatPVRTC_RGBA_2BPP_sRGB

Compressed format using PVRTC compression and 2bpp for RGBA components with conversion between sRGB and linear space.

MTLPixelFormatPVRTC_RGBA_4BPP

Compressed format using PVRTC compression and 4bpp for RGBA components.

MTLPixelFormatPVRTC_RGBA_4BPP_sRGB

Compressed format using PVRTC compression and 4bpp for RGBA components with conversion between sRGB and linear space.

Compressed EAC/ETC Pixel Formats

MTLPixelFormatEAC_R11Unorm

Compressed format using EAC compression with one normalized unsigned integer component.

MTLPixelFormatEAC_R11Snorm

Compressed format using EAC compression with one normalized signed integer component.

MTLPixelFormatEAC_RG11Unorm

Compressed format using EAC compression with two normalized unsigned integer components.

MTLPixelFormatEAC_RG11Snorm

Compressed format using EAC compression with two normalized signed integer components.

MTLPixelFormatEAC_RGBA8

Compressed format using EAC compression with four 8-bit components.

MTLPixelFormatEAC_RGBA8_sRGB

Compressed format using EAC compression with four 8-bit components with conversion between sRGB and linear space.

MTLPixelFormatETC2_RGB8

Compressed format using ETC2 compression with three 8-bit components.

MTLPixelFormatETC2_RGB8_sRGB

Compressed format using ETC2 compression with three 8-bit components with conversion between sRGB and linear space.

MTLPixelFormatETC2_RGB8A1

Compressed format using ETC2 compression with four 8-bit components.

MTLPixelFormatETC2_RGB8A1_sRGB

Compressed format using ETC2 compression with four 8-bit components with conversion between sRGB and linear space.

Compressed ASTC Pixel Formats

MTLPixelFormatASTC_4x4_sRGB

Compressed format using ASTC compression low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 4, the block height of 4, and a bit rate of 8.0 bits per pixel.

MTLPixelFormatASTC_5x4_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 5, the block height of 4, and a bit rate of 6.4 bits per pixel.

MTLPixelFormatASTC_5x5_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 5, the block height of 5, and a bit rate of 5.12 bits per pixel.

MTLPixelFormatASTC_6x5_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 6, the block height of 5, and a bit rate of 4.27 bits per pixel.

MTLPixelFormatASTC_6x6_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 6, the block height of 6, and a bit rate of 3.56 bits per pixel.

MTLPixelFormatASTC_8x5_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 8, the block height of 5, and a bit rate of 3.2 bits per pixel.

MTLPixelFormatASTC_8x6_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 8, the block height of 6, and a bit rate of 2.67 bits per pixel.

MTLPixelFormatASTC_8x8_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 8, the block height of 8, and a bit rate of 2.0 bits per pixel.

MTLPixelFormatASTC_10x5_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 10, the block height of 5, and a bit rate of 2.56 bits per pixel.

MTLPixelFormatASTC_10x6_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 10, the block height of 6, and a bit rate of 2.13 bits per pixel.

MTLPixelFormatASTC_10x8_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 10, the block height of 8, and a bit rate of 1.6 bits per pixel.

MTLPixelFormatASTC_10x10_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 10, the block height of 10, and a bit rate of 1.28 bits per pixel.

MTLPixelFormatASTC_12x10_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 12, the block height of 10, and a bit rate of 1.07 bits per pixel.

MTLPixelFormatASTC_12x12_sRGB

Compressed format using ASTC compression with low-dynamic range content and conversion between sRGB and linear space. The image is encoded with the block width of 12, the block height of 12, and a bit rate of 0.89 bits per pixel.

MTLPixelFormatASTC_4x4_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 4, the block height of 4, and a bit rate of 8.0 bits per pixel.

MTLPixelFormatASTC_5x4_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 5, the block height of 4, and a bit rate of 6.4 bits per pixel.

MTLPixelFormatASTC_5x5_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 5, the block height of 5, and a bit rate of 5.12 bits per pixel.

MTLPixelFormatASTC_6x5_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 6, the block height of 5, and a bit rate of 4.27 bits per pixel.

MTLPixelFormatASTC_6x6_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 6, the block height of 6, and a bit rate of 3.56 bits per pixel.

MTLPixelFormatASTC_8x5_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 8, the block height of 5, and a bit rate of 3.2 bits per pixel.

MTLPixelFormatASTC_8x6_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 8, the block height of 6, and a bit rate of 2.67 bits per pixel.

MTLPixelFormatASTC_8x8_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 8, the block height of 8, and a bit rate of 2.0 bits per pixel.

MTLPixelFormatASTC_10x5_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 10, the block height of 5, and a bit rate of 2.56 bits per pixel.

MTLPixelFormatASTC_10x6_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 10, the block height of 6, and a bit rate of 2.13 bits per pixel.

MTLPixelFormatASTC_10x8_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 10, the block height of 8, and a bit rate of 1.6 bits per pixel.

MTLPixelFormatASTC_10x10_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 10, the block height of 10, and a bit rate of 1.28 bits per pixel.

MTLPixelFormatASTC_12x10_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 12, the block height of 10, and a bit rate of 1.07 bits per pixel.

MTLPixelFormatASTC_12x12_LDR

Compressed format using ASTC compression with low-dynamic range content that is encoded with the block width of 12, the block height of 12, and a bit rate of 0.89 bits per pixel.

Compressed BC Pixel Formats

MTLPixelFormatBC1_RGBA

Compressed format with two 16-bit color components and one 32-bit descriptor component.

MTLPixelFormatBC1_RGBA_sRGB

Compressed format with two 16-bit color components and one 32-bit descriptor component, with conversion between sRGB and linear space.

MTLPixelFormatBC2_RGBA

Compressed format with two 64-bit chunks. The first chunk contains two 8-bit alpha components and one 48-bit descriptor component. The second chunk contains two 16-bit color components and one 32-bit descriptor component.

MTLPixelFormatBC2_RGBA_sRGB

Compressed format with two 64-bit chunks, with conversion between sRGB and linear space. The first chunk contains two 8-bit alpha components and one 48-bit descriptor component. The second chunk contains two 16-bit color components and one 32-bit descriptor component.

MTLPixelFormatBC3_RGBA

Compressed format with two 64-bit chunks. The first chunk contains two 8-bit alpha components and one 48-bit descriptor component. The second chunk contains two 16-bit color components and one 32-bit descriptor component.

MTLPixelFormatBC3_RGBA_sRGB

Compressed format with two 64-bit chunks, with conversion between sRGB and linear space. The first chunk contains two 8-bit alpha components and one 48-bit descriptor component. The second chunk contains two 16-bit color components and one 32-bit descriptor component.

MTLPixelFormatBC4_RUnorm

Compressed format with one normalized unsigned integer component.

MTLPixelFormatBC4_RSnorm

Compressed format with one normalized signed integer component.

MTLPixelFormatBC5_RGUnorm

Compressed format with two normalized unsigned integer components.

MTLPixelFormatBC5_RGSnorm

Compressed format with two normalized signed integer components.

MTLPixelFormatBC6H_RGBFloat

Compressed format with four floating-point components.

MTLPixelFormatBC6H_RGBUfloat

Compressed format with four unsigned floating-point components.

MTLPixelFormatBC7_RGBAUnorm

Compressed format with four normalized unsigned integer components.

MTLPixelFormatBC7_RGBAUnorm_sRGB

Compressed format with four normalized unsigned integer components, with conversion between sRGB and linear space.

YUV Pixel Formats

MTLPixelFormatGBGR422

A pixel format where the red and green components are subsampled horizontally.

MTLPixelFormatBGRG422

A pixel format where the red and green components are subsampled horizontally.

Depth and Stencil Pixel Formats

MTLPixelFormatDepth16Unorm

A 16-bit depth pixel format with one normalized unsigned integer component, typically used for a depth render target.

MTLPixelFormatDepth32Float

A 32-bit depth pixel format with one 32-bit floating-point component, typically used for a depth render target.

MTLPixelFormatStencil8

An 8-bit stencil pixel format with one 8-bit floating-point component, typically used for a stencil render target.

MTLPixelFormatDepth24Unorm_Stencil8

A packed 32-bit combined depth and stencil pixel format with two normalized unsigned integer components: 24 bits, typically used for a depth render target, and 8 bits, typically used for a stencil render target.

MTLPixelFormatDepth32Float_Stencil8

A 64-bit combined depth and stencil pixel format with two floating-point components: 32 bits, typically used for a depth render target, and 8 bits, typically used for a stencil render target.

MTLPixelFormatX32_Stencil8

A stencil pixel format used for a stencil texture view, typically created from a parent texture with the MTLPixelFormatDepth32Float_Stencil8 pixel format.

MTLPixelFormatX24_Stencil8

A stencil pixel format used for a stencil texture view, typically created from a parent texture with the MTLPixelFormatDepth24Unorm_Stencil8 pixel format.

Extended Range and Wide Color Pixel Formats

MTLPixelFormatBGRA10_XR

A 64-bit extended range pixel format with four fixed-point components: 10-bit blue, 10-bit green, 10-bit red, and 10-bit alpha.

MTLPixelFormatBGRA10_XR_sRGB

A 64-bit extended range pixel format with sRGB conversion and four fixed-point components: 10-bit blue, 10-bit green, 10-bit red, and 10-bit alpha.

MTLPixelFormatBGR10_XR

A 32-bit extended range pixel format with three fixed-point components: 10-bit blue, 10-bit green, and 10-bit red.

MTLPixelFormatBGR10_XR_sRGB

A 32-bit extended range pixel format with sRGB conversion and three fixed-point components: 10-bit blue, 10-bit green, and 10-bit red.

MTLPixelFormatBGR10A2Unorm

A 32-bit packed pixel format with four normalized unsigned integer components: 10-bit blue, 10-bit green, 10-bit red, and 2-bit alpha.

Invalid Pixel Format

MTLPixelFormatInvalid

The default value of the pixel format for the MTLRenderPipelineState. You cannot create a texture with this value.

See Also

Textures

Basic Texturing

Demonstrates how to load image data and texture a quad.

About Color-Renderable Pixel Format Sizes

Know the size limits of pixel formats used by color render targets in iOS and tvOS GPUs.

MTLTexture

A memory allocation for storing formatted image data that is accessible to the GPU.

MTLTextureDescriptor

An object that configures new MTLTexture objects.

MTKTextureLoader

An object that decodes common image formats into Metal textures for use in your app.

MTLSharedTextureHandle

A texture handle that can be shared across process address space boundaries.