Instance Method

render(_:to:commandBuffer:bounds:colorSpace:)

Renders a region of an image to a Metal texture.

Declaration

func render(_ image: CIImage, to texture: MTLTexture, commandBuffer: MTLCommandBuffer?, bounds: CGRect, colorSpace: CGColorSpace)

Parameters

image

A Core Image image object.

texture

The destination Metal texture object.

commandBuffer

The Metal command buffer into which to schedule Core Image rendering tasks.

bounds

The rectangle in the destination texture to draw into.

colorSpace

The color space of the destination texture.

Discussion

If you specify nil for the commandBuffer parameter, Core Image manages its own Metal command buffer. To combine Core Image rendering with other Metal rendering tasks—for example, to use Core Image filters on textures whose content is generated by a Metal render-to-texture operation, or to use Core Image output later in the same Metal rendering pass—pass the same MTLCommandBuffer object you use for those tasks.

Rendering to a Metal texture requires a Metal-based context created with the init(mtlDevice:) or init(mtlDevice:options:) method. Calling this method on any other context raises an exception. This method renders only to Metal textures whose texture type is MTLTextureType.type2D and whose sampleCount value is 1.

See Also

Rendering Images

func createCGImage(CIImage, from: CGRect) -> CGImage?

Creates a Quartz 2D image from a region of a Core Image image object.

func createCGImage(CIImage, from: CGRect, format: CIFormat, colorSpace: CGColorSpace?) -> CGImage?

Creates a Quartz 2D image from a region of a Core Image image object.

func createCGImage(CIImage, from: CGRect, format: CIFormat, colorSpace: CGColorSpace?, deferred: Bool) -> CGImage?

Creates a Quartz 2D image from a region of a Core Image image object with deferred rendering.

func createCGLayer(with: CGSize, info: CFDictionary?) -> CGLayer?

Creates a CGLayer object from the provided parameters.

Deprecated
func render(CIImage, to: CVPixelBuffer)

Renders an image into a pixel buffer.

func render(CIImage, to: IOSurfaceRef, bounds: CGRect, colorSpace: CGColorSpace?)

Renders a region of an image into an IOSurface object.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software