<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLCommandQueue/makeCommandBuffer()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLCommandQueue(im)commandBuffer"
  },
  "title" : "makeCommandBuffer()"
}
-->

# makeCommandBuffer()

Returns a command buffer from the command queue that maintains strong references to resources.

```
func makeCommandBuffer() -> (any MTLCommandBuffer)?
```

## Discussion

The command buffers you create with this method maintain strong references to the resources you encode into it, including buffers, textures, samplers, and pipeline states. The command buffer releases these references after it finishes running on the GPU.

This method sets the [`retainedReferences`](/documentation/Metal/MTLCommandBuffer/retainedReferences) property to <doc://com.apple.documentation/documentation/Swift/true> for the command buffer it creates.

Each command queue has a fixed number of command buffers for its lifetime (see [`makeCommandQueue(maxCommandBufferCount:)`](/documentation/Metal/MTLDevice/makeCommandQueue(maxCommandBufferCount:))). This method blocks the calling CPU thread when the queue doesn’t have any free command buffers, and returns after the GPU finishes executing one.

---

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)