Managing FBOs in a program with multiple contexts is painful. On Windows I create an OpenGL context on a hidden window and switch back to this when calling FBO commands. (On Mac, an OpenGL context on a hidden window is invalid, but FBOs do appear to be shared across contexts.) Things would be much more straightforward if FBOs were shared across contexts like VBOs, textures, and shaders are.

09-23-2013, 11:20 PM

AHeumann

The reason that FBOs are not shared is that they are container objects only. But the renderbuffer or texture objects representing the buffers are shared.

Just create FBOs for each context and attach the shared renderbuffer/texture objects.

09-24-2013, 10:28 AM

kRogue

There is a really simple, nasty API reason that FBO's are not shareable across contexts: using and editing them is binding them. Specifically, if FBO's where cross-context there are icky things where context A edits the FBO (by changing attachments or changing to what buffers to render) and context B is rendering using that same FBO. One can declare that FBO edits from another thread and context do not take effect until rebind, but that just adds more ickiness in the long run.

The story is similar for VAO's too.

09-25-2013, 11:25 AM

JoshKlint

Quote:

Originally Posted by AHeumann

The reason that FBOs are not shared is that they are container objects only. But the renderbuffer or texture objects representing the buffers are shared.

Just create FBOs for each context and attach the shared renderbuffer/texture objects.

That is a data management nightmare. What would I do, have an std::map as a member of my render buffer class with a VBO for each context...binding textures each time a new context/vbo combo is encountered. That would be a horrible mess.

Quote:

One can declare that FBO edits from another thread and context do not take effect until rebind, but that just adds more ickiness in the long run.

I never render multiple contexts simultaneously. Didn't even know it was possible.

09-25-2013, 03:45 PM

Dark Photon

Quote:

Originally Posted by JoshKlint

I never render multiple contexts simultaneously. Didn't even know it was possible.

Good plan. Unless the contexts map to different GPUs, the performance isn't likely to be so good.