SFML community forums
Help => Graphics => Topic started by: Nexus on June 05, 2013, 09:38:53 am
-
This question is not directly related to SFML, more to OpenGL.
If I have two FBOs and switch them alternately to render with a shader multiple times, do I need to call glFlush() before each switching to be sure that everything is rendered before the texture is read again? Because when I omit it, it seems like the data is not ready yet. I also noticed that sf::RenderTexture::display() calls glFlush().
The problem is, flushing the whole OpenGL pipeline is terribly slow. Can't multipass shaders be applied without flushing?
-
As long as everything happens in the same OpenGL context, you shouldn't have to call glFlush. sf::RenderTarget calls it because the target has its own separate context, so it is required so that all other contexts have an updated view of the texture.
I'm afraid I can't help more, I'm not a FBO expert :-\
-
Okay. First I had glClear() and then I rendered with the shader. glClear() was very slow, and it did not change much when i used glScissor().
Replacing glClear() with manual rendering is faster, but the pixels are not ready in time -- it only works when I add a synchronization point like glReadPixels() (to debug) or glFlush().
Does glClear() also introduce synchronization, or do you (anybody) have an idea why it could be so slow, even if I'm clearing only a few pixels of a texture?
-
Is it different if I have a single FBO and just attach a different texture after each shader pass? What would I have to do to make sure everything is drawn before the texture is read again?
-
I have no idea, sorry.
Have you tried to use an OpenGL debugger? There are pretty good ones available for free.
-
I have experimented with glIntercept a bit, but not found anything obvious. Also, I use a macro to check the OpenGL calls.
And of course the good old way of debugging a texture by reading it to the RAM with glReadPixels(). Interestingly, this call makes the behavior correct (i.e. the texture data is ready before each shader pass), which makes me think texture attachment switches in a single FBO require some kind of explicit synchronization. The problem is, I just can't afford any glFlush() calls.
If somebody else has an idea, just speculate please :D
Meanwhile, I'm searching further on the Internet...
Thanks!