<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4CommandBuffer/beginCommandBuffer(allocator:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTL4CommandBuffer(im)beginCommandBufferWithAllocator:options:"
  },
  "title" : "beginCommandBuffer(allocator:options:)"
}
-->

# beginCommandBuffer(allocator:options:)

Prepares a command buffer for encoding with additional options.

```
func beginCommandBuffer(allocator: any MTL4CommandAllocator, options: MTL4CommandBufferOptions)
```

## Parameters

`allocator`

[`MTL4CommandAllocator`](/documentation/Metal/MTL4CommandAllocator) to attach to.

`options`

[`MTL4CommandBufferOptions`](/documentation/Metal/MTL4CommandBufferOptions) to configure the command buffer.

## Discussion

Attaches the command buffer to the specified [`MTL4CommandAllocator`](/documentation/Metal/MTL4CommandAllocator) and declares that the
application is ready to encode commands into the command buffer.

Command allocators only service a single command buffer at a time. If you need to issue multiple
calls to this method simultaneously, for example, in a multi-threaded command encoding scenario,
create multiple instances of `MTLCommandAllocator` and use one for each call.

You can safely reuse command allocators after ending the command buffer using it by calling
[`endCommandBuffer()`](/documentation/Metal/MTL4CommandBuffer/endCommandBuffer()).

After calling this method, any prior calls to [`useResidencySet(_:)`](/documentation/Metal/MTL4CommandBuffer/useResidencySet(_:)) and [`useResidencySets:count:`](/documentation/Metal/MTL4CommandBuffer/useResidencySets:count:)
on this command buffer instance no longer apply. Make sure to call these methods again to signal
your residency requirements to Metal.

The options you provide configure the command buffer only until the command buffer ends, in the
next call to [`endCommandBuffer()`](/documentation/Metal/MTL4CommandBuffer/endCommandBuffer()).

---

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)