---
title: "secondarySourceRegion(forDestinationSize:)"
framework: metalperformanceshaders
role: symbol
role_heading: Instance Method
path: "metalperformanceshaders/mpsbinaryimagekernel/secondarysourceregion(fordestinationsize:)"
---

# secondarySourceRegion(forDestinationSize:)

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

## Declaration

```swift
func secondarySourceRegion(forDestinationSize destinationSize: MTLSize) -> MPSRegion
```

## Parameters

- `destinationSize`: The size of the full virtual destination image.

## Return Value

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

## Discussion

Discussion This method is used to determine which region of the secondary source texture will be read by the encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:) method when the filter runs. This information may be needed if the secondary 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 secondaryOffset and 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 encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:) method uses coordinates local to the source and destination image textures. Consequently, the secondaryOffset and clipRect properties attached to this object will need to be updated using a global-to-local coordinate transform before the encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:) method is called.

## See Also

### Methods

- [encode(commandBuffer:primaryTexture:inPlaceSecondaryTexture:fallbackCopyAllocator:)](metalperformanceshaders/mpsbinaryimagekernel/encode(commandbuffer:primarytexture:inplacesecondarytexture:fallbackcopyallocator:).md)
- [encode(commandBuffer:inPlacePrimaryTexture:secondaryTexture:fallbackCopyAllocator:)](metalperformanceshaders/mpsbinaryimagekernel/encode(commandbuffer:inplaceprimarytexture:secondarytexture:fallbackcopyallocator:).md)
- [encode(commandBuffer:primaryTexture:secondaryTexture:destinationTexture:)](metalperformanceshaders/mpsbinaryimagekernel/encode(commandbuffer:primarytexture:secondarytexture:destinationtexture:).md)
- [encode(commandBuffer:primaryImage:secondaryImage:destinationImage:)](metalperformanceshaders/mpsbinaryimagekernel/encode(commandbuffer:primaryimage:secondaryimage:destinationimage:).md)
- [primarySourceRegion(forDestinationSize:)](metalperformanceshaders/mpsbinaryimagekernel/primarysourceregion(fordestinationsize:).md)
