<!--
{
  "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/MTL4RenderCommandEncoder/drawMeshThreadgroups(indirectBuffer:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTL4RenderCommandEncoder(im)drawMeshThreadgroupsWithIndirectBuffer:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"
  },
  "title" : "drawMeshThreadgroups(indirectBuffer:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:)"
}
-->

# drawMeshThreadgroups(indirectBuffer:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:)

Encodes a draw command that invokes a mesh shader and, optionally, an object shader with indirect arguments.

```
func drawMeshThreadgroups(indirectBuffer: MTLGPUAddress, threadsPerObjectThreadgroup: MTLSize, threadsPerMeshThreadgroup: MTLSize)
```

## Parameters

`indirectBuffer`

GPUAddress of an [`MTLBuffer`](/documentation/Metal/MTLBuffer) instance with data that matches the layout of the
[`MTLDispatchThreadgroupsIndirectArguments`](/documentation/Metal/MTLDispatchThreadgroupsIndirectArguments) structure. This address requires 4-byte alignment.

`threadsPerObjectThreadgroup`

A [`MTLSize`](/documentation/Metal/MTLSize) instance that represents the number of threads in an object
shader threadgroup, if applicable.

`threadsPerMeshThreadgroup`

A [`MTLSize`](/documentation/Metal/MTLSize) instance that represents the number of threads in a mesh shader
threadgroup.

## Discussion

This method enables you to determine the number of threadgroups per grid indirectly, in the GPU timeline.
Metal expects this buffer’s contents to match the layout of structure [`MTLDispatchThreadgroupsIndirectArguments`](/documentation/Metal/MTLDispatchThreadgroupsIndirectArguments).
You are responsible for ensuring the address of this buffer has 4-byte alignment.

Use an instance of [`MTLResidencySet`](/documentation/Metal/MTLResidencySet) to mark residency of the indirect buffer that the `indirectBuffer` parameter
references.

---

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)