---
title: "dispatchThreadsPerTile(_:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/dispatchthreadspertile(_:)"
---

# dispatchThreadsPerTile(_:)

Encodes a command that invokes GPU functions from the encoder’s current tile render pipeline state.

## Declaration

```swift
func dispatchThreadsPerTile(_ threadsPerTile: MTLSize)
```

## Parameters

- `threadsPerTile`: An doc://com.apple.metal/documentation/Metal/MTLSize instance that represents the number of threads the render pass uses per tile. Set the size’s doc://com.apple.metal/documentation/Metal/MTLSize/width and doc://com.apple.metal/documentation/Metal/MTLSize/height properties to values that are less than or equal to doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/tileWidth and doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/tileHeight, respectively. Some GPU families only support square tile dispatches and require the same value for doc://com.apple.metal/documentation/Metal/MTLSize/width and doc://com.apple.metal/documentation/Metal/MTLSize/height. See the https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf to check which GPU families support nonsquare dispatches. Set the doc://com.apple.metal/documentation/Metal/MTLSize/depth property to 1.

## Discussion

Discussion The command invokes the GPU function that’s in the encoder’s current tile render pipeline state. You can configure that state with the following steps: Configure an MTLTileRenderPipelineDescriptor instance. Create a tile render pipeline state by calling one of the applicable methods of an MTLDevice instance, including makeRenderPipelineState(tileDescriptor:options:reflection:). Apply that tile render pipeline state by calling the setRenderPipelineState(_:) method. The method records the encoder’s current rendering state and resources the command needs as it runs. You can safely change the encoder’s render pipeline state to encode other commands after calling this method. Subsequent changes to the state don’t affect the commands already in the encoder’s MTLCommandBuffer.

## See Also

### Drawing with tile shaders

- [tileWidth](metal/mtlrendercommandencoder/tilewidth.md)
- [tileHeight](metal/mtlrendercommandencoder/tileheight.md)
