FBO best practices?

Hi,
In my App I do a large number of 2d image operations (composites, blurs etc) on textures. The output of one operation is usually the input for the next. I’ve recently added support for FBOs and I get good performance. Now, there are quite a few different methods to use FBOs to get the same result. I’m wondering what the ‘optimal’ method is.

For example, I could have one FBO for every texture, attach the texture to it’s FBO and then render like this:
BindFBO(1)
render()
BindFBO(2)
render()
etc.

I’ve found that this is slow. So instead I do this (which is fast):
BindFBO(1)
AttachTexture(1)
render()
AttachTexture(2)
render()
etc.

So the question is, is there a happy medium between the two of these that I should be striving for? Should I have 1 FBO for 8 bit texture renders, 1 for 16 etc. Or should I have an FBO for each different texture size? Does anyone know what the perferred method the drivers want us to use FBOs?

Also due to the way the code is set up I am usually forced to bindFBO(0) after each render and then bindFBO(1) before the next render (i.e redundant state change). Is this state change expensive enough that I should work to avoid is as much as possible?

I tend to do 20-40 2D passes per frame.

Thanks!

Malcolm

If you are attaching a texture to the fbo each rendering pass, then that is wasteful. Attach once, and set the draw buffer to the correct color attachment of the bound framebuffer object.

About having fbo’s for 8-bit, 16-bit, etc. textures, all color attachments of an fbo need to be the same.
So you will probably need seperate fbo’s for the different sizes.