<!--
{
  "availability" : [
    "iOS: 11.3.0 -",
    "iPadOS: 11.3.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.4 -",
    "tvOS: 11.3.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSCNNKernel/encode(commandBuffer:sourceImage:destinationState:destinationImage:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSCNNKernel(im)encodeToCommandBuffer:sourceImage:destinationState:destinationImage:"
  },
  "title" : "encode(commandBuffer:sourceImage:destinationState:destinationImage:)"
}
-->

# encode(commandBuffer:sourceImage:destinationState:destinationImage:)

```
func encode(commandBuffer: any MTLCommandBuffer, sourceImage: MPSImage, destinationState: MPSState, destinationImage: MPSImage)
```

---

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)