Instance Method

encodeTransform(to:sourceTexture:histogram:histogramOffset:)

Encodes the transform function to a command buffer using a compute command encoder. The transform function computes the equalization lookup table.

Declaration

func encodeTransform(to commandBuffer: MTLCommandBuffer, sourceTexture source: MTLTexture, histogram: MTLBuffer, histogramOffset: Int)

Parameters

commandBuffer

A valid command buffer.

source

A valid texture containing the source image for the filter.

histogram

A valid buffer containing the histogram results for an image. This filter will use these histogram results to generate the cumulative histogram for equalizing the image. The histogram results per channel are stored together. The number of channels for which histogram results are stored is determined by the number of channels in the image. If the histogramForAlpha value of the histogramInfo property is false and the source image is RGBA, then only histogram results for RGB channels are stored.

histogramOffset

The byte offset into the histogram buffer where the histogram starts. Must conform to alignment requirements for the offset parameter of the setBuffer(_:offset:index:) method.

Discussion

The transform function will not begin to execute until after the command buffer has been enqueued and committed. This step will need to be repeated with the new MPSKernel object if the copy(with:device:) or copy(with:) method is called. The transform is stored as internal state to the object. You still need to call the encode(commandBuffer:sourceTexture:destinationTexture:) afterward to apply the transform to produce a result texture.

See Also

Methods