PDA

View Full Version : Please make FBOs shared across different contexts



JoshKlint
09-23-2013, 11:23 AM
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.

AHeumann
09-24-2013, 12:20 AM
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.

kRogue
09-24-2013, 11:28 AM
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.

JoshKlint
09-25-2013, 12:25 PM
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.


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.

Dark Photon
09-25-2013, 04:45 PM
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.

mhagain
09-25-2013, 06:19 PM
This, together with the 'Request: FBO can use "default" color, depth and stencil buffers (http://www.opengl.org/discussion_boards/showthread.php/182610-Request-FBO-can-use-default-color-depth-and-stencil-buffers?p=1254429#post1254429)' thread, seems to me to be related requests for what is deep-down really the same feature - breaking apart the "FBO as container object" concept and allowing binding of the individual components in isolation.