Jump to content

  • Log In with Google      Sign In   
  • Create Account

Write to FBO vs CopyTexImage


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 dpadam450   Members   -  Reputation: 928

Like
0Likes
Like

Posted 16 April 2013 - 11:33 PM

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



Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7504

Like
1Likes
Like

Posted 17 April 2013 - 12:05 AM

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.



#3 dpadam450   Members   -  Reputation: 928

Like
0Likes
Like

Posted 17 April 2013 - 05:24 PM

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....



#4 mhagain   Crossbones+   -  Reputation: 7978

Like
1Likes
Like

Posted 17 April 2013 - 05:53 PM

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, 20 April 2013 - 03:46 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS