render to multiple textures

What is the most efficient way of rendering to multiple textures?

1. Have a single FBO and bind each texture via glFramebufferTexture2D when required.

2. Have one FBO for each texture and share the depth-texture and the stencil buffer

3. Have one FBO for each texture and don’t share the renderbuffers

BTW: Are depth textures less performant than depth-renderbuffers?

You should try to reuse surfaces as much as possible in your application to keep memory and bandwidth costs low.





Option 2 is likely to provide the best performance. The overhead of creating an FBO per render texture is fairly low, whereas using a single FBO and binding multiple textures to it (as you suggested in option 1) will incur a cost for each glFramebufferTexture2D call you make.





If multiple render passes require depth textures and stencil buffers, but the contents of these do not need to be preserved throughout the rendering for the frame, then you should share these among as many FBOs as possible.





The performance difference between the use of depth textures over depth render buffers is likely to be negligible.





If you target platform supports it, you should call the EXT_discard_framebuffer extenstion at the end of your frame render. This prevents the HW needlessly transferring the contents of the current frame buffer to external memory when they will not be required by the following frame.





Regards,


Joe








Joe2010-07-29 10:38:26