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;
163 return MTLPrimitiveTypePoint;
169 return MTLTriangleFillModeFill;
171 return MTLTriangleFillModeLines;
173 return MTLTriangleFillModeFill;
179 return MTLIndexTypeUInt16;
181 return MTLIndexTypeUInt32;
188 return MTLCullModeNone;
190 return MTLCullModeBack;
192 return MTLCullModeFront;
194 return MTLCullModeNone;
200 return MTLBlendOperationAdd;
202 return MTLBlendOperationSubtract;
204 return MTLBlendOperationReverseSubtract;
206 return MTLBlendOperationAdd;
210 MTLColorWriteMask mask = MTLColorWriteMaskNone;
213 mask |= MTLColorWriteMaskRed;
217 mask |= MTLColorWriteMaskGreen;
221 mask |= MTLColorWriteMaskBlue;
225 mask |= MTLColorWriteMaskAlpha;
234 return MTLCompareFunctionNever;
236 return MTLCompareFunctionLess;
238 return MTLCompareFunctionEqual;
240 return MTLCompareFunctionLessEqual;
242 return MTLCompareFunctionGreater;
244 return MTLCompareFunctionNotEqual;
246 return MTLCompareFunctionGreaterEqual;
248 return MTLCompareFunctionAlways;
250 return MTLCompareFunctionAlways;
256 return MTLStencilOperationKeep;
258 return MTLStencilOperationZero;
260 return MTLStencilOperationReplace;
262 return MTLStencilOperationIncrementClamp;
264 return MTLStencilOperationDecrementClamp;
266 return MTLStencilOperationInvert;
268 return MTLStencilOperationIncrementWrap;
270 return MTLStencilOperationDecrementWrap;
272 return MTLStencilOperationKeep;
278 return MTLLoadActionDontCare;
280 return MTLLoadActionLoad;
282 return MTLLoadActionClear;
285 return MTLLoadActionDontCare;
290 case MTLLoadActionDontCare:
292 case MTLLoadActionLoad:
294 case MTLLoadActionClear:
306 return MTLStoreActionDontCare;
308 return MTLStoreActionStore;
310 return MTLStoreActionMultisampleResolve;
312 return MTLStoreActionStoreAndMultisampleResolve;
314 return MTLStoreActionDontCare;
319 case MTLStoreActionDontCare:
321 case MTLStoreActionStore:
323 case MTLStoreActionMultisampleResolve:
325 case MTLStoreActionStoreAndMultisampleResolve:
336 return MTLSamplerMinMagFilterNearest;
338 return MTLSamplerMinMagFilterLinear;
340 return MTLSamplerMinMagFilterNearest;
346 return MTLSamplerMipFilterNotMipmapped;
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);
402 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_FORMATS_MTL_H_