A memory allocation for storing unformatted data that is accessible to the GPU.
- iOS 8.0+
- macOS 10.11+
- tvOS 9.0+
MTLBuffer protocol defines the interface for objects that represent an allocation of unformatted, device-accessible memory that can contain any type of data. Your app does not define classes that implement this protocol.
Do not create a
MTLBuffer object by using standard allocation or initialization techniques. Instead, use the following
MTLDevice methods to create
MTLBufferobject with a new storage allocation.
Buffer(bytes: length: options:)
MTLBufferobject by copying data from an existing storage allocation into a new allocation.
Buffer(bytes No Copy: length: options: deallocator:)
MTLBufferobject that reuses an existing storage allocation and does not allocate any new storage.
On systems with dedicated memory, when buffers are created with a managed resource storage mode (
MTLStorage), Metal allocates a copy in CPU memory and a second copy in GPU memory. After your application writes are complete, you must call
did to inform Metal that the updated contents in the CPU memory copy must be uploaded to the GPU memory copy. No separate allocation is made on systems with integrated memory.