manpagez: man pages & more
man MPSBinaryImageKernel(3)
Home | html | info | man
MPSBinaryImageKernel(3)




NAME

       MPSBinaryImageKernel


SYNOPSIS

       #import <MPSImageKernel.h>

       Inherits MPSKernel.

       Inherited by MPSImageArithmetic.

   Instance Methods
       (nonnull instancetype) - initWithDevice:
       (nullable instancetype) - initWithCoder:device:
       (BOOL) -
           encodeToCommandBuffer:primaryTexture:inPlaceSecondaryTexture:fallbackCopyAllocator:
       (BOOL) -
           encodeToCommandBuffer:inPlacePrimaryTexture:secondaryTexture:fallbackCopyAllocator:
       (void) -
           encodeToCommandBuffer:primaryTexture:secondaryTexture:destinationTexture:
       (void) -
           encodeToCommandBuffer:primaryImage:secondaryImage:destinationImage:
       (MPSRegion) - primarySourceRegionForDestinationSize:
       (MPSRegion) - secondarySourceRegionForDestinationSize:

   Properties
       MPSOffset primaryOffset
       MPSOffset secondaryOffset
       MPSImageEdgeMode primaryEdgeMode
       MPSImageEdgeMode secondaryEdgeMode
       MTLRegion clipRect

   Additional Inherited Members

Detailed Description

       This depends on Metal.framework  A MPSBinaryImageKernel consumes two
       MTLTextures and produces one MTLTexture.


Method Documentation

   - (BOOL) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >)
       commandBuffer(__nonnull id< MTLTexture > __strong *__nonnull)
       inPlacePrimaryTexture(nonnull id< MTLTexture >)
       secondaryTexture(nullable MPSCopyAllocator) copyAllocator
       Attempt to apply a MPSKernel to a texture in place.  This method
       attempts to apply the MPSKernel in place on a texture.

       In-place operation means that the same texture is used both to hold the input
       image and the results. Operating in-place can be an excellent way to reduce
       resource utilization, and save time and energy. While simple Metal kernels can
       not operate in place because textures can not be readable and writable at the
       same time, some MPSKernels can operate in place because they use
       multi-pass algorithms. Whether a MPSKernel can operate in-place can
       depend on current hardware, operating system revision and the parameters
       and properties passed to it. You should never assume that a MPSKernel will
       continue to work in place, even if you have observed it doing so before.


        If the operation succeeds in-place, YES is returned. If the in-place
       operation fails and no copyAllocator is provided, then NO is returned.
       In neither case is the pointer held at *texture modified.

       Failure during in-place operation is common. You may find it simplifies
       your code to provide a copyAllocator. When an in-place filter fails,
       your copyAllocator will be invoked to create a new texture in which to
       write the results, allowing the filter to proceed reliably out-of-
       place. The original texture will be released, replaced with a pointer
       to the new texture and YES will be returned. If the allocator returns
       an invalid texture, it is released, *texture remains unmodified and NO
       is returned. Please see the MPSCopyAllocator definition for a sample
       allocator implementation.

       Note: Image filters that look at neighboring pixel values may actually
       consume more memory when operating in place than out of place. Many
       such operations are tiled internally to save intermediate texture
       storage, but can not tile when operating in place. The memory savings
       for tiling is however very short term, typically the lifetime of the
       MTLCommandBuffer.

       Parameters:
           commandBuffer A valid MTLCommandBuffer to receive the encoded
           filter
           inPlacePrimaryTexture A pointer to a valid MTLTexture containing
           secondary image. On success, the image contents and possibly
           texture itself will be replaced with the result image.
           secondaryTexture A pointer to a valid MTLTexture containing the
           primary source image. It will not be overwritten.
           copyAllocator An optional block to allocate a new texture to hold
           the results, in case in-place operation is not possible. The
           allocator may use a different MTLPixelFormat or size than the
           original texture. You may enqueue operations on the provided
           MTLCommandBuffer using the provided MTLComputeCommandEncoder to
           initialize the texture contents.

       Returns:
           On success, YES is returned. The texture may have been replaced
           with a new texture if a copyAllocator was provided. On failure, NO
           is returned. The texture is unmodified.



   - (void) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >)
       commandBuffer(MPSImage *__nonnull) primaryImage(MPSImage *__nonnull)
       secondaryImage(MPSImage *__nonnull) destinationImage
       Encode a MPSKernel into a command Buffer. The operation shall proceed
       out-of-place.

       Parameters:
           commandBuffer A valid MTLCommandBuffer to receive the encoded
           filter
           primaryImage A valid MPSImage containing the primary source image.
           secondaryImage A valid MPSImage containing the secondary source
           image.
           destinationImage A valid MPSImage to be overwritten by result
           image. destinationImage may not alias the source images.



   - (BOOL) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >)
       commandBuffer(nonnull id< MTLTexture >) primaryTexture(__nonnull id<
       MTLTexture > __strong *__nonnull) inPlaceSecondaryTexture(nullable
       MPSCopyAllocator) copyAllocator
       This method attempts to apply the MPSKernel in place on a texture.

           In-place operation means that the same texture is used both to hold the input
           image and the results. Operating in-place can be an excellent way to reduce
           resource utilization, and save time and energy. While simple Metal kernels can
           not operate in place because textures can not be readable and writable at the
           same time, some MPSKernels can operate in place because they use
           multi-pass algorithms. Whether a MPSKernel can operate in-place can
           depend on current hardware, operating system revision and the parameters
           and properties passed to it. You should never assume that a MPSKernel will
           continue to work in place, even if you have observed it doing so before.



       If the operation succeeds in-place, YES is returned. If the in-place
       operation fails and no copyAllocator is provided, then NO is returned.
       In neither case is the pointer held at *texture modified.

       Failure during in-place operation is common. You may find it simplifies
       your code to provide a copyAllocator. When an in-place filter fails,
       your copyAllocator will be invoked to create a new texture in which to
       write the results, allowing the filter to proceed reliably out-of-
       place. The original texture will be released, replaced with a pointer
       to the new texture and YES will be returned. If the allocator returns
       an invalid texture, it is released, *texture remains unmodified and NO
       is returned. Please see the MPSCopyAllocator definition for a sample
       allocator implementation.

       Note: Image filters that look at neighboring pixel values may actually
       consume more memory when operating in place than out of place. Many
       such operations are tiled internally to save intermediate texture
       storage, but can not tile when operating in place. The memory savings
       for tiling is however very short term, typically the lifetime of the
       MTLCommandBuffer.

       Attempt to apply a MPSKernel to a texture in place.

       Parameters:
           commandBuffer A valid MTLCommandBuffer to receive the encoded
           filter
           primaryTexture A pointer to a valid MTLTexture containing the
           primary source image. It will not be overwritten.
           inPlaceSecondaryTexture A pointer to a valid MTLTexture containing
           secondary image. On success, the image contents and possibly
           texture itself will be replaced with the result image.
           copyAllocator An optional block to allocate a new texture to hold
           the results, in case in-place operation is not possible. The
           allocator may use a different MTLPixelFormat or size than the
           original texture. You may enqueue operations on the provided
           MTLCommandBuffer using the provided MTLComputeCommandEncoder to
           initialize the texture contents.

       Returns:
           On success, YES is returned. The texture may have been replaced
           with a new texture if a copyAllocator was provided. On failure, NO
           is returned. The texture is unmodified.



   - (void) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >)
       commandBuffer(nonnull id< MTLTexture >) primaryTexture(nonnull id<
       MTLTexture >) secondaryTexture(nonnull id< MTLTexture >)
       destinationTexture
       Encode a MPSKernel into a command Buffer. The operation shall proceed
       out-of-place.

       Parameters:
           commandBuffer A valid MTLCommandBuffer to receive the encoded
           filter
           primaryTexture A valid MTLTexture containing the primary source
           image.
           secondaryTexture A valid MTLTexture containing the secondary source
           image.
           destinationTexture A valid MTLTexture to be overwritten by result
           image. destinationTexture may not alias the source textures.



   - (nullable instancetype) initWithCoder: (NSCoder *__nonnull)
       aDecoder(nonnull id< MTLDevice >) device
       NSSecureCoding compatability  While the standard
       NSSecureCoding/NSCoding method -initWithCoder: should work, since the
       file can't know which device your data is allocated on, we have to
       guess and may guess incorrectly. To avoid that problem, use
       initWithCoder:device instead.

       Parameters:
           aDecoder The NSCoder subclass with your serialized MPSKernel
           device The MTLDevice on which to make the MPSKernel

       Returns:
           A new MPSKernel object, or nil if failure.



       Reimplemented from MPSKernel.

   - (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device
       Standard init with default properties per filter type

       Parameters:
           device The device that the filter will be used on. May not be NULL.

       Returns:
           a pointer to the newly initialized object. This will fail,
           returning nil if the device is not supported. Devices must be
           MTLFeatureSet_iOS_GPUFamily2_v1 or later.



       Reimplemented from MPSKernel.

       Reimplemented in MPSImageArithmetic, MPSImageAdd, MPSImageSubtract,
       MPSImageMultiply, and MPSImageDivide.

   - (MPSRegion) primarySourceRegionForDestinationSize: (MTLSize)
       destinationSize
       primarySourceRegionForDestinationSize: is used to determine which
       region of the primaryTexture will be read by
       encodeToCommandBuffer:primaryTexture:secondaryTexture:destinationTexture
       (and in-place variants) 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.

       The function will consult the MPSBinaryImageKernel primaryOffset and
       clipRect parameters, to determine the full region read by the function.
       Other parameters such as kernelHeight and kernelWidth will be consulted
       as necessary. All properties should be set to intended values prior to
       calling primarySourceRegionForDestinationSize:.

       Caution: This function operates using global image coordinates, but
       -encodeToCommandBuffer:... uses coordinates local to the source and
       destination image textures. Consequently, the primaryOffset and clipRect
       attached to this object will need to be updated using a global to
       local coordinate transform before -encodeToCommandBuffer:... is
       called.



       Determine the region of the source texture that will be read for a
       encode operation

       Parameters:
           destinationSize The size of the full virtual destination image.

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



   - (MPSRegion) secondarySourceRegionForDestinationSize: (MTLSize)
       destinationSize
       secondarySourceRegionForDestinationSize: is used to determine which
       region of the sourceTexture will be read by
       encodeToCommandBuffer:primaryTexture:secondaryTexture:destinationTexture
       (and in-place variants) 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) secondary 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.

       The function will consult the MPSBinaryImageKernel secondaryOffset and
       clipRect parameters, to determine the full region read by the function.
       Other parameters such as kernelHeight and kernelWidth will be consulted
       as necessary. All properties should be set to intended values prior to
       calling secondarySourceRegionForDestinationSize:.

       Caution: This function operates using global image coordinates, but
       -encodeToCommandBuffer:... uses coordinates local to the source and
       destination image textures. Consequently, the secondaryOffset and clipRect
       attached to this object will need to be updated using a global to
       local coordinate transform before -encodeToCommandBuffer:... is
       called.



       Determine the region of the source texture that will be read for a
       encode operation

       Parameters:
           destinationSize The size of the full virtual destination image.

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




Property Documentation

   - clipRect [read],  [write],  [nonatomic],  [assign]
       An optional clip rectangle to use when writing data. Only the pixels in
       the rectangle will be overwritten.  A MTLRegion that indicates which
       part of the destination to overwrite. If the clipRect does not lie
       completely within the destination image, the intersection between clip
       rectangle and destination bounds is used. Default: MPSRectNoClip
       (MPSKernel::MPSRectNoClip) indicating the entire image.

       See Also: MetalPerformanceShaders.h subsubsection_clipRect

   - primaryEdgeMode [read],  [write],  [nonatomic],  [assign]
       The MPSImageEdgeMode to use when texture reads stray off the edge of
       the primary source image  Most MPSKernel objects can read off the edge
       of a source image. This can happen because of a negative offset
       property, because the offset + clipRect.size is larger than the source
       image or because the filter looks at neighboring pixels, such as a
       Convolution or morphology filter. Default: usually
       MPSImageEdgeModeZero. (Some MPSKernel types default to
       MPSImageEdgeModeClamp, because MPSImageEdgeModeZero is either not
       supported or would produce unexpected results.)

       See Also: MetalPerformanceShaders.h subsubsection_edgemode

   - primaryOffset [read],  [write],  [nonatomic],  [assign]
       The position of the destination clip rectangle origin relative to the
       primary source buffer.  The offset is defined to be the position of
       clipRect.origin in source coordinates. Default: {0,0,0}, indicating
       that the top left corners of the clipRect and primary source image
       align.

       See Also: MetalPerformanceShaders.h subsubsection_mpsoffset

   - secondaryEdgeMode [read],  [write],  [nonatomic],  [assign]
       The MPSImageEdgeMode to use when texture reads stray off the edge of
       the secondary source image  Most MPSKernel objects can read off the
       edge of a source image. This can happen because of a negative offset
       property, because the offset + clipRect.size is larger than the source
       image or because the filter looks at neighboring pixels, such as a
       Convolution or morphology filter. Default: usually
       MPSImageEdgeModeZero. (Some MPSKernel types default to
       MPSImageEdgeModeClamp, because MPSImageEdgeModeZero is either not
       supported or would produce unexpected results.)

       See Also: MetalPerformanceShaders.h subsubsection_edgemode

   - secondaryOffset [read],  [write],  [nonatomic],  [assign]
       The position of the destination clip rectangle origin relative to the
       secondary source buffer.  The offset is defined to be the position of
       clipRect.origin in source coordinates. Default: {0,0,0}, indicating
       that the top left corners of the clipRect and secondary source image
       align.

       See Also: MetalPerformanceShaders.h subsubsection_mpsoffset



Author

       Generated automatically by Doxygen for
       MetalPerformanceShaders.framework from the source code.





Version MetalPerformanceShaders-Thu2Jul 13 2017        MPSBinaryImageKernel(3)


Mac OS X 10.13.1 - Generated Mon Nov 6 16:22:56 CST 2017
© manpagez.com 2000-2025
Individual documents may contain additional copyright information.