Multiple FBOs, changing attachments and float textures

The first part of my question is why have the option for creating more than one FBO? One could simply swap out the attachments before each render.

One answer answer may be that the GPU could render to more than one FBO simultaneously, making many small renders faster. Another may be a single bind call may be faster than many attachment swaps (although there’s near to no difference in desktop GL).

The next part is this: I ran into a bug in WebGL where I attached a standard RGBA texture to an FBO, rendered fine to it and then attached another floating point texture before rendering again. The values rendered to the floating point texture became clamped between 0 and 1. I then found that unbinding and rebinding the same FBO before setting the second, floating point attachment caused the problem to go away and I could render negative values again. Have I found a bug? Should I not be changing attachments without rebinding? Should I not be changing attachments at all and creating an FBO per texture configuration I want to render to?

Thanks in advance!

After some testing I’ve reached the conclusion that WebGL does extra stuff when changing attachments. I tentatively suggest that attaching the same target twice is caught and ignored. Certainly attaching another texture, with a different size or format (maybe even the same size/format) seems to cause a slowdown or errors, for example clamping floating point data. In short, creating a framebuffer for every render target configuration you ever use seems like best practice. (For webgl at least. I haven’t noticed any difference in desktop GL).

Specs: GTX670, drv 304.43, firefox 15.