5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_FORMATS_MTL_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_FORMATS_MTL_H_
8#include <Metal/Metal.h>
24 case MTLPixelFormatInvalid:
26 case MTLPixelFormatBGRA8Unorm:
28 case MTLPixelFormatBGRA8Unorm_sRGB:
30 case MTLPixelFormatRGBA8Unorm:
32 case MTLPixelFormatRGBA8Unorm_sRGB:
34 case MTLPixelFormatRGBA32Float:
36 case MTLPixelFormatRGBA16Float:
38 case MTLPixelFormatStencil8:
41 case MTLPixelFormatDepth24Unorm_Stencil8:
44 case MTLPixelFormatDepth32Float_Stencil8:
46 case MTLPixelFormatBGR10_XR_sRGB:
48 case MTLPixelFormatBGR10_XR:
50 case MTLPixelFormatBGRA10_XR:
79 return MTLPixelFormatInvalid;
81 return MTLPixelFormatA8Unorm;
83 return MTLPixelFormatR8Unorm;
85 return MTLPixelFormatRG8Unorm;
87 return MTLPixelFormatBGRA8Unorm;
89 return MTLPixelFormatBGRA8Unorm_sRGB;
91 return MTLPixelFormatRGBA8Unorm;
93 return MTLPixelFormatRGBA8Unorm_sRGB;
95 return MTLPixelFormatRGBA32Float;
97 return MTLPixelFormatRGBA16Float;
99 return MTLPixelFormatStencil8;
103 return MTLPixelFormatDepth32Float_Stencil8;
111 return MTLPixelFormatR32Float;
113 return MTLPixelFormatInvalid;
119 return MTLBlendFactorZero;
121 return MTLBlendFactorOne;
123 return MTLBlendFactorSourceColor;
125 return MTLBlendFactorOneMinusSourceColor;
127 return MTLBlendFactorSourceAlpha;
129 return MTLBlendFactorOneMinusSourceAlpha;
131 return MTLBlendFactorDestinationColor;
133 return MTLBlendFactorOneMinusDestinationColor;
135 return MTLBlendFactorDestinationAlpha;
137 return MTLBlendFactorOneMinusDestinationAlpha;
139 return MTLBlendFactorSourceAlphaSaturated;
141 return MTLBlendFactorBlendColor;
143 return MTLBlendFactorOneMinusBlendColor;
145 return MTLBlendFactorBlendAlpha;
147 return MTLBlendFactorOneMinusBlendAlpha;
149 return MTLBlendFactorZero;
155 return MTLPrimitiveTypeTriangle;
157 return MTLPrimitiveTypeTriangleStrip;
159 return MTLPrimitiveTypeLine;
161 return MTLPrimitiveTypeLineStrip;
163 return MTLPrimitiveTypePoint;
167 return MTLPrimitiveTypePoint;
169 return MTLPrimitiveTypePoint;
175 return MTLTriangleFillModeFill;
177 return MTLTriangleFillModeLines;
179 return MTLTriangleFillModeFill;
185 return MTLIndexTypeUInt16;
187 return MTLIndexTypeUInt32;
194 return MTLCullModeNone;
196 return MTLCullModeBack;
198 return MTLCullModeFront;
200 return MTLCullModeNone;
206 return MTLBlendOperationAdd;
208 return MTLBlendOperationSubtract;
210 return MTLBlendOperationReverseSubtract;
212 return MTLBlendOperationAdd;
216 MTLColorWriteMask mask = MTLColorWriteMaskNone;
219 mask |= MTLColorWriteMaskRed;
223 mask |= MTLColorWriteMaskGreen;
227 mask |= MTLColorWriteMaskBlue;
231 mask |= MTLColorWriteMaskAlpha;
240 return MTLCompareFunctionNever;
242 return MTLCompareFunctionLess;
244 return MTLCompareFunctionEqual;
246 return MTLCompareFunctionLessEqual;
248 return MTLCompareFunctionGreater;
250 return MTLCompareFunctionNotEqual;
252 return MTLCompareFunctionGreaterEqual;
254 return MTLCompareFunctionAlways;
256 return MTLCompareFunctionAlways;
262 return MTLStencilOperationKeep;
264 return MTLStencilOperationZero;
266 return MTLStencilOperationReplace;
268 return MTLStencilOperationIncrementClamp;
270 return MTLStencilOperationDecrementClamp;
272 return MTLStencilOperationInvert;
274 return MTLStencilOperationIncrementWrap;
276 return MTLStencilOperationDecrementWrap;
278 return MTLStencilOperationKeep;
284 return MTLLoadActionDontCare;
286 return MTLLoadActionLoad;
288 return MTLLoadActionClear;
291 return MTLLoadActionDontCare;
296 case MTLLoadActionDontCare:
298 case MTLLoadActionLoad:
300 case MTLLoadActionClear:
312 return MTLStoreActionDontCare;
314 return MTLStoreActionStore;
316 return MTLStoreActionMultisampleResolve;
318 return MTLStoreActionStoreAndMultisampleResolve;
320 return MTLStoreActionDontCare;
325 case MTLStoreActionDontCare:
327 case MTLStoreActionStore:
329 case MTLStoreActionMultisampleResolve:
331 case MTLStoreActionStoreAndMultisampleResolve:
342 return MTLSamplerMinMagFilterNearest;
344 return MTLSamplerMinMagFilterLinear;
346 return MTLSamplerMinMagFilterNearest;
352 return MTLSamplerMipFilterNotMipmapped;
354 return MTLSamplerMipFilterNearest;
356 return MTLSamplerMipFilterLinear;
358 return MTLSamplerMipFilterNotMipmapped;
365 return MTLSamplerAddressModeClampToEdge;
367 return MTLSamplerAddressModeRepeat;
369 return MTLSamplerAddressModeMirrorRepeat;
371 return MTLSamplerAddressModeClampToZero;
373 return MTLSamplerAddressModeClampToEdge;
383 return MTLTextureType2D;
385 return MTLTextureType2DMultisample;
387 return MTLTextureTypeCube;
390 <<
"kTextureExternalOES can not be used with the Metal backend.";
392 return MTLTextureType2D;
395MTLRenderPipelineColorAttachmentDescriptor*
397 ColorAttachmentDescriptor descriptor);
400 std::optional<DepthAttachmentDescriptor> depth,
401 std::optional<StencilAttachmentDescriptor> front,
402 std::optional<StencilAttachmentDescriptor> back);
uint32_t uint32_t * format
@ kOneMinusDestinationAlpha
@ kOneMinusDestinationColor
PrimitiveType
Decides how backend draws pixels based on input vertices.
@ kPoint
Draws a point at each input vertex.
constexpr PixelFormat FromMTLPixelFormat(MTLPixelFormat format)
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
constexpr MTLColorWriteMask ToMTLColorWriteMask(ColorWriteMask type)
constexpr StoreAction FromMTLStoreAction(MTLStoreAction action)
constexpr MTLStencilOperation ToMTLStencilOperation(StencilOperation op)
MTLPixelFormat SafeMTLPixelFormatBGR10_XR_sRGB()
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
@ kEqual
Comparison test passes if new_value == current_value.
@ kLessEqual
Comparison test passes if new_value <= current_value.
@ kGreaterEqual
Comparison test passes if new_value >= current_value.
@ kAlways
Comparison test passes always passes.
@ kLess
Comparison test passes if new_value < current_value.
@ kGreater
Comparison test passes if new_value > current_value.
@ kNotEqual
Comparison test passes if new_value != current_value.
@ kNever
Comparison test never passes.
MTLDepthStencilDescriptor * ToMTLDepthStencilDescriptor(std::optional< DepthAttachmentDescriptor > depth, std::optional< StencilAttachmentDescriptor > front, std::optional< StencilAttachmentDescriptor > back)
MipFilter
Options for selecting and filtering between mipmap levels.
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
@ kBase
The texture is sampled as if it only had a single mipmap level.
@ kNearest
The nearst mipmap level is selected.
@ kDecrementWrap
Decrement the current stencil value by 1. If at zero, set to maximum.
@ kSetToReferenceValue
Reset the stencil value to the reference value.
@ kDecrementClamp
Decrement the current stencil value by 1. Clamp it to zero.
@ kZero
Reset the stencil value to zero.
@ kIncrementClamp
Increment the current stencil value by 1. Clamp it to the maximum.
@ kIncrementWrap
Increment the current stencil value by 1. If at maximum, set to zero.
@ kInvert
Perform a logical bitwise invert on the current stencil value.
@ kKeep
Don't modify the current stencil value.
constexpr MTLLoadAction ToMTLLoadAction(LoadAction action)
constexpr MTLSamplerMipFilter ToMTLSamplerMipFilter(MipFilter filter)
constexpr MTLBlendOperation ToMTLBlendOperation(BlendOperation type)
MTLPixelFormat SafeMTLPixelFormatBGR10_XR()
MTLPixelFormat SafeMTLPixelFormatDepth24Unorm_Stencil8()
@ kStoreAndMultisampleResolve
MTLPixelFormat SafeMTLPixelFormatBGRA10_XR()
constexpr MTLPrimitiveType ToMTLPrimitiveType(PrimitiveType type)
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
constexpr LoadAction FromMTLLoadAction(MTLLoadAction action)
constexpr MTLSamplerAddressMode ToMTLSamplerAddressMode(SamplerAddressMode mode)
constexpr MTLTextureType ToMTLTextureType(TextureType type)
constexpr MTLTriangleFillMode ToMTLTriangleFillMode(PolygonMode mode)
constexpr MTLBlendFactor ToMTLBlendFactor(BlendFactor type)
MinMagFilter
Describes how the texture should be sampled when the texture is being shrunk (minified) or expanded (...
@ kNearest
Select nearest to the sample point. Most widely supported.
constexpr MTLIndexType ToMTLIndexType(IndexType type)
MTLRenderPipelineColorAttachmentDescriptor * ToMTLRenderPipelineColorAttachmentDescriptor(ColorAttachmentDescriptor descriptor)
constexpr MTLSamplerMinMagFilter ToMTLSamplerMinMagFilter(MinMagFilter filter)
constexpr MTLCompareFunction ToMTLCompareFunction(CompareFunction func)
constexpr MTLStoreAction ToMTLStoreAction(StoreAction action)
MTLTextureDescriptor * ToMTLTextureDescriptor(const TextureDescriptor &desc)
MTLClearColor ToMTLClearColor(const Color &color)
constexpr MTLCullMode ToMTLCullMode(CullMode mode)