iosmetalmetalkitmetal-performance-shaders

Metal color attachment supported pixel formats


For offscreen buffer rendering (not drawing on screen), does Metal on iOS supports MTLPixelFormatR32Uint as pixel format? In other words, is something like this supposed to work?

 let pipelineStateDescriptor = MTLRenderPipelineDescriptor()
 pipelineStateDescriptor.vertexDescriptor = vertexDescriptor
 pipelineStateDescriptor.vertexFunction = vertexProgram
 pipelineStateDescriptor.fragmentFunction = fragmentProgram
 pipelineStateDescriptor.colorAttachments[0].pixelFormat = .R32Uint;
pipelineStateDescriptor.colorAttachments[0].blendingEnabled = true

Solution

  • You can download the Metal Feature Set Tables document from Apple. It's currently a PDF. It used to be HTML. Anyway, there you will find a table showing which pixel formats are available for what purpose(s) in each versions of each OS. R32UInt is usable as a render target on all versions of all OSes.