7 #include <Metal/Metal.h>
11 #include "flutter/fml/macros.h"
23 case MTLPixelFormatInvalid:
25 case MTLPixelFormatBGRA8Unorm:
27 case MTLPixelFormatBGRA8Unorm_sRGB:
29 case MTLPixelFormatRGBA8Unorm:
31 case MTLPixelFormatRGBA8Unorm_sRGB:
33 case MTLPixelFormatRGBA32Float:
35 case MTLPixelFormatRGBA16Float:
37 case MTLPixelFormatStencil8:
40 case MTLPixelFormatDepth24Unorm_Stencil8:
43 case MTLPixelFormatDepth32Float_Stencil8:
45 case MTLPixelFormatBGR10_XR_sRGB:
47 case MTLPixelFormatBGR10_XR:
49 case MTLPixelFormatBGRA10_XR:
78 return MTLPixelFormatInvalid;
80 return MTLPixelFormatA8Unorm;
82 return MTLPixelFormatR8Unorm;
84 return MTLPixelFormatRG8Unorm;
86 return MTLPixelFormatBGRA8Unorm;
88 return MTLPixelFormatBGRA8Unorm_sRGB;
90 return MTLPixelFormatRGBA8Unorm;
92 return MTLPixelFormatRGBA8Unorm_sRGB;
94 return MTLPixelFormatRGBA32Float;
96 return MTLPixelFormatRGBA16Float;
98 return MTLPixelFormatStencil8;
102 return MTLPixelFormatDepth32Float_Stencil8;
110 return MTLPixelFormatInvalid;
116 return MTLBlendFactorZero;
118 return MTLBlendFactorOne;
120 return MTLBlendFactorSourceColor;
122 return MTLBlendFactorOneMinusSourceColor;
124 return MTLBlendFactorSourceAlpha;
126 return MTLBlendFactorOneMinusSourceAlpha;
128 return MTLBlendFactorDestinationColor;
130 return MTLBlendFactorOneMinusDestinationColor;
132 return MTLBlendFactorDestinationAlpha;
134 return MTLBlendFactorOneMinusDestinationAlpha;
136 return MTLBlendFactorSourceAlphaSaturated;
138 return MTLBlendFactorBlendColor;
140 return MTLBlendFactorOneMinusBlendColor;
142 return MTLBlendFactorBlendAlpha;
144 return MTLBlendFactorOneMinusBlendAlpha;
146 return MTLBlendFactorZero;
152 return MTLPrimitiveTypeTriangle;
154 return MTLPrimitiveTypeTriangleStrip;
156 return MTLPrimitiveTypeLine;
158 return MTLPrimitiveTypeLineStrip;
160 return MTLPrimitiveTypePoint;
162 return MTLPrimitiveTypePoint;
168 return MTLTriangleFillModeFill;
170 return MTLTriangleFillModeLines;
172 return MTLTriangleFillModeFill;
178 return MTLIndexTypeUInt16;
180 return MTLIndexTypeUInt32;
187 return MTLCullModeNone;
189 return MTLCullModeBack;
191 return MTLCullModeFront;
193 return MTLCullModeNone;
199 return MTLBlendOperationAdd;
201 return MTLBlendOperationSubtract;
203 return MTLBlendOperationReverseSubtract;
205 return MTLBlendOperationAdd;
209 std::underlying_type_t<ColorWriteMask> type) {
210 using UnderlyingType = decltype(type);
212 MTLColorWriteMask mask = MTLColorWriteMaskNone;
215 mask |= MTLColorWriteMaskRed;
219 mask |= MTLColorWriteMaskGreen;
223 mask |= MTLColorWriteMaskBlue;
227 mask |= MTLColorWriteMaskAlpha;
236 return MTLCompareFunctionNever;
238 return MTLCompareFunctionLess;
240 return MTLCompareFunctionEqual;
242 return MTLCompareFunctionLessEqual;
244 return MTLCompareFunctionGreater;
246 return MTLCompareFunctionNotEqual;
248 return MTLCompareFunctionGreaterEqual;
250 return MTLCompareFunctionAlways;
252 return MTLCompareFunctionAlways;
258 return MTLStencilOperationKeep;
260 return MTLStencilOperationZero;
262 return MTLStencilOperationReplace;
264 return MTLStencilOperationIncrementClamp;
266 return MTLStencilOperationDecrementClamp;
268 return MTLStencilOperationInvert;
270 return MTLStencilOperationIncrementWrap;
272 return MTLStencilOperationDecrementWrap;
274 return MTLStencilOperationKeep;
280 return MTLLoadActionDontCare;
282 return MTLLoadActionLoad;
284 return MTLLoadActionClear;
287 return MTLLoadActionDontCare;
292 case MTLLoadActionDontCare:
294 case MTLLoadActionLoad:
296 case MTLLoadActionClear:
308 return MTLStoreActionDontCare;
310 return MTLStoreActionStore;
312 return MTLStoreActionMultisampleResolve;
314 return MTLStoreActionStoreAndMultisampleResolve;
316 return MTLStoreActionDontCare;
321 case MTLStoreActionDontCare:
323 case MTLStoreActionStore:
325 case MTLStoreActionMultisampleResolve:
327 case MTLStoreActionStoreAndMultisampleResolve:
338 return MTLSamplerMinMagFilterNearest;
340 return MTLSamplerMinMagFilterLinear;
342 return MTLSamplerMinMagFilterNearest;
348 return MTLSamplerMipFilterNearest;
350 return MTLSamplerMipFilterLinear;
352 return MTLSamplerMipFilterNotMipmapped;
359 return MTLSamplerAddressModeClampToEdge;
361 return MTLSamplerAddressModeRepeat;
363 return MTLSamplerAddressModeMirrorRepeat;
365 return MTLSamplerAddressModeClampToZero;
367 return MTLSamplerAddressModeClampToEdge;
377 return MTLTextureType2D;
379 return MTLTextureType2DMultisample;
381 return MTLTextureTypeCube;
384 <<
"kTextureExternalOES can not be used with the Metal backend.";
386 return MTLTextureType2D;
389 MTLRenderPipelineColorAttachmentDescriptor*
391 ColorAttachmentDescriptor descriptor);
394 std::optional<DepthAttachmentDescriptor> depth,
395 std::optional<StencilAttachmentDescriptor> front,
396 std::optional<StencilAttachmentDescriptor> back);