Render passes for MSAA and postprocessing

Recently, I have applied postprocessing effects to my rendering. In order to do so, I created 2 render passes, which I configured in the following fashion:

  • First render pass contains one subpass with the following attributes:
    • Depth attachment: For depth values.
    • Color attachment: Final color
  • Second render pass contains one subpass with the following attributes:
    • Color attachment: Input attachment taken from the first render pass.
    • Depth attachment: Input attachment taken from the first render pass.
    • Color attachment (2): Final color (corresponds to the swap chain image)

However, I don’t know how to do postprocessing when I am applying MSAA. In this case, when I am not doing postprocessing, I just have one render pass with one subpass that contains the following attachments:

  • depth attachment (many samples, one per MSAA sample)
  • color attachment (many samples, one per MSAA sample)
  • Resolve color attachment (for resolving the color attachment samples)

I want to render something applying MSAA and also postprocessing effects. What could be the best way of doing this? Two render passes again? How should I configure my render passes and the attachments?

If your post-processing is able to work through the actual “input attachment” functionality (which is limited to reading only from the texel the fragment corresponds to), then there’s no need to use multiple render passes. However, most post-processing effects need to read neighboring texels, which input attachments cannot do. That’s when you need to split the render pass.

As for multisampling and post-processing, you need to decide if you want your post-processing to work per-sample or per-pixel. The former requires a bit more math, as you have to select which samples within a pixel you’re acting on, and you probably need to read more samples in order to do whatever process you’re trying to achieve. But this means doing it before the resolve operation, so if your post-processing step requires a separate render pass, the resolve will have to wait until the post-processing is done.

Thank you. What I want is to apply postprocessing per-sample (and also MSAA) so, as you said, I need many render passes.

This is what I want to do. What I don’t understand is how to design my 2 render passes (I assume 2 are enough for this) and organize their attachments, and their samples. I guess it is done in the following way (but I am not sure of this):

  • The first render pass contains one subpass, containing the following attachments:
    • depth attachment (Many samples, one per MSAA sample. Passed as textures to render pass 2).
    • color attachment (Many samples, one per MSAA sample. Passed as textures to render pass 2).
  • The second render pass contains one subpass, containing the following attachments:
    • Color attachment: Input attachment taken from the first render pass (many samples).
    • Depth attachment: Input attachment taken from the first render pass (many samples).
    • Color attachment (2): Final color (corresponds to the swap chain image)

Is this correct? Am I missing something?
I guess that the sampler format for these multisampled attachments is sample2DMS, right?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.