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"
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 MTLPixelFormatInvalid;
117 return MTLBlendFactorZero;
119 return MTLBlendFactorOne;
121 return MTLBlendFactorSourceColor;
123 return MTLBlendFactorOneMinusSourceColor;
125 return MTLBlendFactorSourceAlpha;
127 return MTLBlendFactorOneMinusSourceAlpha;
129 return MTLBlendFactorDestinationColor;
131 return MTLBlendFactorOneMinusDestinationColor;
133 return MTLBlendFactorDestinationAlpha;
135 return MTLBlendFactorOneMinusDestinationAlpha;
137 return MTLBlendFactorSourceAlphaSaturated;
139 return MTLBlendFactorBlendColor;
141 return MTLBlendFactorOneMinusBlendColor;
143 return MTLBlendFactorBlendAlpha;
145 return MTLBlendFactorOneMinusBlendAlpha;
147 return MTLBlendFactorZero;
153 return MTLPrimitiveTypeTriangle;
155 return MTLPrimitiveTypeTriangleStrip;
157 return MTLPrimitiveTypeLine;
159 return MTLPrimitiveTypeLineStrip;
161 return MTLPrimitiveTypePoint;
165 return MTLPrimitiveTypePoint;
167 return MTLPrimitiveTypePoint;
173 return MTLTriangleFillModeFill;
175 return MTLTriangleFillModeLines;
177 return MTLTriangleFillModeFill;
183 return MTLIndexTypeUInt16;
185 return MTLIndexTypeUInt32;
192 return MTLCullModeNone;
194 return MTLCullModeBack;
196 return MTLCullModeFront;
198 return MTLCullModeNone;
204 return MTLBlendOperationAdd;
206 return MTLBlendOperationSubtract;
208 return MTLBlendOperationReverseSubtract;
210 return MTLBlendOperationAdd;
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 MTLSamplerMipFilterNotMipmapped;
352 return MTLSamplerMipFilterNearest;
354 return MTLSamplerMipFilterLinear;
356 return MTLSamplerMipFilterNotMipmapped;
363 return MTLSamplerAddressModeClampToEdge;
365 return MTLSamplerAddressModeRepeat;
367 return MTLSamplerAddressModeMirrorRepeat;
369 return MTLSamplerAddressModeClampToZero;
371 return MTLSamplerAddressModeClampToEdge;
381 return MTLTextureType2D;
383 return MTLTextureType2DMultisample;
385 return MTLTextureTypeCube;
388 <<
"kTextureExternalOES can not be used with the Metal backend.";
390 return MTLTextureType2D;
393 MTLRenderPipelineColorAttachmentDescriptor*
395 ColorAttachmentDescriptor descriptor);
398 std::optional<DepthAttachmentDescriptor> depth,
399 std::optional<StencilAttachmentDescriptor> front,
400 std::optional<StencilAttachmentDescriptor> back);
406 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_FORMATS_MTL_H_