Core Concepts of MetalPetal
masterMetalPetal is built around four primary abstractions that work together to perform image processing:
MTIContext: The evaluation context used for renderingMTIImages. It manages caches and state information. For optimal performance, you should reuse a singleMTIContextinstance whenever possible rather than creating new ones for every operation.MTIImage: A representation of an image (or a recipe to produce one). It does not hold raw bitmap data directly; instead, it contains anMTIImagePromise(the recipe) and metadata likecachePolicyandsamplerDescriptor. It is immutable and thread-safe.MTIFilter: Represents an image processing effect with controllable parameters. A filter takes inputMTIImages and produces an outputMTIImage. Note thatMTIFilterobjects are mutable and are not thread-safe.MTIKernel: The underlying image processing routine. It is responsible for creating the Metal pipeline states (render or compute) and building theMTIImagePromisefor the resultingMTIImage.