---
title: "drawMeshThreadgroups(indirectBuffer:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4rendercommandencoder/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.

## Declaration

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

## Parameters

- `indirectBuffer`: GPUAddress of an doc://com.apple.metal/documentation/Metal/MTLBuffer instance with data that matches the layout of the doc://com.apple.metal/documentation/Metal/MTLDispatchThreadgroupsIndirectArguments structure. This address requires 4-byte alignment.
- `threadsPerObjectThreadgroup`: A doc://com.apple.metal/documentation/Metal/MTLSize instance that represents the number of threads in an object shader threadgroup, if applicable.
- `threadsPerMeshThreadgroup`: A doc://com.apple.metal/documentation/Metal/MTLSize instance that represents the number of threads in a mesh shader threadgroup.

## Discussion

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. You are responsible for ensuring the address of this buffer has 4-byte alignment. Use an instance of MTLResidencySet to mark residency of the indirect buffer that the indirectBuffer parameter references.

## See Also

### Drawing with meshes

- [drawMeshThreads(threadsPerGrid:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:)](metal/mtl4rendercommandencoder/drawmeshthreads(threadspergrid:threadsperobjectthreadgroup:threadspermeshthreadgroup:).md)
- [drawMeshThreadgroups(threadgroupsPerGrid:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:)](metal/mtl4rendercommandencoder/drawmeshthreadgroups(threadgroupspergrid:threadsperobjectthreadgroup:threadspermeshthreadgroup:).md)
