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);
@ 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)