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>
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:
100 return MTLPixelFormatInvalid;
102 return MTLPixelFormatA8Unorm;
104 return MTLPixelFormatR8Unorm;
106 return MTLPixelFormatRG8Unorm;
108 return MTLPixelFormatBGRA8Unorm;
110 return MTLPixelFormatBGRA8Unorm_sRGB;
112 return MTLPixelFormatRGBA8Unorm;
114 return MTLPixelFormatRGBA8Unorm_sRGB;
116 return MTLPixelFormatRGBA32Float;
118 return MTLPixelFormatRGBA16Float;
120 return MTLPixelFormatStencil8;
124 return MTLPixelFormatDepth32Float_Stencil8;
132 return MTLPixelFormatR32Float;
168 return MTLPixelFormatInvalid;
174 return MTLBlendFactorZero;
176 return MTLBlendFactorOne;
178 return MTLBlendFactorSourceColor;
180 return MTLBlendFactorOneMinusSourceColor;
182 return MTLBlendFactorSourceAlpha;
184 return MTLBlendFactorOneMinusSourceAlpha;
186 return MTLBlendFactorDestinationColor;
188 return MTLBlendFactorOneMinusDestinationColor;
190 return MTLBlendFactorDestinationAlpha;
192 return MTLBlendFactorOneMinusDestinationAlpha;
194 return MTLBlendFactorSourceAlphaSaturated;
196 return MTLBlendFactorBlendColor;
198 return MTLBlendFactorOneMinusBlendColor;
200 return MTLBlendFactorBlendAlpha;
202 return MTLBlendFactorOneMinusBlendAlpha;
204 return MTLBlendFactorZero;
210 return MTLPrimitiveTypeTriangle;
212 return MTLPrimitiveTypeTriangleStrip;
214 return MTLPrimitiveTypeLine;
216 return MTLPrimitiveTypeLineStrip;
218 return MTLPrimitiveTypePoint;
222 return MTLPrimitiveTypePoint;
224 return MTLPrimitiveTypePoint;
230 return MTLTriangleFillModeFill;
232 return MTLTriangleFillModeLines;
234 return MTLTriangleFillModeFill;
240 return MTLIndexTypeUInt16;
242 return MTLIndexTypeUInt32;
249 return MTLCullModeNone;
251 return MTLCullModeBack;
253 return MTLCullModeFront;
255 return MTLCullModeNone;
261 return MTLBlendOperationAdd;
263 return MTLBlendOperationSubtract;
265 return MTLBlendOperationReverseSubtract;
267 return MTLBlendOperationAdd;
271 MTLColorWriteMask mask = MTLColorWriteMaskNone;
274 mask |= MTLColorWriteMaskRed;
278 mask |= MTLColorWriteMaskGreen;
282 mask |= MTLColorWriteMaskBlue;
286 mask |= MTLColorWriteMaskAlpha;
295 return MTLCompareFunctionNever;
297 return MTLCompareFunctionLess;
299 return MTLCompareFunctionEqual;
301 return MTLCompareFunctionLessEqual;
303 return MTLCompareFunctionGreater;
305 return MTLCompareFunctionNotEqual;
307 return MTLCompareFunctionGreaterEqual;
309 return MTLCompareFunctionAlways;
311 return MTLCompareFunctionAlways;
317 return MTLStencilOperationKeep;
319 return MTLStencilOperationZero;
321 return MTLStencilOperationReplace;
323 return MTLStencilOperationIncrementClamp;
325 return MTLStencilOperationDecrementClamp;
327 return MTLStencilOperationInvert;
329 return MTLStencilOperationIncrementWrap;
331 return MTLStencilOperationDecrementWrap;
333 return MTLStencilOperationKeep;
339 return MTLLoadActionDontCare;
341 return MTLLoadActionLoad;
343 return MTLLoadActionClear;
346 return MTLLoadActionDontCare;
351 case MTLLoadActionDontCare:
353 case MTLLoadActionLoad:
355 case MTLLoadActionClear:
367 return MTLStoreActionDontCare;
369 return MTLStoreActionStore;
371 return MTLStoreActionMultisampleResolve;
373 return MTLStoreActionStoreAndMultisampleResolve;
375 return MTLStoreActionDontCare;
380 case MTLStoreActionDontCare:
382 case MTLStoreActionStore:
384 case MTLStoreActionMultisampleResolve:
386 case MTLStoreActionStoreAndMultisampleResolve:
397 return MTLSamplerMinMagFilterNearest;
399 return MTLSamplerMinMagFilterLinear;
401 return MTLSamplerMinMagFilterNearest;
407 return MTLSamplerMipFilterNotMipmapped;
409 return MTLSamplerMipFilterNearest;
411 return MTLSamplerMipFilterLinear;
413 return MTLSamplerMipFilterNotMipmapped;
420 return MTLSamplerAddressModeClampToEdge;
422 return MTLSamplerAddressModeRepeat;
424 return MTLSamplerAddressModeMirrorRepeat;
426 return MTLSamplerAddressModeClampToZero;
428 return MTLSamplerAddressModeClampToEdge;
438 return MTLTextureType2D;
440 return MTLTextureType2DMultisample;
442 return MTLTextureTypeCube;
445 <<
"kTextureExternalOES can not be used with the Metal backend.";
447 return MTLTextureType2D;
450MTLRenderPipelineColorAttachmentDescriptor*
452 ColorAttachmentDescriptor descriptor);
455 std::optional<DepthAttachmentDescriptor> depth,
456 std::optional<StencilAttachmentDescriptor> front,
457 std::optional<StencilAttachmentDescriptor> back);
uint32_t uint32_t * format
MTLPixelFormat SafeMTLPixelFormatETC2_RGB8_sRGB()
MTLPixelFormat SafeMTLPixelFormatEAC_RGBA8()
@ 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)
MTLPixelFormat SafeMTLPixelFormatASTC_4x4_HDR()
MTLPixelFormat SafeMTLPixelFormatETC2_RGB8()
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
MTLPixelFormat SafeMTLPixelFormatASTC_4x4_sRGB()
constexpr MTLColorWriteMask ToMTLColorWriteMask(ColorWriteMask type)
constexpr StoreAction FromMTLStoreAction(MTLStoreAction action)
MTLPixelFormat SafeMTLPixelFormatASTC_4x4_LDR()
MTLPixelFormat SafeMTLPixelFormatASTC_8x8_HDR()
constexpr MTLStencilOperation ToMTLStencilOperation(StencilOperation op)
MTLPixelFormat SafeMTLPixelFormatBC7_RGBAUnorm_sRGB()
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)
MTLPixelFormat SafeMTLPixelFormatBC1_RGBA()
MTLPixelFormat SafeMTLPixelFormatBC7_RGBAUnorm()
constexpr MTLBlendOperation ToMTLBlendOperation(BlendOperation type)
MTLPixelFormat SafeMTLPixelFormatBC3_RGBA()
MTLPixelFormat SafeMTLPixelFormatASTC_8x8_LDR()
MTLPixelFormat SafeMTLPixelFormatBGR10_XR()
MTLPixelFormat SafeMTLPixelFormatBC3_RGBA_sRGB()
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)
MTLPixelFormat SafeMTLPixelFormatBC1_RGBA_sRGB()
constexpr MTLCompareFunction ToMTLCompareFunction(CompareFunction func)
constexpr MTLStoreAction ToMTLStoreAction(StoreAction action)
MTLPixelFormat SafeMTLPixelFormatASTC_8x8_sRGB()
MTLTextureDescriptor * ToMTLTextureDescriptor(const TextureDescriptor &desc)
MTLClearColor ToMTLClearColor(const Color &color)
MTLPixelFormat SafeMTLPixelFormatBC5_RGUnorm()
MTLPixelFormat SafeMTLPixelFormatEAC_RGBA8_sRGB()
constexpr MTLCullMode ToMTLCullMode(CullMode mode)
impeller::ShaderType type