Creates a texture that shares its storage with the buffer.
- iOS 8.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 9.0+
The descriptor that contains the properties of the texture.
The offset, in bytes, from the base address for the first row of texture data.
The stride, in bytes, from one row of texture data to the next.
A texture that shares its storage with this buffer.
This method creates a new
MTLTexture object whose texture data is the same as the buffer data in the
MTLBuffer object. The texture shares the same memory storage as the originating buffer, so modifying the buffer data also modifies the texture data.
Data Access and Coherence
The resource data is coherent between multiple render passes. However, data access within a single render pass may not be coherent due to possible data caching at execution time. For example, in a graphics or compute function, data written to the buffer may not be immediately available in a subsequent texture read.
On macOS, if the resource data has been modified by the graphics processing unit (GPU), you must call the
synchronize(resource:) method to update the data before a subsequent CPU access. CPU access is only coherent between command buffer boundaries. GPU barriers can guard GPU access to buffers and textures, so any earlier access is always executed before a later access.
Multiple nonoverlapping textures can be created from the same buffer. However, references to any of these textures are serialized. If you want to avoid this serialization, first create multiple buffers and then create an individual texture from each buffer.
Linear Texture Restrictions
bytes parameters must be byte aligned to the size returned by the
minimum method. The
bytes parameter must also be greater than or equal to the size of one pixel, in bytes, multiplied by the pixel width of one row.
descriptor parameter has the following restrictions on its properties:
arraymust be 1.
samplemust be 1.
pixelmust not be a depth, stencil, combined depth and stencil, or compressed pixel format. Ordinary and packed color pixel formats are supported, excluding