<!--
{
  "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/primarySourceRegion(forDestinationSize:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSBinaryImageKernel(im)primarySourceRegionForDestinationSize:"
  },
  "title" : "primarySourceRegion(forDestinationSize:)"
}
-->

# primarySourceRegion(forDestinationSize:)

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

```
func primarySourceRegion(forDestinationSize destinationSize: MTLSize) -> MPSRegion
```

## Parameters

`destinationSize`

The size of the full virtual destination image.

## Return Value

The area in the virtual source image that will be read.

## Discussion

This method is used to determine which region of the primary source texture will be read by the [`encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:)`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:)) method when the filter runs. This information may be needed if the primary source image is broken into multiple textures. The size of the full (untiled) destination image is provided. The region of the full (untiled) source image that will be read is returned. You can then piece together an appropriate texture containing that information for use in your tiled context.

This method will consult the [`primaryOffset`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/primaryOffset) and [`clipRect`](/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/clipRect) properties to determine the full region read by the function. Other properties, such as kernel height and width, will be consulted as necessary. All properties should be set to their intended values prior to calling this method.

> Important:
> This function operates using global image coordinates, but the ``doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:)`` method uses coordinates local to the source and destination image textures. Consequently, the ``doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/primaryOffset`` and ``doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/clipRect`` properties attached to this object will need to be updated using a global-to-local coordinate transform before the ``doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSBinaryImageKernel/encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:)`` method is called.

---

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)