• Advertisement
Sign in to follow this  

Write to FBO vs CopyTexImage

This topic is 1740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a forward rendering approach, these are doing the same exact thing just slightly different and I'm wondering if there would be any difference in the timing. I don't know if writes to fbo vs copying screen if one is slower or faster.



Draw to FBO
Bind FBO as texture and write to screen
Use FBO as a texture for heat/refraction shader drawing particles that refract what is on the screen


Draw to screen

Copy screen to texture

Use texture for heat/refraction shader drawing particles that refract what is on the screen

Share this post


Link to post
Share on other sites
Advertisement

In this special case I would say, that when you write to multiple targets (FBO+screen buffer), that you save bandwidth by not reading from the source buffer when using the copy operation.

 

If you like to use the copy operation, remember, that a copy operation will most likely be like a single full-screen (simple)shader pass, therefor try to add more value to the copy operation by using a customized shader. E.g. instead of a simple copy operation use a shader which downscales the image to 1/4 of the original screen size which can be used to further operations like blur, heat etc.

Share this post


Link to post
Share on other sites

I was talking about using glCopyTexImage2D() to a rgb buffer.  As far as I know you can't apply a shader and downsample during a copy....

Share this post


Link to post
Share on other sites

In terms of timing, in theory using an FBO should be faster as CopyTexImage will respecify a new texture with the appropriate dimensions, format and miplevels, then transfer the data to that new texture (CopyTexSubImage should skip the respecification step). An FBO doesn't need the additional data transfer so can save on the time required to do it.

On the other hand, changing a render target can be a time-consuming operation. It may involve a CPU/GPU synchronization (see http://www.opengl.org/wiki/Synchronization#Implicit_synchronization) which may be a bigger performance impact. If you're doing it a lot of times per frame then there may be a cutoff point beyond which the bandwidth cost of CopyTexImage (or CopyTexSubImage) is the lesser evil. (And remember that an FBO means minimum two render target changes per frame, so that's two potential synchronization points.)

On the other other hand, there are things that FBOs allow you to do that CopyTex(Sub)Image doesn't. You want multiple render targets, for example? Gotta use an FBO.

So that's a lot of "maybe"s and "might"s and whatnot. By now you should be getting the idea that there is no absolute answer to this question, and that cases can exist where either is preferable to the other, and that sometimes those cases can be implementation-dependent. So in the end we need to fall back on the time-honoured answer: benchmark, find which is best for your program, and use that.

 

(Finally, and as a historical note, Doom 3 used CopyTex(Sub)Image and didn't suffer overly much from it, but FBOs didn't exist back then so maybe that's not too relevant a point...)

Edited by mhagain

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement