Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Several 'fixed' FBOs vs. one FBO with frequently reattached textures?

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    Several 'fixed' FBOs vs. one FBO with frequently reattached textures?

    I've read here as well in other places that attaching/detaching textures and render buffers from a frame buffer object is much faster than switching between fbo's.

    I generally only ever render to one or two texture(s) at a time so I have to create several fbo's with a single texture and maybe a depth render buffer attached to it. Wouldn't it be much faster then if I just reused the same fbo and reattached my textures and render buffers or would I run into any problems? For example, is it ok to attach several 1024x1024 RGBA render targets to a FBO, detach them later and bind a bunch of 512x512 RGB render targets to the same FBO?

    Thank you!

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261
    The third option is fastest:
    attach everything to the same fbo. (provided you have only one depth-buffer). Use glDrawBuffers() to switch around stuff. I think in most implementations the depth-buffer rules a lot of things, so try to cluster things around depth-buffers (you may need to attach the same texture onto different fbos). On some implementations, the color-format is important, too (changing from rgba8 to rg32f is expensive).

    In all cases, though - renderbuffers, if you use them, are a tricky picky beast. Re-validation of an FBO should take just a hundred nanoseconds, but all mechanics around internal tricks with renderbuffers can make the gpu and drivers break a sweat if configurations change. The only reason I see in using renderbuffers nowadays - is CSAA. Or maybe purposefully allow the driver-configuration-panel (nvidia ctrl panel or CCC) override/add antialiasing settings.

  3. #3
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311
    That's some interesting information, thank you!

    attach everything to the same fbo. (provided you have only one depth-buffer). Use glDrawBuffers() to switch around stuff.
    this would only work if all my textures are of the same size and format, right? so as soon as I wanted to render to a texture which is only half or a quarter as big as the others (for bloom, etc.), I'd have to create a second fbo anyway.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    892
    Quote Originally Posted by Vexator
    this would only work if all my textures are of the same size and format, right?
    Yep. The FBO is incomplete if certain criteria, and the dimensions are among them, don't match for every attachment. This is where my concern comes into play:

    @Ilian: This does break down the moment you need two disjunctive depth buffers, right? At that point you'd have to at least swap the depth attachment.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,713
    this would only work if all my textures are of the same size and format, right?
    No. The formats and sizes don't have to be the same. The size of the overall FBO will the the smallest size along each dimension. Only for the extension version of FBO does the size have to match; the core version removes this requirement.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    892
    the core version removes this requirement.
    Oops, my bad!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •