Imagination PowerVR SDK Blog

FBO rendering ... avoiding the need for 100 useless depth/stencil attachments


#1

Let me pose the question in the form of an example:

Suppose you have a cache of 100 color textures (same res, internal format) to be rendered via FBOs, and you might need to re-render 1-60 of those in one frame.

Suppose also that you need depth and/or stencil FBO attachments to render these color textures properly, and that you don’t care about the final depth/stencil result.

The question is: Can we avoid the needless memory consumption for 60-100 depth/stencil attachments (one per color texture) to avoid depth/stencil texture/renderbuffer ghosting IF we merely:

  1. Call gl{Discard,Invalidate}Framebuffer on the DEPTH/STENCIL attachment(s) at the end of the frame, and
  2. Allocate/share "one" depth/stencil attachment across all FBOs.

Given that we may be talking up to 100MB for 100 depth/stencil attachments (depending on PowerVR’s internal depth and/or stencil renderbuffer/texture representation), I’m very motivated to avoid this waste if possible.

Thanks!


#2

Hello Dark_Photon,

Yes - sharing one depth/stencil across all FBOs will work fine. The complication for ghosting/stalling occurs when the attachment (in this case a depth buffer) is subsequently used by another render e.g. used as a texture elsewhere.

Thanks,
Paul


#3

Thanks a bunch! We’ll implement that approach.