<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLBuffer/makeTexture(descriptor:offset:bytesPerRow:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLBuffer(im)newTextureWithDescriptor:offset:bytesPerRow:"
  },
  "title" : "makeTexture(descriptor:offset:bytesPerRow:)"
}
-->

# makeTexture(descriptor:offset:bytesPerRow:)

Creates a texture that shares its storage with the buffer.

```
func makeTexture(descriptor: MTLTextureDescriptor, offset: Int, bytesPerRow: Int) -> (any MTLTexture)?
```

## Parameters

`descriptor`

The descriptor that contains the properties of the texture.

`offset`

The offset, in bytes, from the base address for the first row of texture data.

`bytesPerRow`

The stride, in bytes, from one row of texture data to the next.

## Return Value

A new texture that shares the buffer’s underlying storage.

## Discussion

This method creates a new [`MTLTexture`](/documentation/Metal/MTLTexture) instance that uses the same data as the buffer’s. Modifying the buffer also modifies the new texture because they share the same underlying memory.

> Note:
> Metal may not be able to optimize a texture that shares memory with a buffer.

The texture’s resource data is coherent between multiple render passes.
However, that data may not be coherent within a single render pass due to caching at runtime.
For example, a texture you create from the method may not be able to immediately reflect
changes to the underlying buffer that come from a render or kernel function.

If this buffer’s [`storageMode`](/documentation/Metal/MTLTextureDescriptor/storageMode) is [`MTLStorageMode.managed`](/documentation/Metal/MTLStorageMode/managed),
and a render or kernel function modifies it, the CPU can access the new values through a texture after calling the [`synchronize(resource:)`](/documentation/Metal/MTLBlitCommandEncoder/synchronize(resource:)) method.
CPU memory operations are only coherent between command buffer boundaries.
GPU barriers guard its memory operations to buffers and textures so that each operation finishes running before the next one begins.

You can create multiple, nonoverlapping textures that use the same buffer; however, the GPU serializes memory operations to those textures.

> Tip:
> You can avoid the GPU’s texture access serialization by creating multiple buffers and then creating a texture from each buffer with this method.

To create a linear texture, you need to:

- Align the `offset` and `bytesPerRow` parameters to the value that the [`minimumLinearTextureAlignment(for:)`](/documentation/Metal/MTLDevice/minimumLinearTextureAlignment(for:)) method returns.
- Set the `bytesPerRow` parameter to a value greater than or equal to the number of bytes in one row of pixels — the product of the row’s width, in pixels, and the size of one pixel, in bytes.

Additionally, creating a linear texture from this method adds the following restrictions for the `descriptor` parameter’s properties:

|Property                                                                           |Acceptable values for a linear texture                                                                                                                                                                                                                                                                                                                                                                    |
|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/textureType``     |``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2D`` or ``doc://com.apple.metal/documentation/Metal/MTLTextureType/typeTextureBuffer``                                                                                                                                                                                                                                                     |
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/depth``           |`1`                                                                                                                                                                                                                                                                                                                                                                                                       |
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/arrayLength``     |`1`                                                                                                                                                                                                                                                                                                                                                                                                       |
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/mipmapLevelCount``|`1`                                                                                                                                                                                                                                                                                                                                                                                                       |
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/sampleCount``     |`1`                                                                                                                                                                                                                                                                                                                                                                                                       |
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/usage``           |The ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/renderTarget`` value if the ``doc://com.apple.metal/documentation/Metal/MTLDevice`` instance supports ``doc://com.apple.metal/documentation/Metal/MTLGPUFamily/apple1`` (see ``doc://com.apple.metal/documentation/Metal/MTLDevice/supportsFamily(_:)``), or any other ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage`` value|
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/storageMode``     |The same value as this buffer’s ``doc://com.apple.metal/documentation/Metal/MTLResource/storageMode`` property (see <doc://com.apple.metal/documentation/Metal/resource-fundamentals>)                                                                                                                                                                                                                    |
|``doc://com.apple.metal/documentation/Metal/MTLTextureDescriptor/pixelFormat``     |Any ordinary or packed color ``doc://com.apple.metal/documentation/Metal/MTLPixelFormat``, except ``doc://com.apple.metal/documentation/Metal/MTLPixelFormat/gbgr422`` and ``doc://com.apple.metal/documentation/Metal/MTLPixelFormat/bgrg422``                                                                                                                                                           |

Samplers can use any [`MTLSamplerAddressMode`](/documentation/Metal/MTLSamplerAddressMode) to sample linear textures from this method on any device that supports the [`MTLGPUFamily.apple2`](/documentation/Metal/MTLGPUFamily/apple2) feature family or later.

> Note:
> For devices that support only the ``doc://com.apple.metal/documentation/Metal/MTLGPUFamily/apple1`` feature family, samplers can only use ``doc://com.apple.metal/documentation/Metal/MTLSamplerAddressMode/clampToEdge`` to sample a linear texture.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)