Chapter 16 - particles pipelineState pixelFormat

I try to have particles as fire of chapter 16 in a 3D scene as the one of the chapter 9.
So I have 3 pipelineState :

  • rendererPipelineState for the 3D scene,
  • particulePipelineState to compute the particles,
  • particleRenderPipelineState to render particles,

I init the metal view with : metalView.depthStencilPixelFormat = .depth32Float

I build the particleRenderPipelineState with :
descriptor.colorAttachments[0].pixelFormat = .bgra8Unorm

I have a build success but a problem occurs : I obtain this message :

failed assertion `For depth attachment, the render pipeline’s pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer’s pixelFormat (MTLPixelFormatDepth32Float).’

I do not really understand these aspects about pixelFormat.

Can someone enlighten me on this subject ?

Thank you for your help.


I would guess that rendererPipelineState doesn’t have a depth pixel format that matches the view?
The error message says that the pipeline state pixel format does not match the frame buffer pixel format. That means that the pipeline state that you’re using to render into the view’s drawable texture does not have its depth stencil state pixel format set to float32.
When you create rendererPipelineState, set the descriptor’s depth stencil format to .depth32Float.
Explanation: the pixel format applies to the textures that are being written. The drawable requires a .bgra8Unorm pixel format for the main texture that appears on screen, but also a .depth32Float pixel format for the depth texture. The pipeline state tells the GPU what formats to write.

1 Like

Thank you very much Caroline for your response and the explanations.

I add : *descriptor.depthAttachmentPixelFormat = .depth32Float * to the description of the particleRenderPipelineState and I have no more problem :smiley:

have a nice week-end

1 Like