Choosing a Resource Storage Mode in iOS and tvOS

Choose an appropriate storage mode for your iOS and tvOS resources.


All iOS and tvOS devices have a unified memory model in which the CPU and the GPU share system memory. However, CPU and GPU access to that memory depends on the chosen storage mode for your resources. The MTLStorageMode.shared mode defines system memory accessible to both the CPU and the GPU, whereas the MTLStorageMode.private mode defines system memory accessible only to the GPU.

The MTLStorageMode.memoryless mode defines tile memory within the GPU accessible only to the GPU. Tile memory has higher bandwidth, lower latency, and lower power consumption than system memory.

A system diagram of resource storage modes in iOS and tvOS, showing the memory location and access permissions for resources configured with a shared, private, or memoryless mode.

Choose a Resource Storage Mode for Buffers or Textures

For guidance on how to set a storage mode, see Setting Resource Storage Modes. Several options are available, depending on your resource’s access needs:

Populated and updated by the CPU. Choose the MTLStorageMode.shared mode if your resource requires CPU access.

Accessed exclusively by the GPU. Choose the MTLStorageMode.private mode if you populate your resource with the GPU through a compute, render, or blit pass. This case is common for render targets, intermediary resources, or texture streaming.

Populated once by the CPU and accessed frequently by a GPU. Use the CPU to create a resource with a MTLStorageMode.shared mode and populate its contents. Then, use the GPU to copy the resource’s contents into another resource with a MTLStorageMode.private mode.

Accessed exclusively by the GPU, and its contents are temporary (textures only). Choose the MTLStorageMode.memoryless mode if your texture is a memoryless render target that’s temporarily populated and accessed by the GPU. Memoryless render targets are render targets that exist only in tile memory and are not backed by system memory. An example is a depth or stencil texture thatʼs used only within a render pass and isnʼt needed before or after GPU execution.

For guidance on how to copy data to a private resource, see Copying Data to a Private Resource.

Create a Memoryless Render Target

To create a memoryless render target, set the storageMode property of a MTLTextureDescriptor to MTLStorageMode.memoryless and use this descriptor to create a new MTLTexture. Then set this new texture as the texture property of a MTLRenderPassAttachmentDescriptor.

let memorylessDescriptor = MTLTextureDescriptor.texture2DDescriptor(pixelFormat: .r16Float,
                                                                    width: 256,
                                                                    height: 256,
                                                                    mipmapped: true)
memorylessDescriptor.storageMode = .memoryless
let memorylessTexture = device.makeTexture(descriptor: memorylessDescriptor)

let renderPassDescriptor = MTLRenderPassDescriptor()
renderPassDescriptor.depthAttachment.texture = memorylessTexture

See Deferred Lighting for an example of an app that uses a memoryless render target.

See Also

Resource Storage Modes by Platform

Choosing a Resource Storage Mode in macOS

Choose an appropriate storage mode for your macOS resources.