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

**URL:** <https://forums.imgtec.com/t/fbo-rendering-avoiding-the-need-for-100-useless-depth-stencil-attachments/2278>\
**Category:** PowerVR Insider\
**Created:** [March 31, 2015, 1:33pm UTC](https://forums.imgtec.com/t/fbo-rendering-avoiding-the-need-for-100-useless-depth-stencil-attachments/2278 "2015-03-31T13:33:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dark\_photon](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/dark_photon/32/224_2.png) [@dark\_photon](https://forums.imgtec.com/u/dark_photon)\
**Post date:** [March 31, 2015, 1:33pm UTC](https://forums.imgtec.com/t/fbo-rendering-avoiding-the-need-for-100-useless-depth-stencil-attachments/2278/1 "2015-03-31T13:33:09Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pauls](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@pauls](https://forums.imgtec.com/u/pauls)\
**Post date:** [April 7, 2015, 12:50pm UTC](https://forums.imgtec.com/t/fbo-rendering-avoiding-the-need-for-100-useless-depth-stencil-attachments/2278/2 "2015-04-07T12:50:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dark\_photon](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/dark_photon/32/224_2.png) [@dark\_photon](https://forums.imgtec.com/u/dark_photon)\
**Post date:** [April 7, 2015, 6:22pm UTC](https://forums.imgtec.com/t/fbo-rendering-avoiding-the-need-for-100-useless-depth-stencil-attachments/2278/3 "2015-04-07T18:22:07Z")

</div>

Thanks a bunch! We’ll implement that approach.
