6#include <Metal/Metal.h>
14MTLRenderPipelineColorAttachmentDescriptor*
17 auto des = [[MTLRenderPipelineColorAttachmentDescriptor alloc]
init];
22 des.sourceRGBBlendFactor =
25 des.destinationRGBBlendFactor =
28 des.sourceAlphaBlendFactor =
31 des.destinationAlphaBlendFactor =
40 auto des = [[MTLStencilDescriptor alloc]
init];
42 des.stencilFailureOperation =
45 des.depthStencilPassOperation =
55 std::optional<DepthAttachmentDescriptor> depth,
56 std::optional<StencilAttachmentDescriptor> front,
57 std::optional<StencilAttachmentDescriptor> back) {
62 .depth_write_enabled =
false,
66 auto des = [[MTLDepthStencilDescriptor alloc]
init];
71 auto depth_write_enabled = depth->depth_write_enabled;
73 des.depthCompareFunction = compare_function;
74 des.depthWriteEnabled = depth_write_enabled;
76 if (front.has_value()) {
79 if (back.has_value()) {
87 if (!
desc.IsValid()) {
90 auto mtl_desc = [[MTLTextureDescriptor alloc]
init];
93 mtl_desc.sampleCount =
static_cast<NSUInteger
>(
desc.sample_count);
94 mtl_desc.width =
desc.size.width;
95 mtl_desc.height =
desc.size.height;
96 mtl_desc.mipmapLevelCount =
desc.mip_count;
97 mtl_desc.usage = MTLTextureUsageUnknown;
99 mtl_desc.usage |= MTLTextureUsageUnknown;
102 mtl_desc.usage |= MTLTextureUsageShaderRead;
105 mtl_desc.usage |= MTLTextureUsageShaderWrite;
108 mtl_desc.usage |= MTLTextureUsageRenderTarget;
115 if (@available(macOS 10.11, *)) {
116 return MTLPixelFormatDepth24Unorm_Stencil8;
119 return MTLPixelFormatInvalid;
123 if (@available(iOS 11, macOS 11.0, *)) {
124 return MTLPixelFormatBGR10_XR_sRGB;
126 return MTLPixelFormatInvalid;
131 if (@available(iOS 10, macOS 11.0, *)) {
132 return MTLPixelFormatBGR10_XR;
134 return MTLPixelFormatInvalid;
139 if (@available(iOS 10, macOS 11.0, *)) {
140 return MTLPixelFormatBGRA10_XR;
142 return MTLPixelFormatInvalid;
MTLStencilDescriptor * ToMTLStencilDescriptor(const StencilAttachmentDescriptor &descriptor)
constexpr MTLColorWriteMask ToMTLColorWriteMask(ColorWriteMask type)
constexpr MTLStencilOperation ToMTLStencilOperation(StencilOperation op)
MTLPixelFormat SafeMTLPixelFormatBGR10_XR_sRGB()
@ kAlways
Comparison test passes always passes.
MTLDepthStencilDescriptor * ToMTLDepthStencilDescriptor(std::optional< DepthAttachmentDescriptor > depth, std::optional< StencilAttachmentDescriptor > front, std::optional< StencilAttachmentDescriptor > back)
constexpr MTLBlendOperation ToMTLBlendOperation(BlendOperation type)
MTLPixelFormat SafeMTLPixelFormatBGR10_XR()
MTLPixelFormat SafeMTLPixelFormatDepth24Unorm_Stencil8()
MTLPixelFormat SafeMTLPixelFormatBGRA10_XR()
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
constexpr MTLTextureType ToMTLTextureType(TextureType type)
constexpr MTLBlendFactor ToMTLBlendFactor(BlendFactor type)
MTLRenderPipelineColorAttachmentDescriptor * ToMTLRenderPipelineColorAttachmentDescriptor(ColorAttachmentDescriptor descriptor)
constexpr MTLCompareFunction ToMTLCompareFunction(CompareFunction func)
MTLTextureDescriptor * ToMTLTextureDescriptor(const TextureDescriptor &desc)
Describe the color attachment that will be used with this pipeline.
BlendOperation color_blend_op
BlendFactor dst_color_blend_factor
ColorWriteMask write_mask
BlendFactor src_alpha_blend_factor
BlendOperation alpha_blend_op
BlendFactor src_color_blend_factor
BlendFactor dst_alpha_blend_factor
CompareFunction depth_compare
StencilOperation stencil_failure
CompareFunction stencil_compare
StencilOperation depth_failure
StencilOperation depth_stencil_pass
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...