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
MTLStorage mode defines system memory accessible to both the CPU and the GPU, whereas the
MTLStorage mode defines system memory accessible only to the GPU.
MTLStorage 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.
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
MTLStorage mode if your resource requires CPU access.
Accessed exclusively by the GPU. Choose the
MTLStorage 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
MTLStorage mode and populate its contents. Then, use the GPU to copy the resource’s contents into another resource with a
Accessed exclusively by the GPU, and its contents are temporary (textures only). Choose the
MTLStorage 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
storage property of a
MTLStorage and use this descriptor to create a new
MTLTexture. Then set this new texture as the
texture property of a
See Deferred Lighting for an example of an app that uses a memoryless render target.