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>
12 #include "flutter/fml/build_config.h"
13 #include "flutter/fml/macros.h"
25 case MTLPixelFormatInvalid:
27 case MTLPixelFormatBGRA8Unorm:
29 case MTLPixelFormatBGRA8Unorm_sRGB:
31 case MTLPixelFormatRGBA8Unorm:
33 case MTLPixelFormatRGBA8Unorm_sRGB:
35 case MTLPixelFormatRGBA32Float:
37 case MTLPixelFormatRGBA16Float:
39 case MTLPixelFormatStencil8:
42 case MTLPixelFormatDepth24Unorm_Stencil8:
45 case MTLPixelFormatDepth32Float_Stencil8:
47 case MTLPixelFormatBGR10_XR_sRGB:
49 case MTLPixelFormatBGR10_XR:
51 case MTLPixelFormatBGRA10_XR:
80 return MTLPixelFormatInvalid;
82 return MTLPixelFormatA8Unorm;
84 return MTLPixelFormatR8Unorm;
86 return MTLPixelFormatRG8Unorm;
88 return MTLPixelFormatBGRA8Unorm;
90 return MTLPixelFormatBGRA8Unorm_sRGB;
92 return MTLPixelFormatRGBA8Unorm;
94 return MTLPixelFormatRGBA8Unorm_sRGB;
96 return MTLPixelFormatRGBA32Float;
98 return MTLPixelFormatRGBA16Float;
100 return MTLPixelFormatStencil8;
104 return MTLPixelFormatDepth32Float_Stencil8;
112 return MTLPixelFormatInvalid;
118 return MTLBlendFactorZero;
120 return MTLBlendFactorOne;
122 return MTLBlendFactorSourceColor;
124 return MTLBlendFactorOneMinusSourceColor;
126 return MTLBlendFactorSourceAlpha;
128 return MTLBlendFactorOneMinusSourceAlpha;
130 return MTLBlendFactorDestinationColor;
132 return MTLBlendFactorOneMinusDestinationColor;
134 return MTLBlendFactorDestinationAlpha;
136 return MTLBlendFactorOneMinusDestinationAlpha;
138 return MTLBlendFactorSourceAlphaSaturated;
140 return MTLBlendFactorBlendColor;
142 return MTLBlendFactorOneMinusBlendColor;
144 return MTLBlendFactorBlendAlpha;
146 return MTLBlendFactorOneMinusBlendAlpha;
148 return MTLBlendFactorZero;
154 return MTLPrimitiveTypeTriangle;
156 return MTLPrimitiveTypeTriangleStrip;
158 return MTLPrimitiveTypeLine;
160 return MTLPrimitiveTypeLineStrip;
162 return MTLPrimitiveTypePoint;
164 return MTLPrimitiveTypePoint;
170 return MTLTriangleFillModeFill;
172 return MTLTriangleFillModeLines;
174 return MTLTriangleFillModeFill;
180 return MTLIndexTypeUInt16;
182 return MTLIndexTypeUInt32;
189 return MTLCullModeNone;
191 return MTLCullModeBack;
193 return MTLCullModeFront;
195 return MTLCullModeNone;
201 return MTLBlendOperationAdd;
203 return MTLBlendOperationSubtract;
205 return MTLBlendOperationReverseSubtract;
207 return MTLBlendOperationAdd;
211 std::underlying_type_t<ColorWriteMask> type) {
212 using UnderlyingType = decltype(type);
214 MTLColorWriteMask mask = MTLColorWriteMaskNone;
217 mask |= MTLColorWriteMaskRed;
221 mask |= MTLColorWriteMaskGreen;
225 mask |= MTLColorWriteMaskBlue;
229 mask |= MTLColorWriteMaskAlpha;
238 return MTLCompareFunctionNever;
240 return MTLCompareFunctionLess;
242 return MTLCompareFunctionEqual;
244 return MTLCompareFunctionLessEqual;
246 return MTLCompareFunctionGreater;
248 return MTLCompareFunctionNotEqual;
250 return MTLCompareFunctionGreaterEqual;
252 return MTLCompareFunctionAlways;
254 return MTLCompareFunctionAlways;
260 return MTLStencilOperationKeep;
262 return MTLStencilOperationZero;
264 return MTLStencilOperationReplace;
266 return MTLStencilOperationIncrementClamp;
268 return MTLStencilOperationDecrementClamp;
270 return MTLStencilOperationInvert;
272 return MTLStencilOperationIncrementWrap;
274 return MTLStencilOperationDecrementWrap;
276 return MTLStencilOperationKeep;
282 return MTLLoadActionDontCare;
284 return MTLLoadActionLoad;
286 return MTLLoadActionClear;
289 return MTLLoadActionDontCare;
294 case MTLLoadActionDontCare:
296 case MTLLoadActionLoad:
298 case MTLLoadActionClear:
310 return MTLStoreActionDontCare;
312 return MTLStoreActionStore;
314 return MTLStoreActionMultisampleResolve;
316 return MTLStoreActionStoreAndMultisampleResolve;
318 return MTLStoreActionDontCare;
323 case MTLStoreActionDontCare:
325 case MTLStoreActionStore:
327 case MTLStoreActionMultisampleResolve:
329 case MTLStoreActionStoreAndMultisampleResolve:
340 return MTLSamplerMinMagFilterNearest;
342 return MTLSamplerMinMagFilterLinear;
344 return MTLSamplerMinMagFilterNearest;
350 return MTLSamplerMipFilterNearest;
352 return MTLSamplerMipFilterLinear;
354 return MTLSamplerMipFilterNotMipmapped;
361 return MTLSamplerAddressModeClampToEdge;
363 return MTLSamplerAddressModeRepeat;
365 return MTLSamplerAddressModeMirrorRepeat;
367 return MTLSamplerAddressModeClampToZero;
369 return MTLSamplerAddressModeClampToEdge;
379 return MTLTextureType2D;
381 return MTLTextureType2DMultisample;
383 return MTLTextureTypeCube;
386 <<
"kTextureExternalOES can not be used with the Metal backend.";
388 return MTLTextureType2D;
391 MTLRenderPipelineColorAttachmentDescriptor*
393 ColorAttachmentDescriptor descriptor);
396 std::optional<DepthAttachmentDescriptor> depth,
397 std::optional<StencilAttachmentDescriptor> front,
398 std::optional<StencilAttachmentDescriptor> back);
404 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_FORMATS_MTL_H_