<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVMetalBufferCacheCreateBufferFromImage(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "c:@F@CVMetalBufferCacheCreateBufferFromImage"
  },
  "title" : "CVMetalBufferCacheCreateBufferFromImage(_:_:_:_:)"
}
-->

# CVMetalBufferCacheCreateBufferFromImage(_:_:_:_:)

```
func CVMetalBufferCacheCreateBufferFromImage(_ allocator: CFAllocator?, _ bufferCache: CVMetalBufferCache, _ imageBuffer: CVImageBuffer, _ bufferOut: UnsafeMutablePointer<CVMetalBuffer?>) -> CVReturn
```

## Parameters

`allocator`

The CFAllocatorRef to use for allocating the CVMetalBuffer object. May be NULL.

`bufferCache`

The buffer cache object that will manage the buffer.

`bufferOut`

The newly created buffer object will be placed here.

## Return Value

Returns kCVReturnSuccess on success

## Discussion

\abstract Creates a CVMetalBuffer object from an existing CVImageBuffer
\discussion Creates or returns a cached CVMetalBuffer object mapped to the CVImageBuffer.
This creates a live binding between the CVImageBuffer and underlying CVMetalBuffer buffer object.

```
        IMPORTANT NOTE: Clients should retain CVMetalBuffer objects until they are done using the images in them.
        Retaining a CVMetalBuffer is your way to indicate that you're still using the image in the buffer, and that it should not be recycled yet.
```

---

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)