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 MTLColorWriteMask mask = MTLColorWriteMaskNone;
214 mask |= MTLColorWriteMaskRed;
218 mask |= MTLColorWriteMaskGreen;
222 mask |= MTLColorWriteMaskBlue;
226 mask |= MTLColorWriteMaskAlpha;
235 return MTLCompareFunctionNever;
237 return MTLCompareFunctionLess;
239 return MTLCompareFunctionEqual;
241 return MTLCompareFunctionLessEqual;
243 return MTLCompareFunctionGreater;
245 return MTLCompareFunctionNotEqual;
247 return MTLCompareFunctionGreaterEqual;
249 return MTLCompareFunctionAlways;
251 return MTLCompareFunctionAlways;
257 return MTLStencilOperationKeep;
259 return MTLStencilOperationZero;
261 return MTLStencilOperationReplace;
263 return MTLStencilOperationIncrementClamp;
265 return MTLStencilOperationDecrementClamp;
267 return MTLStencilOperationInvert;
269 return MTLStencilOperationIncrementWrap;
271 return MTLStencilOperationDecrementWrap;
273 return MTLStencilOperationKeep;
279 return MTLLoadActionDontCare;
281 return MTLLoadActionLoad;
283 return MTLLoadActionClear;
286 return MTLLoadActionDontCare;
291 case MTLLoadActionDontCare:
293 case MTLLoadActionLoad:
295 case MTLLoadActionClear:
307 return MTLStoreActionDontCare;
309 return MTLStoreActionStore;
311 return MTLStoreActionMultisampleResolve;
313 return MTLStoreActionStoreAndMultisampleResolve;
315 return MTLStoreActionDontCare;
320 case MTLStoreActionDontCare:
322 case MTLStoreActionStore:
324 case MTLStoreActionMultisampleResolve:
326 case MTLStoreActionStoreAndMultisampleResolve:
337 return MTLSamplerMinMagFilterNearest;
339 return MTLSamplerMinMagFilterLinear;
341 return MTLSamplerMinMagFilterNearest;
347 return MTLSamplerMipFilterNearest;
349 return MTLSamplerMipFilterLinear;
351 return MTLSamplerMipFilterNotMipmapped;
358 return MTLSamplerAddressModeClampToEdge;
360 return MTLSamplerAddressModeRepeat;
362 return MTLSamplerAddressModeMirrorRepeat;
364 return MTLSamplerAddressModeClampToZero;
366 return MTLSamplerAddressModeClampToEdge;
376 return MTLTextureType2D;
378 return MTLTextureType2DMultisample;
380 return MTLTextureTypeCube;
383 <<
"kTextureExternalOES can not be used with the Metal backend.";
385 return MTLTextureType2D;
388MTLRenderPipelineColorAttachmentDescriptor*
390 ColorAttachmentDescriptor descriptor);
393 std::optional<DepthAttachmentDescriptor> depth,
394 std::optional<StencilAttachmentDescriptor> front,
395 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)
@ 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)
@ kNearest
Sample from the nearest mip level.
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)
@ 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)