Allocates a new buffer of a given length and initializes its contents by copying existing data into it.
Required.
SDKs
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- Metal
Declaration
- (id<MTLBuffer>)newBufferWithBytes:(const void *)pointer length:(NSUInteger)length options:(MTLResource Options)options;
Parameters
pointer
The memory address from which to copy the initial data.
length
The size of the new buffer, in bytes. This is also the number of bytes that are copied from the
pointer
argument.options
Specifies the behavior of the new buffer.
Return Value
A new MTLBuffer
object that contains the data copied from the pointer
argument.
Discussion
The storage allocation of the new MTLBuffer
object is not the same as the storage allocation of the pointer
argument.
MTLBuffer
objects created with this method are CPU-accessible and can be specified with a MTLResource
or MTLResource
storage mode, but not a MTLResource
storage mode.