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;
389MTLRenderPipelineColorAttachmentDescriptor*
391 ColorAttachmentDescriptor descriptor);
394 std::optional<DepthAttachmentDescriptor> depth,
395 std::optional<StencilAttachmentDescriptor> front,
396 std::optional<StencilAttachmentDescriptor> back);
uint32_t uint32_t * format
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
@ 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)
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.
constexpr MTLColorWriteMask ToMTLColorWriteMask(ColorWriteMask type)
constexpr StoreAction FromMTLStoreAction(MTLStoreAction action)
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
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)
@ 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)
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 MTLTriangleFillMode ToMTLTriangleFillMode(PolygonMode mode)
constexpr MTLBlendFactor ToMTLBlendFactor(BlendFactor type)
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)