---
title: "encode(commandBuffer:primaryImage:secondaryImage:destinationState:destinationImage:)"
framework: metalperformanceshaders
role: symbol
role_heading: Instance Method
path: "metalperformanceshaders/mpscnnarithmetic/encode(commandbuffer:primaryimage:secondaryimage:destinationstate:destinationimage:)"
---

# encode(commandBuffer:primaryImage:secondaryImage:destinationState:destinationImage:)

## Declaration

```swift
func encode(commandBuffer: any MTLCommandBuffer, primaryImage: MPSImage, secondaryImage: MPSImage, destinationState: MPSCNNArithmeticGradientState, destinationImage: MPSImage)
```
