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()) {
90 auto mtl_desc = [[MTLTextureDescriptor alloc] init];
93 mtl_desc.sampleCount =
static_cast<NSUInteger
>(desc.
sample_count);
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;
150 if (@available(macOS 10.11, *)) {
151 return MTLPixelFormatBC1_RGBA;
154 return MTLPixelFormatInvalid;
159 if (@available(macOS 10.11, *)) {
160 return MTLPixelFormatBC1_RGBA_sRGB;
163 return MTLPixelFormatInvalid;
168 if (@available(macOS 10.11, *)) {
169 return MTLPixelFormatBC3_RGBA;
172 return MTLPixelFormatInvalid;
177 if (@available(macOS 10.11, *)) {
178 return MTLPixelFormatBC3_RGBA_sRGB;
181 return MTLPixelFormatInvalid;
186 if (@available(macOS 10.11, *)) {
187 return MTLPixelFormatBC5_RGUnorm;
190 return MTLPixelFormatInvalid;
195 if (@available(macOS 10.11, *)) {
196 return MTLPixelFormatBC7_RGBAUnorm;
199 return MTLPixelFormatInvalid;
204 if (@available(macOS 10.11, *)) {
205 return MTLPixelFormatBC7_RGBAUnorm_sRGB;
208 return MTLPixelFormatInvalid;
214 if (@available(macOS 11.0, *)) {
215 return MTLPixelFormatETC2_RGB8;
217 return MTLPixelFormatInvalid;
221 if (@available(macOS 11.0, *)) {
222 return MTLPixelFormatETC2_RGB8_sRGB;
224 return MTLPixelFormatInvalid;
228 if (@available(macOS 11.0, *)) {
229 return MTLPixelFormatEAC_RGBA8;
231 return MTLPixelFormatInvalid;
235 if (@available(macOS 11.0, *)) {
236 return MTLPixelFormatEAC_RGBA8_sRGB;
238 return MTLPixelFormatInvalid;
242 if (@available(macOS 11.0, *)) {
243 return MTLPixelFormatASTC_4x4_LDR;
245 return MTLPixelFormatInvalid;
249 if (@available(macOS 11.0, *)) {
250 return MTLPixelFormatASTC_4x4_sRGB;
252 return MTLPixelFormatInvalid;
256 if (@available(macOS 11.0, *)) {
257 return MTLPixelFormatASTC_8x8_LDR;
259 return MTLPixelFormatInvalid;
263 if (@available(macOS 11.0, *)) {
264 return MTLPixelFormatASTC_8x8_sRGB;
266 return MTLPixelFormatInvalid;
270 if (@available(macOS 11.0, *)) {
271 return MTLPixelFormatASTC_4x4_HDR;
273 return MTLPixelFormatInvalid;
277 if (@available(macOS 11.0, *)) {
278 return MTLPixelFormatASTC_8x8_HDR;
280 return MTLPixelFormatInvalid;
MTLPixelFormat SafeMTLPixelFormatETC2_RGB8_sRGB()
MTLPixelFormat SafeMTLPixelFormatEAC_RGBA8()
MTLStencilDescriptor * ToMTLStencilDescriptor(const StencilAttachmentDescriptor &descriptor)
MTLPixelFormat SafeMTLPixelFormatASTC_4x4_HDR()
MTLPixelFormat SafeMTLPixelFormatETC2_RGB8()
MTLPixelFormat SafeMTLPixelFormatASTC_4x4_sRGB()
constexpr MTLColorWriteMask ToMTLColorWriteMask(ColorWriteMask type)
MTLPixelFormat SafeMTLPixelFormatASTC_4x4_LDR()
MTLPixelFormat SafeMTLPixelFormatASTC_8x8_HDR()
constexpr MTLStencilOperation ToMTLStencilOperation(StencilOperation op)
MTLPixelFormat SafeMTLPixelFormatBC7_RGBAUnorm_sRGB()
MTLPixelFormat SafeMTLPixelFormatBGR10_XR_sRGB()
@ kAlways
Comparison test passes always passes.
MTLDepthStencilDescriptor * ToMTLDepthStencilDescriptor(std::optional< DepthAttachmentDescriptor > depth, std::optional< StencilAttachmentDescriptor > front, std::optional< StencilAttachmentDescriptor > back)
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()
MTLPixelFormat SafeMTLPixelFormatBGRA10_XR()
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
constexpr MTLTextureType ToMTLTextureType(TextureType type)
constexpr MTLBlendFactor ToMTLBlendFactor(BlendFactor type)
MTLRenderPipelineColorAttachmentDescriptor * ToMTLRenderPipelineColorAttachmentDescriptor(ColorAttachmentDescriptor descriptor)
MTLPixelFormat SafeMTLPixelFormatBC1_RGBA_sRGB()
constexpr MTLCompareFunction ToMTLCompareFunction(CompareFunction func)
MTLPixelFormat SafeMTLPixelFormatASTC_8x8_sRGB()
MTLTextureDescriptor * ToMTLTextureDescriptor(const TextureDescriptor &desc)
MTLPixelFormat SafeMTLPixelFormatBC5_RGUnorm()
MTLPixelFormat SafeMTLPixelFormatEAC_RGBA8_sRGB()
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...
constexpr bool IsValid() const