<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSBinaryImageKernel",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSBinaryImageKernel"
  },
  "title" : "MPSBinaryImageKernel"
}
-->

# MPSBinaryImageKernel

A kernel that consumes two textures and produces one texture.

```
class MPSBinaryImageKernel
```

## Overview

[`MPSBinaryImageKernel`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel) defines shared behavior for most image processing kernels (filters) such as edging modes, clipping, and tiling support for image operations that consume two source textures. It is not meant to be used directly, but provides API abstraction and in some cases may allow some level of polymorphic manipulation of image kernel objects.

## Topics

### Initializers

[`-  initWithCoder:device:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/init(coder:device:))

[`-  initWithDevice:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/init(device:))

### Methods

[`-  encodeToCommandBuffer:primaryTexture:inPlaceSecondaryTexture:fallbackCopyAllocator:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:primaryTexture:inPlaceSecondaryTexture:fallbackCopyAllocator:))

This method attempts to apply a kernel in place on a texture.

[`-  encodeToCommandBuffer:inPlacePrimaryTexture:secondaryTexture:fallbackCopyAllocator:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:inPlacePrimaryTexture:secondaryTexture:fallbackCopyAllocator:))

This method attempts to apply a kernel in place on a texture.

[`-  encodeToCommandBuffer:primaryTexture:secondaryTexture:destinationTexture:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:))

Encodes a kernel into a command buffer, out-of-place.

[`-  encodeToCommandBuffer:primaryImage:secondaryImage:destinationImage:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:primaryImage:secondaryImage:destinationImage:))

[`-  primarySourceRegionForDestinationSize:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/primarySourceRegion(forDestinationSize:))

Determines the region of the primary source texture that will be read for an encode operation.

[`-  secondarySourceRegionForDestinationSize:`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/secondarySourceRegion(forDestinationSize:))

Determines the region of the secondary source texture that will be read for an encode operation.

### Properties

[`primaryOffset`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/primaryOffset)

The position of the destination clip rectangle origin relative to the primary source buffer.

[`secondaryOffset`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/secondaryOffset)

The position of the destination clip rectangle origin relative to the secondary source buffer.

[`primaryEdgeMode`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/primaryEdgeMode)

The edge mode to use when texture reads stray off the edge of the primary source image.

[`secondaryEdgeMode`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/secondaryEdgeMode)

The edge mode to use when texture reads stray off the edge of the secondary source image.

[`clipRect`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/clipRect)

An optional clip rectangle to use when writing data. Only the pixels in the rectangle will be overwritten.

## Relationships

### Inherits From

[`MPSKernel`](/documentation/MetalPerformanceShaders/MPSKernel)

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

### Inherited By

[`MPSImageArithmetic`](/documentation/MetalPerformanceShaders/MPSImageArithmetic)

---

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)