Passing MTLTexture to Metal Core Image Kernel

Is it possible to pass MTLTexture to Metal Core Image Kernel? How can Metal resources be shared with Core Image?

Answered by FrankSchlegel in 700167022

You can simply initialize a CIImage with the texture and pass that to the kernel:

let ciImage = CIImage(mtlTexture: texture)

The documentation also mentions what you need to do to let Core Image render into a Metal texture.

If you want to incorporate a Metal processing step into a Core Image pipeline instead, I recommend you check out CIImageProcessorKernel.

Accepted Answer

You can simply initialize a CIImage with the texture and pass that to the kernel:

let ciImage = CIImage(mtlTexture: texture)

The documentation also mentions what you need to do to let Core Image render into a Metal texture.

If you want to incorporate a Metal processing step into a Core Image pipeline instead, I recommend you check out CIImageProcessorKernel.

Passing MTLTexture to Metal Core Image Kernel
 
 
Q